改变按钮字体颜色。帮修改代码
#include<windows.h>
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int x[]={BS_PUSHBUTTON,BS_DEFPUSHBUTTON,BS_CHECKBOX,BS_AUTOCHECKBOX,BS_RADIOBUTTON,BS_3STATE, BS_AUTO3STATE,BS_GROUPBOX,BS_AUTORADIOBUTTON,BS_OWNERDRAW};
int xshu= ( sizeof(x) ) / ( sizeof(x[0]) );
static HWND childhwnd[10];
switch (message)
{
case WM_CREATE:
{
childhwnd[0]=CreateWindow(L"button",L"微软操作系统", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON , 0,0,100,50,hwnd,0,0,0);
HDC hdc=GetDC(childhwnd[0]);
SetTextColor(hdc, RGB(0,0,0) );
ReleaseDC(childhwnd[0],hdc);
}
break;
case WM_DESTROY:
{
PostQuitMessage (0);
break;
}
default:
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE,LPSTR,int iCmdShow)
{
WNDCLASS wndclass;
wndclass.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(0,IDI_APPLICATION);
wndclass.hCursor =LoadCursor(0,IDC_ARROW);
wndclass.hbrBackground = static_cast<HBRUSH>( GetStockObject(COLOR_ACTIVEBORDER ) );
wndclass.lpszMenuName = 0;
wndclass.lpszClassName =L"实验";
RegisterClass(&wndclass);
HWND hwnd ;
hwnd= CreateWindow(L"实验",L"标题", WS_OVERLAPPEDWINDOW | WS_VSCROLL |WS_VISIBLE ,100,100,500,500,0,0,hInstance,0);
ShowWindow(hwnd,iCmdShow);
UpdateWindow(hwnd);
MSG msg;
while( GetMessage(&msg,0,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
红色部分,为何不好使啊?