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

Threaded View

  1. #1
    Join Date
    Jan 2012
    Posts
    33

    Unhappy WM_MOUSEWHEEL messages missing?

    Hello, new to this forum.

    My first question has to do with giving(forcing) a window focus, so that I can handle WM_MOUSEWHEEL messages.

    I currently have a CGXGridWnd inside of a CDlgPage, im my gridwnd I have a messge handler that will receive WM_MOUSEWHEEL messages and scroll the list accordingly, this works fine until I click on of the four CxShadeButtons on the screen(CDlgPage) which takes focus from my gridwnd (i think), so then after the button is done doing what it does I cannot keep scrolling as I wish.

    I came to this conclusion because I placed this code block inside two functions,
    Code:
    CWnd *pWnd = this->GetFocus();
    	if(pWnd->GetSafeHwnd() != this->GetSafeHwnd())
    		TRACE("NOT IN FOCUS\n");
    I placed this inside my message handler inside the CGXGridWnd class, also in the function called when a button is pressed on the CDlgPage (on this page it is modified to find the Focus of my grid window, so read m_GridWnd. instead of this->)

    So, when a button is pressed I get the TRACE statement, which means the grid is not in focus, and the call I make to GetFocus does not give the gridwnd focus.


    So I guess my overall question is, first should I be forcing focus on the gridwnd for what I want to happen to happen, and if so how do I force focus on a window?



    Thanks in advance,

    Kevin

    EDIT:

    Just to add, When using Spy++ I could not find where AT ALL the WM_MOUSEWHEEL messages were being sent after a button is pressed. I was watching the GridWnd, the button, the CDlgPage, and the entire application window. I mean it to me looks like I don't even have a mousewheel. The messages only start to come up again after I physically use my mouse and click on something in the GridWnd.

    Another EDIT:

    In the function that is called on my CDlgPage when a button is pressed I put the line m_GridWnd.SendMessage(WM_PASTE, 0, 0) and try to paste nothing so I can get focus. This does not work either, it seems only a click will get focus to the list

    EDIT 3:

    If I place the following code into the CDlgPage function that is called when the button is pressed, placed right at the end of the function
    Code:
    CWnd *pWnd = GetFocus();
    HWND hWnd = pWnd->GetSafeHwnd();
    TRACE("Focus Wnd: %d\n", hWnd);
    
    CWnd *ppWnd = GetForegroundWindow();
    HWND hhWnd = ppWnd->GetSafeHwnd();
    TRACE("Foreground Wnd: %d\n", hhWnd);
    It says Focus Wnd: 0 Foreground Wnd: (the application)
    but I place the same code block inside of my scroll message handler in the GridWnd class it actually says that the focus is on the grid control.

    So by having a focus of 0 does that mean that I somehow trapped my focus as in this article
    http://www.olivierlanglois.net/trapped_focus.html
    Last edited by kevindckr; March 5th, 2012 at 11:56 AM.

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