从您贴出来的代码来看,其实没有严重错误,只是有着几处地方拼写错误,下面是调试运行通过的代码,除了把WndProc的实现放到了Winmain函数之外,其他的改动都已经用注释符号标出,希望您看了以后有帮助。#include <windows.h>LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)//error
{
static char szAppName[]="winhello";
HWND hwnd;
MSG msg;
WNDCLASSEX wndclass;
wndclass.cbSize=sizeof(wndclass);
wndclass.style=CS_HREDRAW|CS_VREDRAW;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH) GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=szAppName;
wndclass.hIconSm=LoadIcon(NULL,IDI_APPLICATION);
RegisterClassEx(&wndclass);
hwnd=CreateWindow(szAppName,"winhello program",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,500,300,
NULL,NULL,hInstance,NULL);//error
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM lParam)//error c2601:WndProc:local function definitions //are illegal
{
HDC hdc;
//PAINSTRUCT ps;
PAINTSTRUCT ps;
RECT rect;
//swith(iMsg)
switch(iMsg)
{
//case WN_PAINT:
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
//GetClientRect(hwnd,rect);
GetClientRect(hwnd,&rect);
DrawText(hdc,"helloworld from window",-1,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);
//EndPaint(hwnd,ps);
EndPaint(hwnd,&ps);
return 0;
//case WM_DESTORY:
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd,iMsg,wParam,lParam);
}
- 微软全球技术中心 VC技术支持本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款
(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。为了为您创建更好的讨论环境,请参加我们的用户满意度调查
(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。
{
static char szAppName[]="winhello";
HWND hwnd;
MSG msg;
WNDCLASSEX wndclass;
wndclass.cbSize=sizeof(wndclass);
wndclass.style=CS_HREDRAW|CS_VREDRAW;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH) GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=szAppName;
wndclass.hIconSm=LoadIcon(NULL,IDI_APPLICATION);
RegisterClassEx(&wndclass);
hwnd=CreateWindow(szAppName,"winhello program",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,500,300,
NULL,NULL,hInstance,NULL);//error
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM lParam)//error c2601:WndProc:local function definitions //are illegal
{
HDC hdc;
//PAINSTRUCT ps;
PAINTSTRUCT ps;
RECT rect;
//swith(iMsg)
switch(iMsg)
{
//case WN_PAINT:
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
//GetClientRect(hwnd,rect);
GetClientRect(hwnd,&rect);
DrawText(hdc,"helloworld from window",-1,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);
//EndPaint(hwnd,ps);
EndPaint(hwnd,&ps);
return 0;
//case WM_DESTORY:
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd,iMsg,wParam,lParam);
}
- 微软全球技术中心 VC技术支持本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款
(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。为了为您创建更好的讨论环境,请参加我们的用户满意度调查
(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。
解决方案 »
- 点击clistctrl,如何得到当前行内容?下面的方式会产生问题吗?
- 怎么判别输入字符串是英文
- CSpinButtonCtrl 控件一问,
- com的接口函数怎么返回一个bool值(快没分只能给50了)
- 做过图像拼接的高手请进
- 哪位朋友给我寄一个UUIDGEN.exe?
- 急用!!!!万分感谢!!vc5.0下对于CProgressCtrl类型控键,怎么没有SetPos()和GetRange(&pos, &size);函数吗?
- How to debug shell
- 送分大行动!--visual c++的文档输入处理
- 哪可以down objectarx
- 介绍一个<<中国图形编程语言>>
- VC++对话框的问题!急死俺了,求高手们帮忙!!在线等待too........
2.Debug/Text1.exe : fatal error LNK1120: 1 unresolved externals