用evc4.0创建一个新的工程,选WCE Application,自己填了一些代码用createwindow创建一个窗口,然后再创建了按钮,但是在模拟器上窗口是透明的显示的是模拟器的背景只有创建的按钮是不透明的,要怎么设置才可以有背景色?
ATOM MyRegisterClass(HINSTANCE hInstance, LPTSTR szWindowClass)
{
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW | CS_NOCLOSE;
wc.lpfnWndProc = (WNDPROC) WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = 0;
wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = 0;
wc.lpszClassName = TEXT("test");
return RegisterClass(&wc);
}
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
int x;
MyRegisterClass(hInstance, TEXT("test"));
hWnd = CreateWindow(TEXT("test"), NULL, WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
x = GetLastError();
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
在对应的窗口消息处理函数里添加WM_PAINT消息:
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
//
EndPaint(hWnd, &ps);
break;