Date: 02-16-2022
Return to Index
created by gbSnippets
'This short snippet by Brad shows the basics of creating a screensaver
'using the dialog itself as the canvas on which to draw the graphics.
'In the snippet http://gbl_00466 a more complete screensaver is shown
'which uses a graphic control as the canvas.
'Primary Code:
'The screensaver graphics code is handled entirely within
'the WM_Paint event.
Case %WM_PAINT
Local PS AS Paintstruct, hDC AS Long
Local SzText As AsciiZ * 84
hDC = BeginPaint(CB.Hndl, PS)
SetBkMode hDC, %TRUE
szText = "This is my screen saver Clic Mouse to Exit."
textOut HDC, 5, 60, szText, Len(szText)
EndPaint CB.Hndl, PS
'Compilable Example: (Jose Includes)
'Credit Brad D. Byrne
#Compiler PBWin 9, PBWin 10
#Include "WIN32API.INC"
Function PBMain As Long
Local hDlg As DWord, Count As DWord
Dialog New 0, "",0,0,0,0, %WS_POPUP Or %WS_MAXIMIZE TO HDLG
Dialog Show Modeless hDlg Call MainProc
Do '----------- start message loop ----------
Dialog Doevents TO Count
Loop While Count '----------- end message loop ----------
? "bingo"
End Function
CallBack Function MainProc As Long
Select Case Cbmsg
Case %WM_LBUTTONDOWN, %WM_RBUTTONDOWN
Dialog Send CB.Hndl, %WM_SYSCOMMAND, %SC_CLOSE, 0
Case %WM_PAINT
Local PS AS Paintstruct, hDC AS Long
Local SzText As AsciiZ * 84
hDC = BeginPaint(CB.Hndl, PS)
SetBkMode hDC, %TRUE
szText = "This is my screen saver Clic Mouse to Exit."
textOut HDC, 5, 60, szText, Len(szText)
EndPaint CB.Hndl, PS
End Select
End Function
'gbs_00468
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm