VC60 代码移植到VC2008 的异常之一
来源:互联网 发布:linux 改时区 编辑:程序博客网 时间:2024/06/10 07:39
1。原代码
#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
)
{
HWND hwnd;
MSG msg;
WNDCLASS wndcls;
wchar_t lpszClassName[] = L"sunxin2006";
wchar_t lpszTitle[] = L"http://www.sunxin.org";
wndcls.cbClsExtra=0;
wndcls.cbWndExtra=0;
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.lpszMenuName=NULL;
wndcls.lpszClassName;
wndcls.style=CS_HREDRAW | CS_VREDRAW;
//RegisterClass(&wndcls);
if(!RegisterClass(&wndcls))
{
MessageBeep(0);
return FALSE;
}
//HWND hwnd;
hwnd=CreateWindow(lpszClassName,
lpszTitle,
WS_OVERLAPPEDWINDOW,
0,
0,
600,
400,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
//MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
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:
//wchar_t szChar[20];
char szChar[20];
sprintf_s(szChar,"char code is %d",wParam); //sprintf -> sprintf_s
MessageBox(hwnd,(LPCWSTR)szChar,L"char",0);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,L"mouse clicked",L"message",0);
HDC hdc;
hdc=GetDC(hwnd);
TextOut(hdc,0,50,L"程序员之家",strlen("程序员之家"));
//ReleaseDC(hwnd,hdc);
break;
case WM_PAINT:
HDC hDC;
PAINTSTRUCT ps;
hDC=BeginPaint(hwnd,&ps);
TextOut(hDC,0,0,L"http://www.sunxin.org",strlen("http://www.sunxin.org"));
EndPaint(hwnd,&ps);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,L"是否真的结束?",L"message",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}
2。编译正常,运行以下看看?会有什么状况发生?
3。编译正常,不代表程序没有错误,VC2008还需要进一步完善。不知道2010怎么样。有知道的同仁告知一下。谢谢。
- VC60 代码移植到VC2008 的异常之一
- 从VC6到VC2008移植代码问题总结收藏
- VC6 到 VC2008 的移植日志(1)
- 多做一点,或许会有意外发现---VC60 到 VC2008
- ocx转换为VC60.的代码
- vc60到vs2005
- 移植x264到vs2008之一
- Windows 到 Linux 代码移植的常见问题
- 代码从GCC到MSVC的移植
- VC2003升级到vc2008出现的错误
- vc2008 错误:error LNK2001: 无法解析的外部符号之一
- u-boot移植到mini2440之一
- uboot 2012.10移植到at91sam9260ek草稿之一
- Uboot 2012.10移植到at91sam9260ek草稿之一
- 移植FFMPEG到VS2008系列之一
- VC6.0 动态库或控件代码移植到VC2010一些异常问题
- 使Java代码可移植之一
- mingw/vc2008移植问题记录
- 摇奖机是按照金字塔的原理设计的
- pqmagic分区失败蓝屏解决方案
- SignTool Error: No certificates were found that met all the given criteria错误
- 实现首页显示热门关键字,排序并控制显示数量--Show sorted Popular Search Terms
- C# 解析 Targa文件 (TGA) 图形
- VC60 代码移植到VC2008 的异常之一
- 把C++学再好,也无法凭这个找到好工作
- vs2005 调试报桌面应用程序错误
- 在MySQL中导入导出文件
- postgresql在windows下备份的批处理文件(修改版),提示输入密码时,能自动输入密码
- Linux System and Performance Monitoring
- .NET4.0并行计算技术基础(9)
- Roads
- Java 和 C++ 的区别