📄 subject_61448.htm
字号:
<p>
序号:61448 发表者:jdljh 发表日期:2003-11-19 20:21:35
<br>主题:这个程序为什么出这样的错误?
<br>内容:菜鸟请教各位大侠????????<BR>#include <windows.h><BR>LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);<BR>int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR IpszCmdLine,int nCmdShow)<BR>{<BR> HWND hwnd;<BR> MSG Msg;<BR> WNDCLASS wndclass;<BR> char lpszClassName[]="窗口";<BR> char lpszTitle[]="my_windows";<BR> wndclass.style=0;<BR> wndclass.lpfnWndProc=WndProc;<BR> wndclass.cbClsExtra=0;<BR> wndclass.hInstance=hInstance;<BR> wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);<BR> wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);<BR> wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);<BR> wndclass.lpszMenuName=NULL;<BR> wndclass.lpszClassName=lpszClassName;<BR> if(!RegisterClass(&wndclass))<BR> {<BR> MessageBeep(0);<BR> return FALSE;<BR> }<BR> hwnd=CreateWindow(lpszClassName,<BR> lpszTitle,<BR> WS_OVERLAPPEDWINDOW,<BR> CW_USEDEFAULT,<BR> CW_USEDEFAULT,<BR> CW_USEDEFAULT,<BR> CW_USEDEFAULT,<BR> NULL,<BR> NULL,<BR> hInstance,<BR> NULL);<BR> ShowWindow(hwnd,nCmdShow);<BR> UpdateWindow(hwnd);<BR> while(GetMessage(&Msg,NULL,0,0))<BR> {<BR> TranslateMessage(&Msg);<BR> DispatchMessage(&Msg);<BR> }<BR> return Msg.wParam;<BR>}<BR>LRESULT CALLBACK WndProc(HWND hwnd,<BR> UINT message,<BR> WPARAM wParam,<BR> LPARAM lParam)<BR>{<BR> switch(message)<BR> {<BR> case WM_DESTROY: PostQuitMessage(0);<BR> default: return DefWindowProc(hwnd,message,wParam,lParam);<BR> }<BR> return(0);<BR>}<BR>这是书上的例子<BR>我写成c++源程序出错信息如下:<BR>Compiling...<BR>windows.cpp<BR>Linking...<BR>LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main<BR>Debug/windows.exe : fatal error LNK1120: 1 unresolved externals<BR>Error executing link.exe.<BR><BR>windows.exe - 2 error(s), 0 warning(s)<BR>
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:浪际天涯 回复日期:2003-11-19 20:36:42
<br>内容:建工程的时候建成win32 application
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:jdljh 回复日期:2003-11-19 21:59:18
<br>内容:谢谢楼上的<BR>现在可以运行了但是没有结果<BR>不能出来一个简单的窗口<BR>为什么啊????????<BR>请指教<BR>谢谢
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:小虾壳LG 回复日期:2003-11-19 22:45:08
<br>内容:win32 Console application
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:浪际天涯 回复日期:2003-11-19 23:02:34
<br>内容:我这儿没VC,明天帮你看看
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:红苹果 回复日期:2003-11-20 01:00:10
<br>内容: WNDCLASS wndclass;<BR> char lpszClassName[]="窗口";<BR> char lpszTitle[]="my_windows";<BR> wndclass.style=0;<BR> wndclass.lpfnWndProc=WndProc;<BR>//添加如下语句:<BR> wndclass.cbWndExtra=0; // 必须初始化,否则RegisterClass要失败
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:浪际天涯 回复日期:2003-11-20 10:17:43
<br>内容:设定窗口类属性的时候少了一项,要记住是10项,少了wndclass.cbWndExtra=0;<BR>#include <windows.h><BR>LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);<BR>int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR IpszCmdLine,int nCmdShow)<BR>{<BR> HWND hwnd;<BR> MSG Msg;<BR> WNDCLASS wndclass;<BR> char lpszClassName[]="窗口";<BR> char lpszTitle[]="my_windows";<BR> wndclass.style=0;<BR> wndclass.lpfnWndProc=WndProc;<BR> wndclass.cbClsExtra=0;<BR> wndclass.hInstance=hInstance;<BR> wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);<BR> wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);<BR> wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);<BR> wndclass.lpszMenuName=NULL;<BR> wndclass.lpszClassName=lpszClassName;<BR> wndclass.cbWndExtra=0;<BR> if(!RegisterClass(&wndclass))<BR> {<BR> MessageBeep(0);<BR> return FALSE;<BR> }<BR> hwnd=CreateWindow(lpszClassName,<BR> lpszTitle,<BR> WS_OVERLAPPEDWINDOW,<BR> CW_USEDEFAULT,<BR> CW_USEDEFAULT,<BR> CW_USEDEFAULT,<BR> CW_USEDEFAULT,<BR> NULL,<BR> NULL,<BR> hInstance,<BR> NULL);<BR> ShowWindow(hwnd,nCmdShow);<BR> UpdateWindow(hwnd);<BR> while(GetMessage(&Msg,NULL,0,0))<BR> {<BR> TranslateMessage(&Msg);<BR> DispatchMessage(&Msg);<BR> }<BR> return Msg.wParam;<BR>}<BR>LRESULT CALLBACK WndProc(HWND hwnd,<BR> UINT message,<BR> WPARAM wParam,<BR> LPARAM lParam)<BR>{<BR> switch(message)<BR> {<BR> case WM_DESTROY:<BR> {<BR> PostQuitMessage(0);<BR> break;<BR> }<BR> default:<BR> return DefWindowProc(hwnd,message,wParam,lParam);<BR> }<BR> return(0);<BR>}
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -