PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Mark Strickland on September 30, 2005, 11:04:12 AM

Title: How to find the IDC in the CUSTOM event??
Post by: Mark Strickland on September 30, 2005, 11:04:12 AM
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?
Title: How to find the IDC in the CUSTOM event??
Post by: TechSupport on September 30, 2005, 01:37:05 PM
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.
Title: Thanks
Post by: Mark Strickland on September 30, 2005, 01:53:40 PM
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.
Title: How to find the IDC in the CUSTOM event??
Post by: TechSupport on September 30, 2005, 03:50:31 PM
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.
Title: Clarification
Post by: Mark Strickland on September 30, 2005, 04:21:37 PM
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.