[RESOLVED] how can i call LRESULT CALLBACK WindowProc() function? - Page 3
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 3 of 3 FirstFirst 123
Results 31 to 33 of 33

Thread: [RESOLVED] how can i call LRESULT CALLBACK WindowProc() function?

  1. #31
    Join Date
    Apr 2009
    Posts
    625

    Re: [RESOLVED] how can i call LRESULT CALLBACK WindowProc() function?

    Quote Originally Posted by 2kaud View Post
    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

  2. #32
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,352

    Re: [RESOLVED] how can i call LRESULT CALLBACK WindowProc() function?

    Quote Originally Posted by Cambalinho View Post
    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

  3. #33
    Join Date
    Apr 2009
    Posts
    625

    Re: [RESOLVED] how can i call LRESULT CALLBACK WindowProc() function?

    Quote Originally Posted by VictorN View Post
    This Marius Bancila's Blog might be helpful for you.
    thanks for all

Page 3 of 3 FirstFirst 123

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center