用VisualC++6.0的Win32 Application创建了一个空白工程目的是创建一个窗口,编译组建都通过,却不能执行

这是代码,有什么问题吗?跪求大神解决#defineWIN32_LEAN_AND_MEAN//justsaynotoMFC#include<windows.h>//incl... 这是代码,有什么问题吗?跪求大神解决
#define WIN32_LEAN_AND_MEAN //just say no to MFC
#include<windows.h> //include all the windows headers
#include<windowsx.h> //include useful macros
#include<stdio.h>
#include<math.h>
#define WINDOW_CLASS_NAME "WINCLASS1"
LRESULT CALLBACK WindowProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{PAINTSTRUCT ps;
HDC hdc;
switch(msg)
{
case WM_CREATE:
{return(0);
} break;
case WM_PAINT:
{hdc=BeginPaint(hwnd,&ps);
EndPaint(hwnd,&ps);
return(0);
} break;
case WM_DESTROY:
{PostQuitMessage(0);
return(0);
} break;
default:break;
}
return (DefWindowProc(hwnd,msg,wparam,lparam));
}
int WINAPI WinMain(HINSTANCE hinstance,HINSTANCE hprevinstance,LPSTR lpcmdline,int ncmdshow)
{WNDCLASSEX winclass;
HWND hwnd;
MSG msg;
winclass.cbSize=sizeof(WNDCLASSEX);
winclass.style=CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc=WindowProc;
winclass.cbClsExtra=0;
winclass.cbWndExtra=0;
winclass.hInstance=hinstance;
winclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
winclass.hCursor=LoadCursor(NULL,IDC_ARROW);
winclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszClassName=WINDOW_CLASS_NAME;
winclass.hIconSm=LoadIcon(NULL,IDI_APPLICATION);
if(!RegisterClassEx(&winclass))
return(0);
if(!(hwnd=CreateWindowEx(NULL,
WINDOW_CLASS_NAME,
"My Basic Window",
WS_OVERLAPPEDWINDOW | WS_VISIBLE
0,0,
400,400,
NULL,
NULL,
hinstance,
NULL)))
return(0);
while(GetMessage(&msg,NULL,0,0))
{TranslateMessage(&msg);
DispatchMessage(&msg);
}
return((int)msg.wParam);
}
展开
 我来答
mikeyangzx
2013-08-27 · 超过27用户采纳过TA的回答
知道答主
回答量:79
采纳率:0%
帮助的人:62.2万
展开全部
填写winclass结构没完成,还差个winclass.lpszMenuName=NULL;
完整代码如下:
#define WIN32_LEAN_AND_MEAN //just say no to MFC
#include<windows.h> //include all the windows headers
#include<windowsx.h> //include useful macros
#include<stdio.h>
#include<math.h>
#define WINDOW_CLASS_NAME "WINCLASS1"
LRESULT CALLBACK WindowProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{PAINTSTRUCT ps;
HDC hdc;
switch(msg)
{
case WM_CREATE:
{return(0);
} break;
case WM_PAINT:
{hdc=BeginPaint(hwnd,&ps);
EndPaint(hwnd,&ps);
return(0);
} break;
case WM_DESTROY:
{PostQuitMessage(0);
return(0);
} break;
default:break;
}
return (DefWindowProc(hwnd,msg,wparam,lparam));
}
int WINAPI WinMain(HINSTANCE hinstance,HINSTANCE hprevinstance,LPSTR lpcmdline,int ncmdshow)
{
WNDCLASSEX winclass;
HWND hwnd;
MSG msg;

winclass.cbSize=sizeof(WNDCLASSEX);
winclass.style=CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc=WindowProc;
winclass.cbClsExtra=0;
winclass.cbWndExtra=0;
winclass.hInstance=hinstance;
winclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
winclass.hCursor=LoadCursor(NULL,IDC_ARROW);
winclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszClassName=WINDOW_CLASS_NAME;
winclass.lpszMenuName=NULL;
winclass.hIconSm=LoadIcon(NULL,IDI_APPLICATION);

if(!RegisterClassEx(&winclass))
return(0);
if(!(hwnd=CreateWindowEx(NULL,
WINDOW_CLASS_NAME,
"My Basic Window",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0,0,
400,400,
NULL,
NULL,
hinstance,
NULL)))
return(0);
while(GetMessage(&msg,NULL,0,0))
{TranslateMessage(&msg);
DispatchMessage(&msg);
}
return((int)msg.wParam);
}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式