📄 subject_16727.htm
字号:
<p>
序号:16727 发表者:Jonny 发表日期:2002-10-02 10:30:29
<br>主题:请教一个不能再‘菜’的问题
<br>内容:以下源码是个最起码的WIN32程序,为何主窗口不显示?在任务管理器中,“应用程序栏”中没有,而“进程”中却有?<BR>#include <windows.h><BR><BR>HWND hwnd;<BR>HINSTANCE pInstance;<BR><BR>LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);<BR><BR><BR>int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,<BR> PSTR szCmdLine,int iCmdShow){<BR> static char szClassName[]="MainClass";//class name<BR> MSG msg;<BR><BR> //defining a struct of type WNDCLASSEX<BR><BR> WNDCLASSEX wndclass;<BR><BR> wndclass.cbSize=sizeof(WNDCLASSEX);<BR> wndclass.style=CS_HREDRAW|CS_VREDRAW;<BR> wndclass.lpfnWndProc=WndProc;<BR> wndclass.cbClsExtra=0;<BR> wndclass.cbWndExtra=0;<BR><BR> wndclass.hInstance=hInstance;<BR> wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);<BR> wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);<BR><BR> wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);<BR> wndclass.lpszMenuName=NULL; //No Menu<BR><BR> wndclass.lpszClassName=szClassName;<BR><BR> wndclass.hIconSm=LoadIcon(NULL,IDI_APPLICATION);<BR><BR> if(!RegisterClassEx(&wndclass))<BR> return 0;<BR><BR> hwnd=CreateWindowEx(<BR> WS_EX_LEFT,<BR> szClassName,<BR> "Window Caption",<BR> WS_OVERLAPPEDWINDOW,<BR> CW_USEDEFAULT,<BR> CW_USEDEFAULT,<BR> CW_USEDEFAULT,<BR> CW_USEDEFAULT,<BR> NULL,<BR> NULL,<BR> hInstance,<BR> NULL);<BR><BR> ShowWindow(hwnd,iCmdShow);<BR><BR> UpdateWindow(hwnd);<BR><BR><BR> //Message loop<BR> while(GetMessage(&msg,NULL,0,0))<BR> {<BR> TranslateMessage(&msg);<BR> DispatchMessage(&msg);<BR> }<BR> return msg.wParam;<BR><BR>}<BR><BR>LRESULT CALLBACK WndProc(HWND hwnd,UINT iMsg,WPARAM wParam,<BR> LPARAM lParam){<BR> return 0;<BR><BR>}<BR>
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:lp 回复日期:2002-10-02 12:20:39
<br>内容:真正的VC程序员不用API编程,只用MFC!Just forget it!
<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>回复者:Norton AntivVirus 回复日期:2002-10-02 17:21:39
<br>内容:ShowWindow(hwnd,iCmdShow);<BR>iCmdShow是多少啊,直接用SW_SHOW不好吗?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:FullMoon 回复日期:2002-10-08 13:21:31
<br>内容:问题可能出在WndProc,至少应为return DefWindowProc(hWnd, message, wParam, lParam);
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:Jonny 回复日期:2002-10-09 20:45:52
<br>内容:CanMoon 回答的有道理,我后来将WndProc修改后,窗口出现。
<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 + -