菜鸟提问!为什么编译不过去??
以下是我的代码!
#include "windows.h"
INT PASCAL WINMAIN(HINSTANCE,HINSTANCE,LPSTR,INT);
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
HINSTANCE myhinse;
char szAppName[]="Windows API Demo";
char szAppTitle[]="A Application Windows API";
INT PASCAL WINMAIN(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdParam,INT nCmdShow)
{
HWND hmainwnd;
MSG message;
WNDCLASS mydc;
if (!hPrevInstance)
{
mydc.style = CS_HREDRAW|CS_VREDRAW ;
mydc.lpfnWndProc = WndProc;
mydc.cbClsExtra = 0;
mydc.cbWndExtra = 0;
mydc.hInstance = hInstance;
mydc.hIcon = LoadIcon(NULL,IDI_APPLICATION);
mydc.hCursor = LoadCursor(NULL,IDC_ARROW);
mydc.hbrBackground = GetStockObject(WHITE_BRUSH);//这句出错了
mydc.lpszMenuName = NULL;
mydc.lpszClassName = szAppName;
RegisterClass(&mydc);
}
hmainwnd = CreateWindow(szAppName,szAppTitle,WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);
ShowWindow(hmainwnd,SW_SHOWMAXIMIZED);
UpdateWindow(hmainwnd);
while (GetMessage(&message,NULL,0,0))
{
TranslateMessage(&message);
DispatchMessage(&message);
}
return message.wParam ;
}
/*********************************************************************
Function : WndProc(HWND,UINT,WPARAM,LPARAM)
Purpose : Processes Message
*********************************************************************/
LRESULT CALLBACK WndProc(HWND hmainwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
char messageLeft[] = "this is a demo application API\n The Left mouse Button have been presed";
char messageRight[] = "this is a demo application API\n The Right mouse Button have been presed";
switch(message)
{
case WM_RBUTTONDOWN:
{
MessageBeep(MB_ICONINFORMATION);
MessageBox(GetFocus(),messageRight,"message",MB_OK|MB_ICONINFORMATION);
break;
}
case WM_LBUTTONDOWN:
{
MessageBeep(MB_ICONINFORMATION);
MessageBox(GetFocus(),messageLeft,"message",MB_OK|MB_ICONINFORMATION);
break;
}
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
default :
break;
return DefWindowProc(hmainwnd,message,wParam,lParam);
}
}
错误提示::error C2440: '=' : cannot convert from 'void *' to 'struct HBRUSH__ *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast