Here. I have also attached this script, together with a test bitmap.
# This example uses the screensaver preview window as target.
OutFile "C:\WINDOWS\System32\PreviewTest.scr"
Name "PreviewTest"
Caption "PreviewTest"
RequestExecutionLevel User
!include "FileFunc.nsh"
!define WS_CHILD 0x40000000
!define WS_VISIBLE 0x10000000
!define SS_BITMAP 0x0000000EL
!define IMAGE_BITMAP 0
!define LR_LOADFROMFILE 0x0010
!define STM_SETIMAGE 0x0172
Function .onGUIInit
# When a screensaver is selected from the dropdown list, windows runs it with /p #### switch, passing it hwnd of the preview window.
${GetParameters} $R0
${GetOptions} "$R0" "/P" $R1 # R1=HWND of preview window
IfErrors 0 Preview
Exec 'Rundll32.exe shell32.dll,Control_RunDLL Desk.cpl,@0, 1'
Abort
Preview:
System::Call '*(&i4,&i4,&i4,&i4) i .r0' # RECT structure
System::Call 'user32::GetWindowRect(i R1, i r0) i.'
System::Call '*$0(&i4,&i4,&i4,&i4)i(.r1,.r2,.r3,.r4)'
System::Free $0
IntOp $1 $3 - $1 # x = right - left
IntOp $2 $4 - $2 # y = bottom - top
System::Call "user32::CreateWindowEx(i 0, t 'STATIC', t 'Preview', i '${WS_CHILD}|${WS_VISIBLE}|${SS_BITMAP}', i 0, i 0, i r1, i r2, i R1, i 0, i 0, i 0) i. R2"
IntCmp $R2 0 PreviewEnd
File /oname=$PLUGINSDIR\Test.bmp ".\Test.bmp"
System::Call "user32::LoadImage(i 0, t '$PLUGINSDIR\Test.bmp', i ${IMAGE_BITMAP}, i 0, i 0, i ${LR_LOADFROMFILE}) i. R3"
System::Call "user32::SendMessage(i R2, i ${STM_SETIMAGE}, i ${IMAGE_BITMAP}, i R3) i."
# Here's the problem: bitmap will not appear in the preview window until the msgbox is displayed.
# What can I do to change that?
Sleep 2000
MessageBox MB_OK|MB_USERICON "Test bitmap should be visible now."
PreviewEnd:
Abort
FunctionEnd
Section "Blank"
SectionEnd