

System Wide Hot Key (continued)
Our next step is to create the ScreenCap procedure. To do that, let’s click on the “Local Procedures” of our main window and then right click and choose “New Local Procedure”. Name it “ScreenCap”.
Modify the ScreenCap procedure declaration so that it looks like the following:
Next copy and paste the following code into the procedures body:
Again we’re going to use an API call which is the GetWindowRect. We need this to figure out the location and size of the active window. We do this by passing the structure we created which contains 4 variables which are top, bottom, left & right. Once we have the location and size, we’ll use the dCopyBlt() function to copy only this area of the screen into the IMG_Image1 control.
Also note that we’re resizing the IMG_image1 control to match the size of the active window. Next compile and run your program and hit the hotkey you’ve assigned and check out the image. This is the basis for a neat screen capture program. Have fun and enjoy!
PROCEDURE ScreenCap(nMsg is int, nWParam is int, nLParam is int)
RECT is structure
Left is int //Type C : LONG
top is int //Type C : LONG
Right is int //Type C : LONG
bottom is int //Type C : LONG
END
// we need to grab the handle of the active window and
// pass it ot the GetWindowRect function to find out the
// width and height of the window.
FunctionResult is boolean // C Type:BOOL
hWnd is int // C Type:HWND
lpRect is int // Pointer on structureRECT
stMyRect is RECT
lpRect = &stMyRect
hWnd = SysWinActive()
FunctionResult=API("USER32","GetWindowRect",hWnd,lpRect)
IMG_Image1..Width = stMyRect:right -
IMG_Image1..Height = stMyRect:bottom -
IMG_Image1 = ""
gnOrigX = IMG_Image1..Width
gnOrigY = IMG_Image1..Height
dCopyBlt(copyScreen,IMG_Image1,copySrcCopy,stMyRect:left,stMyRect:top,stMyRect:bottom-