Current location - Health Preservation Learning Network - Healthy weight loss - Change the color of button font with API
Change the color of button font with API
Assume that win32sdk is programmed with VC++. In the message processing function of lresult callback wndproc (hwnd hwnd, uint message, wparam wparam, lparam lparam) automatically generated by the programming wizard, add the following code in the switch (message):

Case WM_CTLCOLORBTN:

{

HDC HDC edit =(HDC)wParam; SetTextColor(hdcEdit,RGB(0,0,0)); //Black

SetBkColor(hdcEdit,RGB(255,255,255)); //White

return(INT _ PTR)create solid brush(RGB(255,255,255));

}

LParam is the HWND of the button at this time. If there are multiple buttons, you can compare them by (HWND)lparam.