Windows Events

D

DaveL

I have a Base Window
public class InheritForm:BaseForm

when Controls are added
i want to add a eventhandler that will fire 1st before
the other control events
as in the leave and enter events

ive tried Control_added event but my events fire after the inherited
Controls enter/leave events

Ive also tried OnControlCreate() well Test App Hangs

Where is the best place to add leave/enter events
in the base form , so they will fire 1st before the leave /enter in the
inherited form

DaveL
 
J

Jeroen Mostert

DaveL said:
I have a Base Window
public class InheritForm:BaseForm

when Controls are added
i want to add a eventhandler that will fire 1st before
the other control events
as in the leave and enter events

ive tried Control_added event but my events fire after the inherited
Controls enter/leave events

Ive also tried OnControlCreate() well Test App Hangs
You can't do this with event handlers. If you design your forms in the
regular way, the constructor of the derived form will create the controls
and add event handlers before your base class has a chance to run anything,
so any event handler it adds will necessarily fire after those of the
derived form.

In Windows Forms there's (AFAIK) no way to change the event bubbling order
either, so you can't tell the event to go to the form before it goes to the
child control. What you *can* do is subclass any created controls (using
NativeWindow) so you can override handling for WM_SETFOCUS and WM_KILLFOCUS,
but this is quite low-level and dangerous (not to mention hard to get right).

You could consider creating an item template with the desired functionality
pre-added. This isn't as maintainable as inheritance, since you cannot
update the behavior in a central place and have all the existing uses
changed, but it might do.
 
D

DaveL

i was working with wndproc of mybaseform
got the wm_command on textboxes functioning

but having problem with hiword and lowword of the lparm and wparm

Do you have any examples of getting Focus Events in wndProc

public const int LBN_KILL_FOCUS = 5;

public const int CBN_KILL_FOCUS = 4;

public const int WM_KILLFOCUS = 0x0008;

public const int EN_KILLFOCUS = 0x0200;

public const int NM_KILLFOCUS = unchecked (NM_FIRST - 8);

public const int WM_NOTIFY = 0x004E;

public const int NM_FIRST = (int)(0U-0U); // not sure if this one is
correct



I'll keep Playing with it

thanks alot much appriciated

DaveL
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top