I am trying to create an if statement that when the user releases the left mouse button it will write that out to a text file. I have tried multiple different scenario's and have had no luck, here is some of what I have tried. Thanks for your help!

if(mouse_event == WM_LBUTTONUP)
      {
        myfile.open("testingZoom.txt", std::ios_base::app);
        myfile << "Mouse Release";
      }

OR

if(BN_UNPUSHED == WM_LBUTTONUP)
{
    myfile.open("testingZoom.txt", std::ios_base::app);
    myfile << "Mouse Release";
}

I am trying to create an if statement that when the user releases the left mouse button it will write that out to a text file. I have tried multiple different scenario's and have had no luck, here is some of what I have tried. Thanks for your help!

if(mouse_event == WM_LBUTTONUP)
      {
        myfile.open("testingZoom.txt", std::ios_base::app);
        myfile << "Mouse Release";
      }

OR

if(BN_UNPUSHED == WM_LBUTTONUP)
{
    myfile.open("testingZoom.txt", std::ios_base::app);
    myfile << "Mouse Release";
}

You have to capture your mouse button clicks in the Window procedure called by DispatchMessage in the message pump. For example:

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)                  /* handle the messages */
    {
		 case WM_LBUTTONDOWN: 
			 MessageBox(NULL, "Button Down", "Down", MB_OK);
        	break;
		 case WM_LBUTTONUP: 
		 	MessageBox(NULL, "Button Up", "UP", MB_OK);
        	break;
        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.