怎样显示LOGO?

zxhseu 2005-09-05 02:02:32
为了在软件打开时先出现一个LOGO,过几秒种后,再弹出对话框
我开了个线程,请问Sleep后,怎样回到主对话框?
我有一个用单文档做的例子
在Dialog 的App怎样实现呢?
代码如下:
BOOL CChatCntApp::InitInstance()
{
#ifdef _AFXDLL
Enable3dControls();
#else
Enable3dControlsStatic();
#endif

LoadStdProfileSettings();


//ADDITION OF SPLASH SCREEN COMPONENT
//Bring up the splash screen in a secondary UI thread
CSplashThread* pSplashThread = (CSplashThread*) AfxBeginThread(RUNTIME_CLASS(CSplashThread), THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
if (pSplashThread == NULL)
{
AfxMessageBox(_T("Failed to create splash screen"), MB_OK | MB_ICONSTOP);
return FALSE;
}
ASSERT(pSplashThread->IsKindOf(RUNTIME_CLASS(CSplashThread)));

//Tell the splash screen to load the bitmap from a resource called IDB_SPLASH.
//Alternatively, you could use the line:
// pSplashThread->SetBitmapToUse(GetHomeDirectory() + _T("TEST.BMP"));
//if you wanted the splasher code to load a bitmap from file at runtime.
pSplashThread->SetBitmapToUse(IDB_SPLASH);

pSplashThread->ResumeThread(); //Resume the thread now that we have set it up

Sleep(3000); //Simulate some slow loading process. Your code might
//load up some info from a file or make a network connection etc.

pSplashThread->HideSplash(); //Bring down the splash screen

CDialog* pDlg;
pDlg = new CDialog(
IDR_MAINFRAME,
RUNTIME_CLASS(CChatCntDlg),
RUNTIME_CLASS(CntSocket),
RUNTIME_CLASS(CCEnBitmap),
RUNTIME_CALSS(CPlaySoundThread),
RUNTIME_CALSS(CRecordSoundThread),
RUNTIME_CALSS(CTransparentStatic));
AddDialog(pDlg);

CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);

if (!ProcessShellCommand(cmdInfo))
return FALSE;

//ADDITION OF SPLASH SCREEN COMPONENT
//This is required to activate the normal mainframe, If you remove the splash
//screen, then the main frame window is brought up but will not
//be at the top of the Z Order.
m_pMainWnd->SetForegroundWindow();


return TRUE;
}

CString CChatCntApp::GetHomeDirectory()
{
TCHAR sFilename[_MAX_PATH];
TCHAR sDrive[_MAX_DRIVE];
TCHAR sDir[_MAX_DIR];
TCHAR sFname[_MAX_FNAME];
TCHAR sExt[_MAX_EXT];
GetModuleFileName(AfxGetInstanceHandle(), sFilename, _MAX_PATH);
_tsplitpath(sFilename, sDrive, sDir, sFname, sExt);

CString rVal(CString(sDrive) + CString(sDir));
int nLen = rVal.GetLength();
if (rVal.GetAt(nLen-1) != _T('\\'))
rVal += _T("\\");

return rVal;
}

上面RUNTIME_CLASS的地方是错的.请问在对话框中怎么实现?
...全文
186 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
dirdirdir3 2005-09-06
  • 打赏
  • 举报
回复
要显示logo可以在主对话框前显示一个logo对话框。其中有个SetTimer,时间到了就OnOK()就可以了。
zxhseu 2005-09-06
  • 打赏
  • 举报
回复
但这样开始时并不能隐藏对话框
如果要隐藏,是不是自己要另外开一个线程?
zxhseu 2005-09-06
  • 打赏
  • 举报
回复
谢谢楼上的
saliors 2005-09-05
  • 打赏
  • 举报
回复
利用 Visual C++ 的组件库中的 Splash Screen 组件可以很方便的在应用程序中实现
Splash Screen。但是由于这个组件缺省时使用 16 色位图,因此很多人误认为这个组件仅支
持 16 色位图。其实,这个组件是可以支持真彩色位图的。
1.制作封面位图

  制作应用程序启动封面真彩位图

2.在资源中插入位图资源

  打开 VC++ 的资源编辑器,用鼠标右键单击 Resources 文件夹,选择 Import 命令,插
入你所制作的真彩位图。这时 VC++ 会弹出一个对话框,显示下列信息:
  “The bitmap has been imported correctly, however because it contains
more than 256 colors it cannot be loaded in the bitmap editor”。
  不用担心,你的真彩位图已经被成功地插入资源里了。将其 ID 改为 IDB_SPLASH。

3.插入 Splash Screen 组件

  从 Project 菜单选择 Add To Project->Components and Controls... 命令,
选择 Developer studio components 中的 Splash screen 组件,将对话框中的位图资源
ID 改为你的真彩位图的 ID。然后删除 VC++ 自动加入到资源中的缺省 16 色启动封面位图
(可选)。编译、连接,漂亮的真彩启动封面就显示出来了。

4.增强功能

 *基于对话框的应用程序

  基于对话框的应用程序不能插入 Splash Screen 组件。利用下面的方法可以实现基于对
话框的应用程序启动画面:重复上面的第 1,2 步骤,将已经生成的 Splash.cpp 和
Splash.h 文件(可以使用其他项目的文件)拷贝到工作文件夹,并将其加入到你的基于对话
框的项目中(使用 Project 菜单下的 Add To Project->Files...命令)。
  在 CWinApp 派生类的 InitInstance() 中加入下列代码:

#include "Splash.h"

BOOL CDialogsplApp::InitInstance()
{
// CG: The following block was added by the Splash Screen component.
{
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);

CSplashWnd::EnableSplashScreen(cmdInfo.m_bShowSplash);
}
......
}

  使用 Class Wizard 为在 CDialog 派生类添加 OnCreate() 函数,并加入下列代码:

#include "Splash.h"

int CDialogsplDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;

// CG: The following line was added by the Splash Screen component.
CSplashWnd::ShowSplashScreen(this);

return 0;
}

  最后将 Splash.cpp 文件中的 CSplashWnd::Create() 函数中的位图资源 ID 改为真彩
位图的 ID 就可以了。

BOOL CSplashWnd::Create(CWnd* pParentWnd /*= NULL*/)
{
if (!m_bitmap.LoadBitmap(IDB_BITMAP1))
return FALSE;
......
}

15,980

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧