May 11, 2024, 03:33:08 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Getfocus?

Started by JoaoAfonso, October 31, 2009, 05:40:08 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

JoaoAfonso

Good evening.
How to find out which control has the focus, at the moment?
Thanks in advance
JoÃÆ'ƒÂÃ,£o Afonso
Viriato
-----------------
Iberia MUD
www.iberiamud.com
iberiamud.com:5900

sapero

$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

JoaoAfonso

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!
JoÃÆ'ƒÂÃ,£o Afonso
Viriato
-----------------
Iberia MUD
www.iberiamud.com
iberiamud.com:5900

Bruce Peaslee

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?
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles