CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    May 2012
    Posts
    22

    [RESOLVED] Mouse whhel cycling

    I want to run soem code by rolling a mouse wheel.

    MFC, doc/view

    In Mainframe header:
    Code:
    afx_msg BOOL OnMouseWheel (UINT nFlags, short zDelta, CPoint pt);
    In source message map:
    Code:
    ON_WM_MOUSEWHEEL()
    Event handler:
    Code:
    BOOL CMainFrame::OnMouseWheel (UINT nFlags, short zDelta, CPoint pt)
    {	
    	
    	if (zDelta>0)
    	{
    		OnDemokey();
    	}
    	else
    	{
    		OnMinuskey();
    	};	
    	return TRUE;
    };
    If i roll forward my code cyling in "OnDemokey();" if i roll back - in "OnMinuskey();"

    What have I do to make act of rolling the wheel to work like an ordinary key pressing?

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Mouse whhel cycling

    Quote Originally Posted by 330xi View Post
    ...
    What have I do to make act of rolling the wheel to work like an ordinary key pressing?
    Do you mean "MK_MBUTTON - the middle mouse button is down" or what?
    Victor Nijegorodov

  3. #3
    Join Date
    May 2012
    Posts
    22

    Re: Mouse whhel cycling

    Quote Originally Posted by VictorN View Post
    Do you mean "MK_MBUTTON - the middle mouse button is down" or what?
    Very often, the element between left and right mouse button is a kind of wheel. You can push or you can roll it forward or backward. The second kind of movement people perform when they want to move text in browser up or down, for instance. Or with ctrl pressed they change the scale of a picture in Paint win7 or the scale of a text in MS Word or so.

    So I want to work not with pressing this wheellike piece of plastic, but with its onestep rolling.

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Mouse whhel cycling

    What have I do to make act of rolling the wheel to work like an ordinary key pressing?
    To do what? If you have an ordinary keypress handlers, just call them appropriately from the wheel handler.
    Best regards,
    Igor

  5. #5
    Join Date
    May 2012
    Posts
    22

    Re: Mouse whhel cycling

    Quote Originally Posted by Igor Vartanov View Post
    To do what? If you have an ordinary keypress handlers, just call them appropriately from the wheel handler.
    I do exactly like that: I try to call my keypress handlers (OnDemokey(); OnMinuskey() ) in wheel handler (OnMouseWheel), problem is that this call unexpectedly repeats many-many times until program fails with "Unhadled exception ... Stack overflow" Break или Continue? If second, then: "Unhadled exception ... Access violation writing".

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Mouse whhel cycling

    Perhaps, you should call these OnDemokey(); OnMinuskey() not every time but depending on the zDelta value?
    Or, maybe, you should return FALSE just after calling these OnDemokey(), OnMinuskey() ?
    Victor Nijegorodov

  7. #7
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Mouse whhel cycling

    I do exactly like that
    Don't you think that providing a compilable minimal project reproducing your problem would solve your issue much faster than telling us what you do and what you get?
    Best regards,
    Igor

  8. #8
    Join Date
    May 2012
    Posts
    22

    Re: Mouse whhel cycling

    Quote Originally Posted by Igor Vartanov View Post
    Don't you think that providing a compilable minimal project reproducing your problem would solve your issue much faster than telling us what you do and what you get?
    I do. May be later I will come back to this problem. The counting was that somebody already had such symptoms in his experience and the disease had been eliminated.

  9. #9
    Join Date
    May 2012
    Posts
    22

    Re: Mouse whhel cycling

    I got the wanted result:
    I start to send messages as if this keys have been pressed out of mousewheel handler instead of calling their handlers..

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