-
September 6th, 2013, 05:00 AM
#31
Re: [RESOLVED] how can i call LRESULT CALLBACK WindowProc() function?
Originally Posted by 2kaud
Code:
else
{
printf("another event detected\n");
}
You do realise that this code will never execute? Previously you have a test for a non-zero value, then you have a test for a zero value so one of those conditions must be true!
You can therefore simplify the tests slightly
Code:
#define BUTTON_RELEASE 0
if(mer.dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED)
{
printf("left button press \n");
}
else if(mer.dwButtonState == RIGHTMOST_BUTTON_PRESSED)
{
printf("right button press \n");
}
else if(mer.dwButtonState == FROM_LEFT_2ND_BUTTON_PRESSED)
{
printf("middle button press \n");
}
else if(mer.dwButtonState == BUTTON_RELEASE)
{
printf("button release\n");
}
else
{
printf("another event detected\n");
}
IMO I prefer not to have nested if statements like this and would code this as
Code:
#define BUTTON_RELEASE 0
switch (mer.dwButtonState) {
case BUTTON_RELEASE:
puts("button release");
break;
case FROM_LEFT_1ST_BUTTON_PRESSED:
puts("left button press");
break;
case RIGHTMOST_BUTTON_PRESSED:
puts("right button press");
break;
case FROM_LEFT_2ND_BUTTON_PRESSED:
puts("middle button press");
break;
default:
puts("another button press");
break;
}
I would also use a #define (or a const int as appropriate) to define constants (such as the 0 for the button release test) to make the program more readable and more easily maintainable in the future.
thanks for all. thanks
-
September 6th, 2013, 05:17 AM
#32
Re: [RESOLVED] how can i call LRESULT CALLBACK WindowProc() function?
Originally Posted by Cambalinho
in these case, i'm using a console aplication, so i don't have the windows class. then how can i call the LRESULT CALLBACK WindowProc() function?
This Marius Bancila's Blog might be helpful for you.
Victor Nijegorodov
-
September 6th, 2013, 05:21 AM
#33
Re: [RESOLVED] how can i call LRESULT CALLBACK WindowProc() function?
Originally Posted by VictorN
thanks for all
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|