| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1008 人关注过本帖
标题:不明的编译错误?
取消只看楼主 加入收藏
唐龙
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2004-11-27
收藏
 问题点数:0 回复次数:1 
不明的编译错误?

#include<windows.h>

LRESULT CALLBACK WindowProc( 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, // pointer to command line int nCmdShow // show state of window ) { char lpszClassName[]="lll"; char lpszTitle[]="lllll"; HWND hwnd; MSG msg; WNDCLASS wndclass;

wndclass.cbClsExtra=0; wndclass.cbWndExtra=0; wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH); wndclass.hCursor=LoadCursor(NULL,IDC_ARROW); wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION); wndclass.hInstance=hInstance; wndclass.lpfnWndProc=WindowProc; wndclass.lpszClassName=lpszClassName; wndclass.lpszMenuName=NULL; wndclass.style=CS_HREDRAW | CS_VREDRAW;

if(!RegisterClass(&wndclass)) { MessageBeep(0); return FALSE; } hwnd=CreateWindow(lpszClassName, lpszTitle, WS_OVERLAPPEDWINDOW, 50,50, 700,500, NULL, NULL, hInstance, NULL); ShowWindow(hwnd,nCmdShow); UpdateWindow(hwnd); while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } LRESULT CALLBACK WindowProc( HWND hwnd, // handle to window UINT uMsg, // message identifier WPARAM wParam, // first message parameter LPARAM lParam // second message parameter ) { switch(uMsg) { case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd,uMsg,wParam,lParam); } return 0; } //////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////

--------------------Configuration: llll - Win32 Debug-------------------- Compiling... ddd.cpp Linking... LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Debug/llll.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe.

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

上面为什么会出现这两个错误呢?

加上以下的"按钮"代码后编译虽然没有了错误,但是只有框架,却没有按钮,这是不是又是初学者的错误啊!

#include <windows.h> #define IDB_PUSHBUTTON 10 HWND hwndPush; HINSTANCE hInst; char lpszClassName1[]="liitlepig"; LRESULT CALLBACK WindowProc( 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, // pointer to command line int nCmdShow // show state of window ) { char lpszClassName[]="lll"; char lpszTitle[]="lllll"; HWND hwnd; MSG msg; WNDCLASS wndclass;

wndclass.cbClsExtra=0; wndclass.cbWndExtra=0; wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH); wndclass.hCursor=LoadCursor(NULL,IDC_ARROW); wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION); wndclass.hInstance=hInstance; wndclass.lpfnWndProc=WindowProc; wndclass.lpszClassName=lpszClassName; wndclass.lpszMenuName=NULL; wndclass.style=CS_HREDRAW | CS_VREDRAW;

if(!RegisterClass(&wndclass)) { MessageBeep(0); return FALSE; } hwnd=CreateWindow(lpszClassName, lpszTitle, WS_OVERLAPPEDWINDOW, 50,50, 700,500, NULL, NULL, hInstance, NULL); ShowWindow(hwnd,nCmdShow); UpdateWindow(hwnd); while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } LRESULT CALLBACK WindowProc( HWND hwnd, // handle to window UINT uMsg, // message identifier WPARAM wParam, // first message parameter LPARAM lParam // second message parameter ) { switch(uMsg) { case WM_CREATE: hwndPush=CreateWindow(lpszClassName1, "litt", BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE, 50,50, 120,25, hwnd, (HMENU)IDB_PUSHBUTTON, hInst, NULL); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd,uMsg,wParam,lParam); } return 0; }

搜索更多相关主题的帖子: windows handle message instance 编译 
2004-12-17 20:03
唐龙
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2004-11-27
收藏
得分:0 
lib库是怎么加的啊
2004-12-24 20:00
快速回复:不明的编译错误?
数据加载中...
 
   



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

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