1

I'm trying to include into my Dialog Window Procedure, that when the msg WM_CTLCOLORSTATIC is received that I get the ID of the Control that is sending the message.

case WM_CTLCOLORSTATIC: 
        UINT ID = GetWindowLong((HWND)lParam, GWL_ID);

Problem is... when I try to type-cast the lParam of WM_CTLCOLORSTATIC it returns the value 65535, which can't be correct; I don't even have a resource item with the maximum UINT ID 65535.

Can you give me any insight into why this is happening?

  • Are you saying that the window handle (the lParam) is 65535? Or that the result of `GetWindowLong` is 65535? Please clarify your question. – arx Dec 18 '13 at 13:25
  • `GetWindowLong` is deprecated as it doesn't support x64 platforms, the correct function is [`GetWindowLongPtr`](http://msdn.microsoft.com/en-us/library/windows/desktop/ms633585(v=vs.85).aspx) – Mgetz Dec 18 '13 at 13:42
  • I called GetWindowLong with the parameters "lParam" of CTLCOLORSTATIC and the GWL_ message "GWL_ID". So GetWindowLong should return the UINT ID of the Control sending the message CTLCOLORSTATIC. But it doesn't. It returns 65535. –  Dec 19 '13 at 13:22

1 Answers1

5

Your question is not very clear, but I guess that you got an ID of 65535, which is -1, which is pretty standard for a static control ID.

If you want to be able to differentiate your static controls, give them different IDs.

If you don't care of the color for other Static Control, just use:

if ( ID ==  IDC_RECT_CC_00 ) {
    [...]
} else {
    // don't bother
}
manuell
  • 7,528
  • 5
  • 31
  • 58