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

Thread: WM_MOUSEWHEEL messages missing?

  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 10:56 AM.

  2. #2
    ovidiucucu's Avatar
    ovidiucucu is offline Moderator/Reviewer Power Poster
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,021

    Re: WM_MOUSEWHEEL messages missing?

    What is "CGXGridWnd inside of a CDlgPage"?
    Ovidiu Cucu
    "When in Rome, do as Romans do."
    Visit: Microsoft Virtual Academy
    Follow: https://twitter.com/#!/ovidiucucu
    My blog: http://codexpert.ro/blog/author/ovidiu-cucu/

  3. #3
    Join Date
    Jan 2012
    Posts
    33

    Re: WM_MOUSEWHEEL messages missing?

    Ok, I think I have fixed my problem after some searching and guess and check coding.

    It seems that in most (if not all) of my CheckEnables functions (checks the dialog page to see if controls need to be enabled or disabled based on current program data) violate this webpage and the bug it details

    http://www.olivierlanglois.net/trapped_focus.html

    It was never a problem until I came to this problem. My solution was creating this function
    Code:
    void CSpreadSheetPage::GiveFocusToGrid()
    {
    	PostMessage(WM_SETFOCUS, (WPARAM)GetDlgItem(IDC_RAM_GRID)->GetSafeHwnd());
    	return;
    }
    And calling it after each time a button is pressed on my CSpreadSheetPage, and so far it seems to work fine.



    I would thank anyone who posted, but it seems I either asked a stupid question or no one has ever encountered this that had the time to read it. Either way, thanks for listening interwebz

  4. #4
    Join Date
    Jan 2012
    Posts
    33

    Re: WM_MOUSEWHEEL messages missing?

    CxGridWnd is a custom control documented here

    http://www.google.com/url?sa=t&rct=j...OOT95XQtDPr_4A

    Sorry huge URL, might break after a few years.

    But is just a excel type custom grid control we use to display info about each step in a program to users. Here the user can move, delete, copy, and add steps using 4 buttons at the bottom of the dialog page containing the CxGridWnd control.


    -----

    Sorry didn't see your response ovidiucucu

  5. #5
    ovidiucucu's Avatar
    ovidiucucu is offline Moderator/Reviewer Power Poster
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,021

    Re: WM_MOUSEWHEEL messages missing?

    Quote Originally Posted by kevindckr View Post
    CxGridWnd is a custom control documented here

    http://www.google.com/url?sa=t&rct=j...OOT95XQtDPr_4A
    Well then, just ask there.
    Ovidiu Cucu
    "When in Rome, do as Romans do."
    Visit: Microsoft Virtual Academy
    Follow: https://twitter.com/#!/ovidiucucu
    My blog: http://codexpert.ro/blog/author/ovidiu-cucu/

  6. #6
    Join Date
    Jan 2012
    Posts
    33

    Re: WM_MOUSEWHEEL messages missing?

    I'm sorry, what do you mean by just ask there?

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center