We can start building a small example to retrieve the bounding rectangle of the windows desktop. In user32.dll we can found 2 functions that we can use to retrieve this info. GetDesktopWindow() to retrieve the numeric handle to the desktop window and GetWindowRect() to retrieve the bounding rectangle.
#include "ot4xb.ch"
#include "dll.ch"
proc main() ... return
function aGetDesktopRect( lOk )
local cRect := ChrR( 0 , 16) // Same as Replicate(Chr(0),16)
ot4xb peek and poke functions work with numeric memory pointers or also with Xbase++ character buffers, in this case we are going to use a character buffer to avoid the allocation a release steps.
local hDesktop
local nShift
local aRect := NIL
// Retrieve the handle to the desktop window
hDesktop := DllCall( "user32" , DLL_STDCALL ,"GetDesktopWindow");
// Fill cRect with GetWindowRect()
lOk := ( DllCall("user32",DLL_STDCALL,"GetWindowRect",hDesktop,@cRect) != 0 )
if lOk
aRect := Array(4)
nShift := 0
At every call to any ot4xb peek or poke function nShift will be increased with the size in bytes of the read or write operation, by this way you can use it in subsequent calls to peek or poke functions.
aRect[1] := PeekDWord(cRect,@nShift)
aRect[2] := PeekDWord(cRect,@nShift)
aRect[3] := PeekDWord(cRect,@nShift)
aRect[4] := PeekDWord(cRect,@nShift)
end
return aRect
Peek functions have an alternate syntax to retrieve some members of the same type in only 1 call.
function aGetDesktopRect( lOk )
...
aRect := PeekDWord(cRect,0,4) // returns an array of 4 LONG items