| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 295 人关注过本帖
标题:为何不出现窗口
只看楼主 加入收藏
*明华锐达*
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2007-2-7
收藏
 问题点数:0 回复次数:0 
为何不出现窗口

偶是新手,照着例子写了此程序,通过了编译,链接,但不出现窗口,请各位高手指教;
#include "stdafx.h"
#include "windows.h"
#include "stdio.h"
LRESULT CALLBACK longProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam );

int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
WNDCLASS cls;
cls.cbClsExtra=0;
cls.cbWndExtra=0;
cls.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
cls.hCursor=LoadCursor(NULL,IDC_CROSS);
cls.hIcon=LoadIcon(NULL,IDI_ERROR);
cls.hInstance=hInstance;
cls.lpfnWndProc=longProc;
cls.lpszClassName="longming";
cls.lpszMenuName=NULL;
cls.style=CS_HREDRAW|CS_VREDRAW;
HWND hwnd;
RegisterClass(&cls);
hwnd=CreateWindow("longming","myfirstwin32",WS_OVERLAPPEDWINDOW,0,0,600,400,NULL,NULL,hInstance,NULL);
::ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
MSG msg;
while(GetMessage(&msg,hwnd,NULL,NULL))
{TranslateMessage(&msg);
DispatchMessage(&msg);
}

return 0;
}

LRESULT CALLBACK longProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam )
{ switch(uMsg)
{case WM_PAINT:
HDC hdc;
PAINTSTRUCT ps;
hdc=BeginPaint(hwnd,&ps);
TextOut(hdc,300,300,"l want to surpass you",strlen("l want to marry you"));
EndPaint(hwnd,&ps);
break;
case WM_CLOSE:
MessageBox(hwnd,"do you want to close the window","close the window",MB_YESNO);
DestroyWindow(hwnd);
break;
case WM_CHAR:
char sz[12];
sprintf(sz,"you input char is %c",wParam);
MessageBox(hwnd,sz,"you have input the char",MB_OKCANCEL);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_LBUTTONDOWN:
HDC dc;
dc=GetDC(hwnd);

if(IDOK==MessageBox(hwnd,"You have cllicked the window ","Mouse",MB_OKCANCEL))
TextOut(dc,234,234,"you clicked the window",0);
break;
default: DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}


搜索更多相关主题的帖子: 窗口 窗口 
2007-02-07 14:57
快速回复:为何不出现窗口
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020637 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved