I need the IDC_ of the control in a CUSTOM event. I am using a SENDMESSAGE to do a KILLFOCUS (without setting the focus to a new control) and I need the IDC value.
Is there some way to get the IDC_ value while in the CUSTOM event?
Hi Mark,
If you know the HWND of the Control then you can easily get the IDC_ using GetWindowLong.
idCtrl = GetWindowLong( hwndControl, %GWL_ID)
Hope this is what you are looking for.
Thanks for the reply.
My Masked Edit functions have sort of gotten "out of control" (no pun intended).
I have some functions that handle input of SSN/PHONE/DATE and other special formats on the fly as you type. I was trying to handle the ESCAPE key as an "abort" of sorts for a form. I was using SETFOCUS in the CUSTOM event for next control in the Z order and was causing problems.
If I do a SENDMESSAGE ... KILLFOCUS then the SETFOCUS of the next control in the Z order does not fire.
Thanks for the help.
Maybe you can use something like the following to set focus to the next control in the zorder:
SetFocus GetNextDlgTabItem( hWndForm, hWndControl, %FALSE)
Quote
If I do a SENDMESSAGE ... KILLFOCUS then the SETFOCUS of the next control in the Z order does not fire.
I am pretty sure that I read somewhere that you should not explicitly send a WM_KILLFOCUS message to controls.
I tested and a SENDMESSAGE with a KILLFOCUS does what I need.
Previously I used the code below to change the focus in the CUSTOM event to handle function keys.
FF_CONTROL_SETFOCUS GETNEXTDLGTABITEM(hWndForm, hWndControl, %FALSE)
This caused a SETFOCUS event on the next control in Z order before the KILLFOCUS on the control where I pressed the function key and it caused a problem with how I am editing fields.
When I do this (below) it fires KILLFOCUS but without moving focus to any other control first.
SENDMESSAGE hWndForm, %wm_command, MAKDWD(GETWINDOWLONG( hWndControl, %GWL_ID),%en_killfocus),hWndControl
I will be aware to look for problems based on your previous comment.
Thanks.