CreateWindow的出错解决
CreateWindow返回NULL,而且GetLastError()也返回0,代码如下:
WNDCLASSEX wc =
{
sizeof( WNDCLASSEX ), CS_CLASSDC, NULL/*gWndProc 注意这里直接把它写成 NULL ,贪方便啊.*/,
0L, 0L,
GetModuleHandle( NULL ), NULL, NULL, NULL, NULL,
classname, NULL
};
RegisterClassEx( &wc );
HWND hWnd = CreateWindow( classname, wndname,
WS_DLGFRAME | WS_SYSMENU, 0, 0,m_ScreenWidth, m_ScreenHeight,
::GetDesktopWindow(), NULL,wc.hInstance, NULL );
#include <windows.h>
#include <stdio.h> LRESULT CALLBACK WinSunProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
); int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
WNDCLASS wndcls;
wndcls.cbClsExtra=;
wndcls.cbWndExtra=;
wndcls.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wndcls.hCursor=LoadCursor(NULL,IDC_CROSS);
wndcls.hIcon=LoadIcon(NULL,IDI_ERROR);
wndcls.hInstance=hInstance;
wndcls.lpfnWndProc=WinSunProc;
wndcls.lpszClassName="sunxin2006";
wndcls.lpszMenuName=NULL;
wndcls.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wndcls); HWND hwnd;
hwnd=CreateWindow("sunxin2006","http://www.sunxin.org",WS_OVERLAPPEDWINDOW,
,,,,NULL,NULL,hInstance,NULL); ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd); MSG msg;
while(GetMessage(&msg,NULL,,))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
} LRESULT CALLBACK WinSunProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
switch(uMsg)
{
case WM_CHAR:
char szChar[];
sprintf(szChar,"char code is %d",wParam);
MessageBox(hwnd,szChar,"char",);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"mouse clicked","message",);
HDC hdc;
hdc=GetDC(hwnd);
TextOut(hdc,,,"程序员之家",strlen("程序员之家"));
//ReleaseDC(hwnd,hdc);
break;
case WM_PAINT:
HDC hDC;
PAINTSTRUCT ps;
hDC=BeginPaint(hwnd,&ps);
TextOut(hDC,,,"http://www.sunxin.org",strlen("http://www.sunxin.org"));
EndPaint(hwnd,&ps);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"是否真的结束?","message",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage();
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return ;
}
CreateWindow的出错解决的更多相关文章
- make menuconfig出错解决方法
make menuconfig出错解决方法 2011-06-11 22:22:49 分类: 系统运维 错误现象: make menuconfig In file included from scri ...
- vs连接mysql出错解决方法
vs连接mysql出错解决方法 先按以下的步骤配置一下: **- (1)打开VC6.0 工具栏Tools菜单下的Options选项.在Directories的标签页中右边的"Show dir ...
- paip.vs2010 或.net 4.0安装出错解决大法.
paip.vs2010 或.net 4.0安装出错解决大法. 作者Attilax , EMAIL:1466519819@qq.com 来源:attilax的专栏 地址:http://blog.cs ...
- 黄聪:C#使用Application.Restart重启程序出错解决办法
调用 Application.Restart重启程序出错 解决办法,就是给程序的.exe文件,加上下面的设置
- $ sudo python -m pip install pylint 出错解决方法
问题:在unbuntu执行$ sudo python -m pip install pylint出错解决方法支行以下命令sudo pip install pylint==1.9.3这样roboware ...
- npm中npm install 始终出错解决办法
npm中npm install 始终出错解决办法 错误信息: C:\Windows\System32>npm install -g gulp npm ERR! Windows_NT 6.1.76 ...
- $ gulp watch 运行出错解决方法
$ gulp watch 运行出错解决方法 $ gulp watch 如果你出现了如下报错信息: gulp-notify: [Laravel Elixir] Browserify Fail ...
- 安装openstack同步数据库时出错解决方法
错误提示:(2003, "Can't connect to MySQL server on 'controller' ([Errno -2] Name or service not know ...
- ARM64平台编译stream、netperf出错解决办法 解决办法:指定编译平台为alpha [root@localhost netperf-2.6.0]# ./configure –build=alpha
ARM64平台编译stream.netperf出错解决办法 http://ilinuxkernel.com/?p=1738 stream编译出错信息: [root@localhost stream]# ...
随机推荐
- APP被苹果APPStore拒绝的各种原因 分类: ios相关 app相关 2015-06-25 17:27 200人阅读 评论(0) 收藏
APP被苹果APPStore拒绝的各种原因 1.程序有重大bug,程序不能启动,或者中途退出. 2.绕过苹果的付费渠道,我们之前游戏里的用兑换码兑换金币. 3.游戏里有实物奖励的话,一定要说清楚,奖励 ...
- STL基础知识
一,STL的组成 1.什么是STL STL(Standard Template Library)标准模板库的简称,是由惠普开发的一系列软件的总称,STL现在是C++的一部分,已经被构建于编译系统之内, ...
- [Angular Tutorial] 12 -Event Handlers
在这一步中,您将会在电话细节页面添加一个可点击的电话图片转换器. ·电话细节页面展示了当前电话的一张大图片和几张相对较小的略图.如果我们能仅仅通过点击略图就能把大图片换成略图就好了.让我们看看用Ang ...
- HDU 1813 Escape from Tetris
TMDTMD IDA*没跑了.什么是IDA*? 就是迭代深搜+A*估个价. 然而为什么调了一天? n<=2的时候我输出了东西.... 看了一天. #include<iostream> ...
- python 开发者 精品
当 Python 和 R 遇上北京二手房 http://mp.weixin.qq.com/s?timestamp=1473262097&src=3&ver=1&signatur ...
- [Angular Tutorial] 7-XHRs & Dependency Injection
我们受够了在应用中用硬编码的方法嵌入三部电话!现在让我们用Angular内建的叫做$http的服务来从我们的服务器获取更大的数据集吧.我们将会使用Angular的依赖注入来为PhoneListCtrl ...
- Python 线程池的实现
import urllib2 import time import socket from datetime import datetime from thread_pool import * def ...
- HTML5学习笔记四:html5结构
一.大纲:大纲即文档中各内容区块的结构编排 1. 显示编排内容区块:使用section等元素创建文档结构,每个内容区块使用标题(h1~h6,hgroup); 2. 隐式编排内容区块:根据页面所书写的各 ...
- Jquery Validate 动态添加校验
<cx:script> <script type="text/javascript"> //修改表单验证,提交 $(document).ready(func ...
- js原生设计模式——2面向对象编程之继承—call(this)构造函数式继承
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8&qu ...