On (08 Sep 97) Neil Heller wrote to Roger Scudder...
NH> It seems as though all the programs I am asked to modify are vintage
NH> Windows code containing at least one 10+ page switch statement. Yet
NH> I've never heard about "message crackers". Can these be applied
NH> retroactively without all the hassle necessary if the code were to be
NH> rewritten using a framework like MSF or OWL?
Converting a program to use Message Crackers is definitely simpler than
converting it to OWL or MFC, and it doesn't generally make the final
product noticeably larger or slower like they tend to.
You start with a switch statement, but the message cracker decodes
wParam and lparam for you, and passes the correct bits to your function.
The prototypes you need to user for most functions are given in
windowsx.h as well as MS' documentation for it (which is unfortunately
usually provided only on disk, and often the fact that it's there at all
isn't even mentioned elsewhere in the documentation.)
Basically though, you'll typically end up with something like this:
#define WINDOWPROC LRESULT CALLBACK _export
void doPaint(hWnd window) {
// ...
}
void doCreate(hWnd, CREATESTRUCT FAR *lpCS) {
// ...
}
WINDPROC WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch(msg) {
HANDLE_MSG(hWnd, WM_PAINT, doPaint);
HANDLE_MSG(hWnd, WM_CREATE, doCreate);
// ...
}
}
For these to work, you have to use the names "wParam" and "lParam" for
those parameters in your window procedure. Considering the difficulty
you're likely to run into in finding official documentation on
windowsx.h, the easiest way to find the prototypes for the functions you
write is probably by simply extracting the comments from windowsx.h
itself. It precedes each message cracker macro with the prototype of
the function that macro is intended to call.
Later,
Jerry.
--- PPoint 1.90
---------------
* Origin: Point Pointedly Pointless (1:128/166.5)
|