简体   繁体   中英

WM_CTLCOLORSTATIC lParam, C++ WINAPI

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?

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
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM