JohnIdol
JohnIdol

Reputation: 50107

Why can't I find a Control ID in my Resource file in ATL?

Since I need to do some checks depending on which control is on focus in my app, I am getting the focused control ID like this:

HWND controlOnFocus = ::GetFocus();
int controlID = ::GetDlgCtrlID(controlOnFocus);

I am getting consistent IDs, but I can't find them in the resource file! Can I rely on the IDs I am getting or what?

Any help would be highly appreciated.

Upvotes: 1

Views: 428

Answers (1)

RobH
RobH

Reputation: 3348

Your snippet of code gets the control identifier from whichever window has the current focus. Your application is likely to include lots of windows that you haven't created yourself, such as common dialogue boxes, and the IDs for those won't be in your resource file. Also, not all windows have useful control IDs; For instance, static text controls usually have ID_STATIC (-1?).

Upvotes: 1

Related Questions