P
Paul N
I have a style question. In my code, I have a function that receives
messages, and deals with some of them while passing others on to a
further function. For instance:
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
LPARAM lParam)
{
switch (message) {
case WM_CREATE:
// stuff here
default:
return DefWindowProc(hWnd, message, wParam, lParam); } }
Now, some of the other messages require me, in some circumstances, to
also pass the message on to DefWindowProc either after, or instead of,
dealing with it in my function. Obviously one way to do this is to
simply call DefWindowProc there as well. But I was wondering if there
was a neater way. One way would be to use a goto; a second way would
be to set a flag if I want DefWindowProc to be called and then have
if (flag) DefWindowProc(...)
after the switch. Possibly there's also a way, like Duff's device,
using big "if"s that span the case labels... Anyhow, would anyone
recommend any of these techniques, or are there any other alternatives
I've missed?
Thanks for any thoughts.
Paul.
messages, and deals with some of them while passing others on to a
further function. For instance:
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
LPARAM lParam)
{
switch (message) {
case WM_CREATE:
// stuff here
default:
return DefWindowProc(hWnd, message, wParam, lParam); } }
Now, some of the other messages require me, in some circumstances, to
also pass the message on to DefWindowProc either after, or instead of,
dealing with it in my function. Obviously one way to do this is to
simply call DefWindowProc there as well. But I was wondering if there
was a neater way. One way would be to use a goto; a second way would
be to set a flag if I want DefWindowProc to be called and then have
if (flag) DefWindowProc(...)
after the switch. Possibly there's also a way, like Duff's device,
using big "if"s that span the case labels... Anyhow, would anyone
recommend any of these techniques, or are there any other alternatives
I've missed?
Thanks for any thoughts.
Paul.