Click to See Complete Forum and Search --> : OpenGL / MFC mouse handler
DrPowers
June 16th, 2006, 01:37 PM
I have an openGL window within my main MFC created window. Within the window I want to handle mouse clicks and movements a certain way.
When I am not within the window I want to handle the movement of the mouse with different handlers.
Is there a way to do this? My first guess would be to query the coords of the mouse and compare them to see if they are within the openGL area... if they arent call the other handler.
Is this correct or am I going in the wrong direction?
Mike Harnad
June 16th, 2006, 01:50 PM
I have an openGL window What is the window dervied from? Is it a CView? Typically, you handle the mouse in the assoicated class's OnLButtonDown() handler.
DrPowers
June 16th, 2006, 02:21 PM
What is the window dervied from? Is it a CView? Typically, you handle the mouse in the assoicated class's OnLButtonDown() handler.
CWnd actually.
I catch these msgs within the CWnd OpenGL class
ON_WM_LBUTTONDOWN()
ON_WM_KEYDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_MOUSEWHEEL()
ON_WM_RBUTTONDOWN()
ON_WM_RBUTTONUP()
basically all they do is set a flag so that when I render the OpenGL portion it can know which way to rotate etc. Then I call the base class handler.
The only problem is the Main Wnd has several CWnd classes. But when I load the OpenGL based CWnd I can only control the OpenGL objects.
I hope thats not overly confusing...
Mike Harnad
June 16th, 2006, 02:24 PM
The only problem is the Main Wnd has several CWnd classesWhat does this mean? Your overall design is a bit confusing.
DrPowers
June 16th, 2006, 02:30 PM
What does this mean? Your overall design is a bit confusing.
Sry about the confusion
the Main window has several inlay windows (very distant children of CWnd) in which you can dock onto the sides/bottom of the screen. I'll call these sidebars when I create the openGL window it ocupies the portion of the window not already taken.
The mouse clicks are handled fine within the openGL window... but when I click to move the boarders etc of a non-OpenGL sidebar it doesnt register the mouse click outside of the openGL window.
Does that clear up my problem?
Mike Harnad
June 16th, 2006, 02:40 PM
If the "inlay windows" are also derived from CWnd, you should code the equivalent mouse handlers within that class. You may find it useful to take a look at the OpenGl site. In particular, there's an FAQ/Tutorial (http://www.opengl.org//resources/faq/technical/mswindows.htm) that explains using OpenGL with MFC, etc.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.