| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 541 人关注过本帖
标题:初学者的问题
只看楼主 加入收藏
refeiner
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-12-28
收藏
 问题点数:0 回复次数:4 
初学者的问题

最基本的程序
编译没有问题.但是就是不能显示窗口
连接出错,错误如下,各位大虾帮帮忙吧!
--------------------Configuration: WinMain - Win32 Debug--------------------
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/WinMain.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

WinMain.exe - 2 error(s), 0 warning(s)

搜索更多相关主题的帖子: warning 
2006-04-12 22:16
名人
Rank: 1
等 级:新手上路
威 望:1
帖 子:205
专家分:0
注 册:2006-3-3
收藏
得分:0 
没有main函数吧?没有代码这种错误很难分析的。

未必钱多乐便多,财多累己招烦恼。 清贫乐道真自在,无牵无挂乐逍遥。
2006-04-13 11:19
refeiner
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-12-28
收藏
得分:0 
有..编译一直没问题

这里是代码!
#include<windows.h>
#include<stdio.h>
LRESULT CALLBACK WindowProc(HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);


int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
)
{
WNDCLASS winclass;
winclass.cbClsExtra=0;
winclass.cbWndExtra=0;
winclass.hbrBackground =(HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.hCursor =LoadCursor(NULL,IDC_CROSS);
winclass.hIcon =LoadIcon(NULL,IDI_ERROR);
winclass.hInstance =hInstance;
winclass.lpfnWndProc =WindowProc;
winclass.lpszClassName ="wangjunren";
winclass.lpszMenuName =NULL;
winclass.style=CS_HREDRAW|CS_VREDRAW;
RegisterClass(&winclass);
HWND hwnd;
hwnd=CreateWindow("wangjunren","i am a wolf",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 0;

}


LRESULT CALLBACK WindowProc( HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
case WM_PAINT:
HDC hDC;
PAINTSTRUCT ps;
hDC=BeginPaint(hwnd,&ps);
TextOut(hDC,50,50,"haha",strlen("haha"));

EndPaint(hwnd,&ps);


break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"是否确定退出","box",MB_YESNO))
DestroyWindow(hwnd);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"you put the lbotton down","box",0);
HDC hdc;
hdc=GetDC(hwnd);
TextOut(hdc,0,50,"this is the test of mouse",strlen("this is the test of mouse"));
ReleaseDC(hwnd,hdc);

break;
case WM_CHAR:
char szChar[20];
sprintf(szChar,"this is%d",wParam);
MessageBox(hwnd,szChar,"box",0);

break;
case WM_DESTROY:
PostQuitMessage(0);
break;

default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}

2006-04-13 14:57
bfgghy
Rank: 1
等 级:新手上路
帖 子:75
专家分:0
注 册:2006-3-25
收藏
得分:0 
我调试过了,没有问题,你确保以下步骤:
1.用AppWizard向导创建Win32 Application(你可能用了Win32 Console Application )
2.选择空项目
3.新建一个cpp文件,添加到当前项目
4.将代码复制到cpp文件
5.编译、创建应用程序
2006-04-13 23:02
refeiner
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-12-28
收藏
得分:0 

用你的方法我试过了,成功!非常感谢~
这几天查资料用那个console程序的时候得用/MT来指出C RUNTIME的类型,但是我不知道在哪里设定~

2006-04-15 18:29
快速回复:初学者的问题
数据加载中...
 
   



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

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