孙鑫MFC视频第一课的例子窗口不显示

#include<windows.h>//#include<iostream>//#include<cstdlib>#include<stdio.h>LRESULTCAL... #include<windows.h>
//#include<iostream>
//#include<cstdlib>
#include<stdio.h>

LRESULT CALLBACK WinPanProc(
HWND hwnd,
UINT umsg,
WPARAM wParam,
LPARAM lParam
);

int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd
)
{
WNDCLASS wndcls;
wndcls.cbClsExtra=0;
wndcls.cbWndExtra=0;
wndcls.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndcls.hCursor=LoadCursor(NULL,IDC_CROSS);
wndcls.hIcon=LoadIcon(NULL,IDI_ERROR);
wndcls.hInstance=hInstance;
wndcls.lpfnWndProc=WinPanProc;
wndcls.lpszClassName="PanXin";
wndcls.lpszMenuName=NULL;
wndcls.style=CS_HREDRAW | CS_VREDRAW;

RegisterClass(&wndcls);

HWND hwnd;
hwnd=CreateWindow("PanXin","YES!!!",WS_OVERLAPPEDWINDOW,0,0,600,400,NULL,NULL,hInstance,NULL); //变化CW_DEFAULT
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);

MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

return msg.wParam; //变化
}

LRESULT CALLBACK WinPanProc(
HWND hwnd,
UINT umsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(umsg)
{
case WM_PAINT:
HDC hdc;
PAINTSTRUCT ps;
hdc=BeginPaint(hwnd,&ps);
TextOut(hdc,0,0,"PanXin Win",strlen("PanXin Win"));
EndPaint(hwnd,&ps);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"clicked","click",0);
HDC dc;
dc=GetDC(hwnd);
TextOut(dc,0,50,"Again",strlen("Again"));
ReleaseDC(hwnd,dc);
break;
case WM_CHAR:
char szchar[20];
sprintf(szchar,"char is %d",wParam);
MessageBox(hwnd,szchar,"Char",0);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"tui chu ma ?","Exit",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
DefWindowProc(hwnd,umsg,wParam,lParam);
}
return 0;
}

我这个代码在进程里看得到,但是不会弹出窗口。为什么?谢谢大家
展开
 我来答
a741878688
2015-09-29
知道答主
回答量:23
采纳率:0%
帮助的人:9.4万
展开全部
WNDCLASS wndcls;
ZeroMemory( &wndcls, sizeof( WNDCLASS ) );
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式