CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Jun 2004
    Posts
    30

    Catching mouse event on window border

    Hi all!

    I'm wondering how to catch a certain mouse event:

    After resizing a modeless dialog box, I want a function to run when the user releases the left mouse button. WM_LBUTTONUP won't work for some reason.

  2. #2
    Join Date
    Jun 2004
    Posts
    7
    Can you explain why WM_LBUTTONUP won't work ? Do you notice that you need to give a little bit more explanations to let us help you - if we can ?

  3. #3
    Join Date
    Jan 2002
    Location
    Czech
    Posts
    251
    Look at the WM_NCLBUTTONUP message. It should work outside of the window, but I am not sure with the border.

  4. #4
    Join Date
    Mar 2002
    Location
    Banglore
    Posts
    322
    trap WM_NCLBUTTONUP message

  5. #5
    Join Date
    Jun 2004
    Posts
    30
    Seems WM_NCLBUTTONUP won't work either.

    I'm running the program in a dialog window. From this dialog I can open modeless child dialogs. Each child dialog starts a thread to paint a Direct3D window inside the child dialog. When a child dialog is resized, I need to pause the thread, and when the user is finished resizing the dialog, the Direct3D device needs to be reset and the thread started again.

    It would be easier of course if I could do without the thread, but I still need the dialog to be able to receive notifications and function calls, and I don't know how I would otherwise be able to do that.

  6. #6
    Join Date
    Mar 2002
    Location
    Banglore
    Posts
    322
    Originally Posted by O.P.
    Seems WM_NCLBUTTONUP won't work either
    well from ur problem it looks it shud work in ur scenario.
    by the way have u tried it or not?

  7. #7
    Join Date
    Jun 2004
    Posts
    30
    Originally posted by Kapil Maheshwari
    well from ur problem it looks it shud work in ur scenario.
    by the way have u tried it or not?
    ON_WM_LBUTTONUP does work somewhat, if I after I resized the dialog click once inside it. What I did then was to replace ON_WM_LBUTTONUP with ON_WM_NCLBUTTONUP in the MESSAGE_MAP structure and the OnLButtonUp(UINT, CPoint) with NcOnLButtonUp(...), but so far nothings happening.

    Edit: I suppose there is a function for checking mouse stats, but I can't find anything. What function can I use to check the stats of mouse buttons?
    Last edited by O.P.; July 2nd, 2004 at 08:47 AM.

  8. #8
    Join Date
    Mar 2002
    Location
    Banglore
    Posts
    322
    can u post ur project (may be dummy but simulating the same scenario).

  9. #9
    Join Date
    Jun 2004
    Posts
    30
    Here's the relevant code. One weird thing tough: I get a response if I double click on the border.

    Code:
    BEGIN_MESSAGE_MAP(DialogSpectrum, CDialogView)
    	ON_BN_CLICKED(IDC_SUSPEND, OnBnClickedSuspend)
    	ON_BN_CLICKED(IDC_RUN, OnBnClickedRun)
    
    	// To get resize notification
    	ON_WM_SIZE()
    	ON_WM_NCLBUTTONUP()
    END_MESSAGE_MAP()
    
    void DialogSpectrum::OnNcLButtonUp(UINT u, CPoint c) {
    	RECT WindowRect;
    
    	if (Resizing && g_pd3dDevice) {
    		DisplayWnd.GetClientRect(&WindowRect);
    		d3dpp.BackBufferWidth = WindowRect.right;
    		d3dpp.BackBufferHeight = WindowRect.bottom;
    
    		g_pVB->Release();
    		g_pd3dDevice->Reset(&d3dpp);
    		g_pd3dDevice->CreateVertexBuffer(1024 * 3 * sizeof CUSTOMVERTEX,
    			0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL);
    		Resizing = false;
    		DialogThread->ResumeThread();
    	}
    }
    
    void DialogSpectrum::OnSize(UINT nType, int cx, int cy) {
    	if (DisplayWnd.GetSafeHwnd()) {
    		Resizing = true;
    
    		CDialog::OnSize(nType, cx, cy);
    		m_resizer.Move();
    	}
    }
    
    void DialogSpectrum::Paint(CArray<RadioUDP> &Arr, int PNum) {
    
    [ ... ]
    
    	if (Resizing)
    		DialogThread->SuspendThread();
    }

  10. #10
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917
    Why don't you handle WM_EXITSIZEMOVE and/or WM_ENTERSIZEMOVE?
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  11. #11
    Join Date
    Jun 2004
    Posts
    30
    Originally posted by JohnCz
    Why don't you handle WM_EXITSIZEMOVE and/or WM_ENTERSIZEMOVE?
    Good question. Now I do, and it worked just fine! Many thanks.

  12. #12
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917
    So, a question was a solution you needed. You are welcome, glad to be of help.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured