Hi all,
I have a question regarding some things in win32 programming. I can write my own code, but there are some things that I don't completely understand, such as what some things do. So I have a list here of things I don't completely understand, so hopefully you will answer as many as you can!
1. HIWORD & LOWORD
2. WPARAM & LPARAM (I know they have something to do with messages)
3. When you check to see if registration of the window class failed or not, why do you use a reference (I think it's a reference). Example: why
if (!RegisterClassEx(&wincl))
instead of
if (!RegisterClassEx(wincl))
4. In WM_ONPAINT when I draw text on the screen, why does a whole bunch of weird characters appear after the text that's supposed to be drawn if the area in which the text is drawn is bigger than the actual text.
Thanks! I will ask other questions if I think of any more.
HIWORD and LOWORD are macros to get the high-order or low-order word of a dword(double word)
| CODE |
#define LOWORD(l) ((WORD) (l)) #define HIWORD(l) ((WORD) (((DWORD) (l) >> 16) & 0xFFFF))
|
And WPARAM and LPARAM are 32bit(DWORD) message parameters.
It depends on the message what is stored there. Since some messages(ar all?) pass different information in the high-order and low-order word, you use the macros HIWORD and LOWORD to get the parameters you need.
If you want to know why Windows sends parameters as 2 DWORDS and not as 4 words, it's either because Microsoft wants to annoy you or because it's faster to send 2 DWORDS than 4 WORDS. :D
Okay Xception, I have some more questions. (Don't worry, not going to be that much more). :D
Why is a reference used when checking to see if the registration of the window class succeeded or not? Also, why is one used in the message loop with 'TranslateMessage(&messages)' and 'DispatchMessage(&messages)'.
WNDCLASS and MSG are structures and that's the way to pass structures as parameters.