int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
static HMENU hMenu,hMenuPop; wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (hInstance, MAKEINTRESOURCE(125)) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH)GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ; if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
} hMenu = CreateMenu();hMenuPop = CreateMenu();
AppendMenu(hMenuPop, MF_STRING, IDM_FILE_NEW, "&New");
AppendMenu(hMenuPop, MF_STRING, IDM_FILE_OPEN, "&Open");
AppendMenu(hMenuPop, MF_STRING, IDM_FILE_SAVE, "&Save");
AppendMenu(hMenuPop, MF_STRING, IDM_APP_EXIT , "&Exit");AppendMenu(hMenu, MF_POPUP, hMenuPop, "&File");
hwnd = CreateWindow (szAppName, TEXT ("Menu"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, hMenu, hInstance, NULL) ;
ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}这这是代码的一部分,其它就不贴上去了当我运行程序时,程序提示错误信息是:
AppendMenuA' : cannot convert parameter 3 from 'struct HMENU__ *' to 'unsigned int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
大概的意思就是第三个参数无法转换,为什么,这难道不正确吗,可书上是这样写的呀,我该怎么解决这个问题呢?哪位能给我提示下,谢啦
PSTR szCmdLine, int iCmdShow)
{
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
static HMENU hMenu,hMenuPop; wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (hInstance, MAKEINTRESOURCE(125)) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH)GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ; if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
} hMenu = CreateMenu();hMenuPop = CreateMenu();
AppendMenu(hMenuPop, MF_STRING, IDM_FILE_NEW, "&New");
AppendMenu(hMenuPop, MF_STRING, IDM_FILE_OPEN, "&Open");
AppendMenu(hMenuPop, MF_STRING, IDM_FILE_SAVE, "&Save");
AppendMenu(hMenuPop, MF_STRING, IDM_APP_EXIT , "&Exit");AppendMenu(hMenu, MF_POPUP, hMenuPop, "&File");
hwnd = CreateWindow (szAppName, TEXT ("Menu"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, hMenu, hInstance, NULL) ;
ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}这这是代码的一部分,其它就不贴上去了当我运行程序时,程序提示错误信息是:
AppendMenuA' : cannot convert parameter 3 from 'struct HMENU__ *' to 'unsigned int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
大概的意思就是第三个参数无法转换,为什么,这难道不正确吗,可书上是这样写的呀,我该怎么解决这个问题呢?哪位能给我提示下,谢啦
-->
AppendMenu(hMenu, MF_POPUP, (UINT)hMenuPop, "&File");
强制类型转化