March 29, 2024, 01:38:16 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


How to: Use PaintDesktop

Started by ZeroDog, July 26, 2012, 03:57:14 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ZeroDog






' How to: Use PaintDesktop
' By ZeroDog
' ----------------------------------------------------------------------------------
' This tutorial describes how to use the PaintDesktop API function in a window.
' The PaintDesktop function fills the clipping region in the specified device context
' with the desktop pattern or wallpaper. The function is provided primarily for shell
' desktops.
' ----------------------------------------------------------------------------------

'What we will do is use the PaintDesktop API to paint the desktop image in a
'window we create.  When no other window messages are being processed in the
'window message handler subroutine, we will call the PaintDesktop function.

'The first thing we will do is declare the PaintDesktop API function.
declare import,PaintDesktop(hdc as int),int
' hdc - Handle to the device context. We can get this using the gethdc function.

' Our window variable.
def win as window

' We will now open the window.
openwindow win,0,0,400,300,@noautodraw|@maxbox|@minbox|@size,0,"paintdesktop",&winproc

' The PaintDesktop function requires the handle to the device context for the window,
' So we will use the gethdc function to retrieve it. 
' Variable to store the handle to the device context for the window.
def winhdc as int
winhdc=gethdc(win)

' Process window messages until run=0 (program closed).
run=1
waituntil run=0
'We need to release the memory used by the HDC with the releasehdc function.
releasehdc(win,winhdc)
closewindow win
end
' ----------------------------------------------------------------------------------


' ----------------------------------------------------------------------------------
' Our window message handler.
sub winproc(),int
select @class
'---------------------------------------------------------------
'When no other messages are processed, paint the window with the dekstop image.
default
PaintDesktop(winhdc)
'---------------------------------------------------------------
' When the user closes the window, end the program.
case @idclosewindow
run=0
'---------------------------------------------------------------
endselect
return 0
endsub
' ----------------------------------------------------------------------------------