#include<windows.h>
#include "stdafx.h"
#include <stdio.h>
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow){
MSG Msg;
MyRegisterClass(hInstance); if(!InitInstance(hInstance,nCmdShow))
{
return FALSE;
}
while (GetMessage(&Msg,NULL,0,0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg); } return Msg.wParam;
}ATOM MyReisterClass(HINSTANCE hInstance)
{
WNDCLASS wcex;
wcex.cbSize=sizeof(WNDCLASS);
wcex.style=CS_HREDRAW|CS_VREDRAW;
wcex.lpfnWndProc=(WNDPROC)WndProc;
wcex.cbClsExtra=0;
wcex.cbWndExtra=0;
wcex.hInstance=hInstance;
wcex.hIcon=NULL;
wcex.hCursor=NULL;
wcex.hCursor=LoadCursor(NULL,IDC_ARROW);
wcex.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName=NULL;
wcex.lpszClassName="canvas";
wcex.hIconSm=NULL;
return RegisterClassEx(&wcex);
}BOOL InitInstance(HINSTANCE hInstance,int nCmdshow)
{
HWND hWnd;
hInst=hInstance;
hWnd=CreateWindow("canvas","绘图窗口",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,0,
CW_USEDEFAULT,0,NULL,NULL,hInstance,NULL);
if(!hWnd)
{
return FALSE;
}
MoveWindow(hWnd,10,10,600,450,true);
ShowWindow(hWnd,nCmdshow);
UpdateWindow(hWnd); return TRUE;
}444.cpp
1>d:\我的文档\visual studio 2008\projects\444\444\444.cpp(38) : error C2039: “cbSize”: 不是“tagWNDCLASSA”的成员
1> c:\program files\microsoft sdks\windows\v6.0a\include\winuser.h(1566) : 参见“tagWNDCLASSA”的声明
1>d:\我的文档\visual studio 2008\projects\444\444\444.cpp(50) : error C2039: “hIconSm”: 不是“tagWNDCLASSA”的成员
1> c:\program files\microsoft sdks\windows\v6.0a\include\winuser.h(1566) : 参见“tagWNDCLASSA”的声明
1>d:\我的文档\visual studio 2008\projects\444\444\444.cpp(51) : error C2664: “RegisterClassExA”: 不能将参数 1 从“WNDCLASS *”转换为“const WNDCLASSEXA *”
1> 与指向的类型无关;转换要求 reinterpret_cast、C 样式转换或函数样式转换
1>d:\我的文档\visual studio 2008\projects\444\444\444.cpp(59) : error C2065: “hInst”: 未声明的标识符
#include "stdafx.h"
#include <stdio.h>
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow){
MSG Msg;
MyRegisterClass(hInstance); if(!InitInstance(hInstance,nCmdShow))
{
return FALSE;
}
while (GetMessage(&Msg,NULL,0,0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg); } return Msg.wParam;
}ATOM MyReisterClass(HINSTANCE hInstance)
{
WNDCLASS wcex;
wcex.cbSize=sizeof(WNDCLASS);
wcex.style=CS_HREDRAW|CS_VREDRAW;
wcex.lpfnWndProc=(WNDPROC)WndProc;
wcex.cbClsExtra=0;
wcex.cbWndExtra=0;
wcex.hInstance=hInstance;
wcex.hIcon=NULL;
wcex.hCursor=NULL;
wcex.hCursor=LoadCursor(NULL,IDC_ARROW);
wcex.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName=NULL;
wcex.lpszClassName="canvas";
wcex.hIconSm=NULL;
return RegisterClassEx(&wcex);
}BOOL InitInstance(HINSTANCE hInstance,int nCmdshow)
{
HWND hWnd;
hInst=hInstance;
hWnd=CreateWindow("canvas","绘图窗口",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,0,
CW_USEDEFAULT,0,NULL,NULL,hInstance,NULL);
if(!hWnd)
{
return FALSE;
}
MoveWindow(hWnd,10,10,600,450,true);
ShowWindow(hWnd,nCmdshow);
UpdateWindow(hWnd); return TRUE;
}444.cpp
1>d:\我的文档\visual studio 2008\projects\444\444\444.cpp(38) : error C2039: “cbSize”: 不是“tagWNDCLASSA”的成员
1> c:\program files\microsoft sdks\windows\v6.0a\include\winuser.h(1566) : 参见“tagWNDCLASSA”的声明
1>d:\我的文档\visual studio 2008\projects\444\444\444.cpp(50) : error C2039: “hIconSm”: 不是“tagWNDCLASSA”的成员
1> c:\program files\microsoft sdks\windows\v6.0a\include\winuser.h(1566) : 参见“tagWNDCLASSA”的声明
1>d:\我的文档\visual studio 2008\projects\444\444\444.cpp(51) : error C2664: “RegisterClassExA”: 不能将参数 1 从“WNDCLASS *”转换为“const WNDCLASSEXA *”
1> 与指向的类型无关;转换要求 reinterpret_cast、C 样式转换或函数样式转换
1>d:\我的文档\visual studio 2008\projects\444\444\444.cpp(59) : error C2065: “hInst”: 未声明的标识符
解决方案 »
- 由向导生成的MDI程序,VC6没有滚动条,VC2010却有,怎么给去掉?
- 有关红外目标成像的模拟,请问使用OPenGL好呢?还是用DirectX好?请相关熟悉的人解答一下,不胜感激!~
- 如何在Combo box控件上显示文字
- C#调用ATL com控件被阻死,是什么原因?
- <<MFC windows程序设计>>还是先学<<vc++技术内幕>>
- 如何刷新你的子窗口?
- 如何在视图中加入控件?
- 能提供文件传送程序吗?
- vb调用vc写的动态链接库的问题,搞不清是VB调用有错,还是VC写的时候有问题,请帮忙
- GetKeyboardState 真的是检测物理中断吗我发现不准啊
- 我有了tlb类型库,如何用VC开发COM呢
- 如何查看连接FTP后的一些信息
应该是WNDCLASSEX,而不是WNDCLASS。
cbSize是WNDCLASSEX的成员变量,而WNDCLASS是不包含cbSize的。
但是还有
:\我的文档\visual studio 2008\projects\444\444\444.cpp(59) : error C2065: “hInst”: 未声明的标识符
这个问题
========
模仿是最好的老师,但是你也要型明白啊,上面这段代码应该是SDK中最简单的了
可以使用VC自动生成WIN32程序,估计就是你抄的这段。对照一下就知道了