GIS之家

愿大家在GIS的海洋里自由遨游

导航

Application.Run()和Form.Show()的区别

Posted on 2007-08-09 10:52  雨衣blog  阅读(5400)  评论(1编辑  收藏  举报
Application.Run()是"Begins running a standard application message loop on the current thread, and makes the specified form visible." 用代码可以表示为:
while(GetMessage(&msg)>0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
执导受到WM_QUIT,退出应用程序。而使用Form.Show()方法则Form显示后就立刻退出程序。如果用Form.ShowDialog()是模化对话框所以不会立刻消失,但是如果您还有其他窗口,Form.ShowDialog()显示的是模态窗口,只有它退出,其他窗口才能显示,但是一旦退出整个程序就推出,其他窗口将永不会得到运行机会,而用Application.Run()就不会出现这种现象。