新手求教这怎么改
#include<windows.h>
HWND Mainwindowhandle = 0;
bool Initwindowsapp(HINSTANCE Instancehandle,int Show);
int Run();
LRESULT CALLBACK Wndproc(
HWND Hwnd,
UINT Msg,
WPARAM Wparam,
LPARAM Lparam);
int WINAIP; int WinMain_stdcall(
HINSTANCE Hinstance,
HINSTANCE Hprevinstance,
PSTR Pcmdline,
int Nshowcmd)
{
if(!Initwindowsapp(Hinstance,Nshowcmd))
{
MessageBox(0,"Init - Failed","Error",MB_OK);
return 0;
}
return Run ();
}
bool InitwindowsAPP(HINSTANCE Instancehandle,int Show)
{
WNDCLASS Wc;
Wc.Stale = CS_HREDRAW|CS_VREDRAW;
Wc.Lpfnwndproc = Wndproc;
Wc.Cbclsextra = 0;
Wc.Cbwndextra = 0;
Wc.Hinstance = Instancehandle;
Wc.Hicon = LoadIcon(0,IDI_APPLICATION);
Wc.Hcursor = LoadCursor(0,IDC_ARROW);
Wc.Hbrbackground =
static_cast<Hbrush>(GetStockObject(WHITE_BRUSH));
Wc.Lpszmenuname = 0;
Wc.Lpszclassname = "Hello";
if(!RegisterClass(&Wc))
{
MessageBox(0,"RegisterClass - Failed",0,0);
return false;
}
Mainwindowhandle = CreateWindow(
"Hello",
"Hello",
WS_OVERLAOOEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
0,//50
0,
Instancehandle,0);
if (Mainwindowhandle == 0)
{
MessageBox(0,"Createwindow - Failed",0,0);
return false;
}
ShowWindow (Mainwindowhandle,Show);
UpdateWindow(Mainwindowhandle);
return true;
}
int Run()
{
MSG Msg;
ZeroMemory(&Msg,sizeof(MSG));
while(GetMessage(&Msg,0,0,0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.Wparam;
}
LRESULT CALLBACK Wndproc(
HWND Windohandle,
UINT Msg,
WPARAM Wparam,
LPARAM Lparam)
{
switch (Msg)
{
Case WM_LBUTTONDOWN:
::MessageBox(0,"Hello World","Hello",MB_OK);
return 0;
Case WM_KEYDOWN:
if(Wparam == VK_ESCAPE)
::DestroyWindow(Mainwindowhandle);
return 0;
Case WM_DESTRY:
::PostQuitMessage(0);
return 0;
}
return ::DefWindowProc(Windowhandle,Msg,Wparam,Lparam);
}
[解决办法]
插入代码啊 别直接复制