Custom Control 's OnMouseXXX and OnKeyXXX overrides not called 
Author Message
 Custom Control 's OnMouseXXX and OnKeyXXX overrides not called


I am writing a custom control that will represent a 3D view and allow
interaction with the objects in the scene, thus needs to receive mouse
and keyboard events.
I derived it from System::Windows::Forms::Control, created protected
overrides for OnMouseMove, OnMouseDown, OnMouseUp, OnMouseEnter,
OnMouseLeave, OnClick, OnKeyDown and OnKeyUp. Now when I embed my
control in a form and start the application, having breakpoints inside
each of the mentioned overrides, I never reach them. It seems as if
the control doesn't get any mouse or keyboard events.
I've tried this->SetStyle(Selectable, true) in the control's
constructor, no improvement. I've tried to derive from UserControl
instead, same (=no) result.

So I'm beginning to wonder whether
a) I'm deriving from the right class
b) there is some property I need to set or some method I need to call
or some other method I need to override to achieve that my control
gets mouse/keyboard events.

Another question has to do with update:
the custom 3D-engine that is used by the control uses Direct 3D. It's
supposed to show not only a static scene, but animation. To achieve
this, I've created a thread in my control that continously calls the
engines's Update() method (which tells the engine draw it's current
state). So, when the control is created and it's window handle is
valid, I start the engine and the thread; the thread keeps telling the
engine to paint over the control's window. Thus, I've got no OnPaint()
in my control as it would only call engine->Update() which is being
called continously by the thread, anyway.
I wonder whether this is the right way to do things, it kinda seems
ugly to me. Any comments on that?

Anyway, the problem of my OnMouseXXX() and OnKeyXXX() overriden
methods not being called bothers me much more as I can come up with no
solution, which makes me thing I'm doing something completely wrong
here or I leave out something important.

Thanks for any suggestions,

max hajek
known universe/terra/europe/austria/vienna

Wed, 09 Feb 2005 03:31:54 GMT  
 [ 1 post ] 

 Relevant Pages 

1. VB's mousepointer property not working when set from event of custom ATL control

2. VB5 does not like my control's custom property pages

3. Override Create in Custom Controls

4. Override Create in Custom Controls

5. c# custom control (overriding OnClick problem)

6. Virtual override not being called

7. Virtual override of OnCmdMsg not called

8. Virtual override of OnCmdMsg not called

9. MFC Control OnCreate not called via VB, but called under MSVC

10. Can we override a control's OnPaint ?

11. DoDataExchange() Not Getting Called By Custom CFileDialog

12. DoDataExchange() Not Getting Called By Custom CFileDialog


Powered by phpBB® Forum Software