Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

making an OnFocus event

Status
Not open for further replies.

cyprus106

Programmer
Apr 30, 2001
654
how would i make an OnFocus event for my form(s)? could I? Cyprus
 
Greetinx!

You may trap following messages to make the event:
WM_SETFOCUS
WM_KILLFOCUS



Happy programming!))
 
uhh, I used WM_KILLFOCUS and WM_SETFOCUS, but they didn't work, the code checked out, but when I focused on the thing the WM_SETFOCUS was aimed for, it didnt do jack, even tho i had code in the function. any help?
btw, I checked out all of the different beginner mistakes and the stupid stuff, and i've come to the conclusion that...I have no idea whats going on. except that i dont know how reliable the setfocus is, and maybe i associated it with the wrong object. im trying to use setfocus for a forum. Ill post the code up tommorow...Any suggestions? Cyprus
 
Greetinx!

You may also try to use TWinControl's method of SetFocus or use folleing codes:
in header file:
protected:
void __fastcall WMFocus(TMessage &Message);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_SETFOCUS, TMessage , WMFocus)
MESSAGE_HANDLER(WM_KILLFOCUS, TMessage , WMFocus)
END_MESSAGE_MAP(TComponent)


in c file:
void __fastcall TYourComponent::WMFocus(TMessage &Message)
{
if(Message.Msg == WM_SETFOCUS)
//to do on set focus event
else
//to do on kill focus event
}


Happy programming!))
 
ok, yes. i was being dumb and forgot to put in the if statement. thanks, pavlo. Cyprus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top