界面开发套包ToolKit Pro教程:如何生成带有启动动画的对话框

Xtreme Toolkit Pro是MFC开发中最全面界面控件套包,它提供了Windows开发所需要的11种主流的Visual C++ MFC控件,包括Command Bars、Controls、Chart Pro、Calendar、Docking Pane、Property Grid、Report Control、Shortcut Bar、Syntax Edit、Skin Framework 和Task Panel。如果对产品感兴趣的话欢迎下载Xtreme Toolkit Pro最新试用版! 点击获取更多免费Xtreme Toolkit Pro教程、视频、示例!

【同类产品推荐】

  • BCGControlBar for .NET | 下载试用 :包含有大量高度自定义、完全可设计的.NET界面控件,用户可以使用这些来创建精致美观的图形用户界面。

带有启动画面的对话框

开机画面

为了在基于对话框的应用程序中使用CSplashWnd,我们将必须重写三个函数CDialog :: OnInitDialog(),CWinApp :: InitInstance()和CWinApp :: PreTranslateMessage(MSG * pMsg)。如果使用AppWizard,则在创建项目时应该已经将OnInitDialog和InitInstance添加到了项目中,但是可能必须将PreTranslateMessage添加到CWinApp派生类中。

步骤1:
在失去作用域之前,将以下代码行添加到CDialog :: OnInitDialog()方法中。ShowSplashScreen的第一个参数是超时值(以毫秒为单位)。这是启动屏幕将在关闭前显示多长时间。第二个参数是我们将用作初始屏幕的位图图像的资源标识符。最后一个参数是父窗口。此参数可以为NULL。

// Create and show the splash screen.CSplashWnd::ShowSplashScreen(3000, IDB_SPLASH24, this);return TRUE;  // return TRUE  unless you set the focus to              // a control}

步骤2:
在调用ParseCommandLine(…)之后,将以下代码行添加到CWinApp :: InitInstance()的开头。如果尚未包含ParseCommandLine,则需要添加它。

BOOL CDialogsplApp::InitInstance(){    // Enable the splash screen component based on the command    // line info.    CCommandLineInfo cmdInfo;    ParseCommandLine(cmdInfo);    CSplashWnd::EnableSplashScreen(cmdInfo.m_bShowSplash);

步骤3:
使用类向导覆盖CWinApp :: PreTranslateMessage(MSG * pMsg),并添加以下代码行:

BOOL CDialogsplApp::PreTranslateMessage(MSG* pMsg){    // Route messages to the splash screen while it is visible    if (CSplashWnd::PreTranslateAppMessage(pMsg)) {        return TRUE;    }    return CWinApp::PreTranslateMessage(pMsg);}

今天的内容就是这些了,下载最新版Xtreme ToolKit Pro并在下方评论区分享您对该产品的想法。您的反馈意见可帮助我们在以后的更新中找到正确的方向,作为Codejock的正版代理商现Xtreme ToolKit Pro正版授权最高立减2000元! Xtreme Command Bars在线订购最低仅需1105元!

标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2020年8月26日
下一篇 2020年8月26日

相关推荐

发表回复

登录后才能评论