Using Win32 routines
Very well. We have created the label for our event handler and we have requested the event loop information. What now? This is the point at which we need to call a Win32 routine. This, again, is what makes goAsm such a powerful piece of equipment. It allows us to call these routines very simply by means of the Invoke
keyword.
Open your Win32 Help application. This is part of the Microsoft Win32 SDK and can be downloaded from their site. Each time the WM_SIZE
event occurs and our handler is activated, we want to discover the size of the client area (the working area) of the window. Select the "Index" button and type in the text "getClientRect". Click the "Display" button to see the results.
BOOL getClientRect(
HWND hWnd,
LPRECT lpRect
);
If that looks a bit mystifying, don't worry - it's in "C" format. Let's dissect it:
UseData winMainProcedure
, that gave us some information, prominent amongst which is the location of the window's handle and EasyCode always gives this the name "hWnd".RECT
. This is a box which is split into 4 smaller compartments with the pre-made names "left", "top", "bottom", "right". We can call the box whatever we want but these "internal" names are fixed. What we need to do is to create a box of this type and then tell this routine the location where Windows has stored it. That is why the type specified in the routine is LPRECT
- the "LP" part stands for "Long Pointer". Our problem is that we don't know how to make a box to hold a RECT but don't worry - that's what we'll do next. The actual name of the box is given here as "lpRect" but since you are going to create it, you can call it whatever you want.