Hiya,
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
www.wootsoft.com
known universe/terra/europe/austria/vienna
PS
Prakash S
Syncfusion Team
August 27, 2002 08:31 PM UTC
Max,
Looks like there is some code in your class that is interferring with the default Control class's mouse message processing; I am assuming this because I just checked and the OnMouseDown() override in a default wizard generated UserControl(or Control) class always seems to get called. Are you, by any chance, performing Win32 subclassing or intercepting the WndProc method in your class?
Prakash