May 23, 2019, 07:39:15 am

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


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

Code Select





' 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
' ----------------------------------------------------------------------------------