Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Wait for mouse button press (outside of callback)
Index -> Programming, C -> C Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
np_123




PostPosted: Sat Jan 27, 2018 6:44 pm   Post subject: Wait for mouse button press (outside of callback)

I create a window and the below code is the callback for it.
What I'm looking for is a way to wait for those events to happen, using the callback essentially as a trigger. But doing something like toggling a boolean variable and having a loop waiting for it would cause the UI to hang as it's event-driven. Any suggestions?



C:

LRESULT CALLBACK WndProc(       HWND   hWnd,                  // Handle For This Window
                                                        UINT    uMsg,                     // Message For This Window
                                                        WPARAM  wParam,         // Additional Message Information
                                                        LPARAM  lParam)         // Additional Message Information
{
        switch (uMsg) {
        case (WM_LBUTTONDOWN | WM_RBUTTONDOWN): // | WM_LBUTTONUP | WM_RBUTTONUP):
                Cursor.X = GET_X_LPARAM(lParam);
                Cursor.Y = GET_Y_LPARAM(lParam);
                Cursor.buttonmask = wParam;
                break;
        case WM_MOUSEMOVE:
                Cursor.X = GET_X_LPARAM(lParam);
                Cursor.Y = GET_Y_LPARAM(lParam);               
                break;
        case WM_CLOSE:
                MIOGLGraph_CloseWin();
                stGLWinClosed = TRUE;
                return 0;
        }

        // Pass All Unhandled Messages To DefWindowProc
        return DefWindowProc(hWnd,uMsg,wParam,lParam);
}
Sponsor
Sponsor
Sponsor
sponsor
np_123




PostPosted: Sat Jan 27, 2018 8:31 pm   Post subject: RE:Wait for mouse button press (outside of callback)

Nvm figured it out.
I reversed my logic as in:

My non-callback function continuously returns a boolean value determined by an internal variable. I loop on this function, waiting for it to be True. (I assume because it's always entering & returning the procedure, that's why it doesn't hang).
When the callback registers a click it sets the variable to True. This causes the function to return True. Problem now solved.
Ty
Display posts from previous:   
   Index -> Programming, C -> C Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: