IonicWind Software

IWBasic => GUI Central => Topic started by: JoaoAfonso on October 31, 2009, 05:40:08 AM

Title: Getfocus?
Post by: JoaoAfonso on October 31, 2009, 05:40:08 AM
Good evening.
How to find out which control has the focus, at the moment?
Thanks in advance
Title: Re: Getfocus?
Post by: sapero on October 31, 2009, 06:02:15 AM
$include "windows.inc"

int controlId = 0 /*focused*/
int hwnd = _GetFocus()
if (hwnd) then controlId = _GetDlgCtrlID(hwnd)
QuoteAlthough GetDlgCtrlID may return a value if hwndCtl is a handle to a top-level window, top-level windows cannot have identifiers and such a return value is never valid
Title: Re: Getfocus?
Post by: JoaoAfonso on October 31, 2009, 09:32:11 AM
Need to try.
I've checked other messages from controls, like @ENCHANGE and @SETKILLFOCUS, that I could eventually use to do the same thing, but in dialogs, @ENCHANGE works as supposed, but @SETKILLFOCUS no...
Thank you!
Title: Re: Getfocus?
Post by: Bruce Peaslee on November 20, 2009, 12:38:18 PM
sapero's method works for me. I can detect which control got the focus in a routine that looks for data entry errors. My problem is that when the user clicks OK when an error exists, I want to cancel that click (i.e., not process the data and close the dialog). I suppose I could use a flg, but is there another way?