| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 444 人关注过本帖
标题:不知道哪里错了,一个简单的程序
只看楼主 加入收藏
zh286091487
Rank: 1
等 级:新手上路
帖 子:36
专家分:0
注 册:2007-3-22
收藏
 问题点数:0 回复次数:3 
不知道哪里错了,一个简单的程序

#include<windows.h>


LRESULT CALLBACK WindowProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);

int WINAPI WINMIAN
(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
)
{
WNDCLASS wndclass;
wndclass.cbClsExtra =0;
wndclass.cbWndExtra =0;
wndclass.hbrBackground =(HBRUSH)GetStockObject(GRAY_BRUSH);
wndclass.hCursor =LoadCursor(NULL,IDC_CROSS);
wndclass.hIcon =LoadIcon(NULL,IDI_WINLOGO);
wndclass.hInstance=hInstance;
wndclass.lpfnWndProc =WindowProc;
wndclass.lpszClassName ="firstwindow";
wndclass.lpszMenuName =NULL;
wndclass.style =CS_HREDRAW|CS_VREDRAW|CS_NOCLOSE;

RegisterClass(&wndclass);

HWND hwnd;
hwnd=CreateWindow("firstwindow","an easy window",WS_OVERLAPPED,CW_USEDEFAULT ,
CW_USEDEFAULT ,CW_USEDEFAULT ,CW_USEDEFAULT ,NULL,NULL,hInstance,NULL);

ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);

MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WindowProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
case WM_CHAR:
break;
case WM_LBUTTONDOWN:
break;
case WM_PAINT:
break;
case WM_CLOSE:
/*if(MessageBox(hwnd,"是否要关闭窗口?","提示",0)==IDYES)
{
DestroyWindow(hwnd);
}*/
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;

}




Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/窗口代码.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

窗口代码.exe - 2 error(s), 0 warning(s)

搜索更多相关主题的帖子: include 
2007-04-23 18:31
jamin513
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2007-4-16
收藏
得分:0 
以下是引用zh286091487在2007-4-23 18:31:34的发言:

#include<windows.h>


LRESULT CALLBACK WindowProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);

int WINAPI WINMIAN //WinMain WinMain名字写错了
(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
)
{
WNDCLASS wndclass;
wndclass.cbClsExtra =0;
wndclass.cbWndExtra =0;
wndclass.hbrBackground =(HBRUSH)GetStockObject(GRAY_BRUSH);
wndclass.hCursor =LoadCursor(NULL,IDC_CROSS);
wndclass.hIcon =LoadIcon(NULL,IDI_WINLOGO);
wndclass.hInstance=hInstance;
wndclass.lpfnWndProc =WindowProc;
wndclass.lpszClassName ="firstwindow";
wndclass.lpszMenuName =NULL;
wndclass.style =CS_HREDRAW|CS_VREDRAW|CS_NOCLOSE;

RegisterClass(&wndclass);

HWND hwnd;
hwnd=CreateWindow("firstwindow","an easy window",WS_OVERLAPPED,CW_USEDEFAULT ,
CW_USEDEFAULT ,CW_USEDEFAULT ,CW_USEDEFAULT ,NULL,NULL,hInstance,NULL);

ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);

MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WindowProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
case WM_CHAR:
break;
case WM_LBUTTONDOWN:
break;
case WM_PAINT:
break;
case WM_CLOSE:
/*if(MessageBox(hwnd,"是否要关闭窗口?","提示",0)==IDYES)
{
DestroyWindow(hwnd);
}*/
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;

}




Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/窗口代码.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

窗口代码.exe - 2 error(s), 0 warning(s)

2007-04-26 15:50
alading514
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2007-4-23
收藏
得分:0 
这也叫小程序啊 我都不想看了
2007-04-26 17:04
jamin513
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2007-4-16
收藏
得分:0 
是你没接触过而已,这是最简单的WINDOWS API 程序!!
2007-04-26 17:16
快速回复:不知道哪里错了,一个简单的程序
数据加载中...
 
   



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

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