CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: WM_LBUTTONDBLCLK is not responded by CMainFrame?

  1. #1
    Join Date
    Oct 2001
    Location
    Beijing, P.R.China
    Posts
    8

    WM_LBUTTONDBLCLK is not responded by CMainFrame?

    In my simple, standard, appwizard generated MDI application.

    First, I added WM_LBUTTONDBLCLK message handler to class CMainFrame. Then, to test the message process function, I added AfxMessageBox("Just for Test") to test if the message was responded. NO dialog popuped when i double clicked in the client area of the main frame.

    I need your help and thanks very much!


  2. #2
    Join Date
    Oct 2001
    Posts
    15

    Re: WM_LBUTTONDBLCLK is not responded by CMainFrame?

    It sounds like your view class is getting the message, If you click on the frame around the client you should get the dialog box. The client CView is a CWnd-type class which is a child window of the mainframe.


  3. #3
    Join Date
    Oct 2000
    Posts
    379

    Re: WM_LBUTTONDBLCLK is not responded by CMainFrame?

    Hi,
    the surface you are clicking in does not belong to the CMainFrame, but to the MDICLIENT class,
    generated by the framework. You can use the
    subclassing technique to receive mouse notifications, like this:

    1 Derive with class wizard a new class from CWnd, say CMyMDIClient,
    2 Give the mainframe a member variable for this class, say m_myMDIClient,
    3 Subclass it in the mainframe, like

    //in CMainFrame::OnCreate
    if (!m_myMDIClient.SubclassWindow(m_hWndMDIClient))
    {
    AfxMessageBox("Failed to subclass MDI Client");
    return -1;
    }
    //continue with the usual stuff, like creting toolbars etc.



    4 Give your CMyMDIClient message handler for the mouse messages.

    Regards
    clem

    Want to test your C++ skills?
    http://www.softsyst.com/prequizef.htm


  4. #4
    Join Date
    Oct 2001
    Location
    Beijing, P.R.China
    Posts
    8

    Re: WM_LBUTTONDBLCLK is not responded by CMainFrame?

    Thanks a lot.

    But what it more confusing, now it respond WM_LBUTTONDOWN, as well as WM_LBUTTONUP, still doesn't respond WM_LBUTTONDBLCLK.

    Can you tell me why?


  5. #5
    Join Date
    Oct 2001
    Location
    Beijing, P.R.China
    Posts
    8

    WM_LBUTTONDBLCLK still not responded, HELP!

    see my previous article


  6. #6
    Join Date
    Oct 2000
    Posts
    379

    Re: WM_LBUTTONDBLCLK is not responded by CMainFrame?

    Hi again,
    for a window to react on doubleclicks, it must be registered with the CS_DBLCLKS style.
    Obviously, the MDICLIENT is not. To change this untolerable situation, proceed like this:
    1 Override the virtual function PreSubclassWindow,
    2 Get your registered class name of the MDICLIENT (this "class" has NOTHING to do with the C++ class)
    by calling GetClassName,
    3 Read the class infoe int a WNDCLASSEX structure, by calling GetClassInfoEx
    4 change the style, by OR-ing the CS_DBLCLKS into it
    5 Set the style by calling SetClassLong
    6 Enjoy your doubleclicks

    Hope it helps
    Regards
    clem


Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)