Displaying a bitmap in a child within a parent window?
Posted: Wed Jul 02, 2003 9:19 pm
Im trying to display a bitmap within the little mini monitor in the screensaver tab of the 'Display Properties' dialog on WinXP, but i'm having little luck. I've been trying to get this to work for months now and its really doing me in. I have read lots of working examples using WinAPI but i really don't understand them and i can't seem to convert them to make them more simple
I would be very gratefull if someone could point me in the right direction. Basically i need to display a bitmap inside a window which is a child of the 'mini monitor' window and then pass control of all events to the parents callback. sounds easy? not for me 
This is what i have been trying:
Compile this into C:\windows\system32 as whatever.src to make it appear in the screensaver drop down menu. BTW it doesn't work, but it should? Also this program doesn't quit when the parent is closed?
This is what i have been trying:
Code: Select all
;===========================================================================
;-CONSTANTS
;===========================================================================
#WINDOW_PREVIEW = 0
;===========================================================================
;-GLOBAL FLAGS / VARIABLES / STRUCTURES / ARRAYS
;===========================================================================
Global parameter.s
Global prevWinHndlString.s
Global prevWinHndl.l
parameter = UCase(ProgramParameter())
If Len(parameter) > 2
prevWinHndlString = RemoveString(parameter, Left(parameter, 3), 1)
parameter = RemoveString(parameter, Left(parameter, 1), 1)
parameter = Left(parameter, 1)
Else
parameter = RemoveString(parameter, Left(parameter, 1), 1)
prevWinHndlString = ProgramParameter()
If FindString(prevWinHndlString, "-", 0) <> 0 : prevWinHndlString = RemoveString(prevWinHndlString, "-", 1) : EndIf
If FindString(prevWinHndlString, "/", 0) <> 0 : prevWinHndlString = RemoveString(prevWinHndlString, "/", 1) : EndIf
EndIf
prevWinHndl = Val(prevWinHndlString)
;===========================================================================
;-PROCEDURES
;===========================================================================
;simple error checking
Procedure HandleError(result, text.s)
If result = 0 : MessageRequester("Error", text, #PB_MessageRequester_Ok) : End : EndIf
EndProcedure
;execute the preview in the little mini monitor in 'Display Properties'
Procedure ExecutePreview()
previewWindowSize.RECT
GetClientRect_(prevWinHndl, @previewWindowSize)
OpenWindow(#WINDOW_PREVIEW, 0, 0, previewWindowSize\right, previewWindowSize\bottom, #PB_Window_BorderLess | #WS_CHILD | #WS_VISIBLE, "Preview", prevWinHndl)
CatchImage(1, ?PreviewImage)
HandleError(CreateGadgetList(WindowID(#WINDOW_PREVIEW)), "Gadget list in preview window could not be created!")
ImageGadget(1, 0, 0, previewWindowSize\right, previewWindowSize\bottom, UseImage(1))
CloseGadgetList()
Repeat
EventID.l = WaitWindowEvent()
Until EventID = #PB_EventCloseWindow
EndProcedure
;deal with the parameters passed to this program
Select parameter
Case "P" ;when the preview is requested in the screensaver dialog
ExecutePreview()
EndSelect
;===========================================================================
;-BINARY INCLUDES
;===========================================================================
PreviewImage:
IncludeBinary "preview.bmp"