VS2008创建启动画面

我勒个去,网上大部分代码都是不靠谱的,都是扯淡,也不怕失控卫星砸到你!

先是在CSDN的某人的博客上看到CSplashWnd的源代码,你说你写就写吧,又不写完整,最后就说了一下为什么那么做不行,也不弄个解决方案出来,鄙视!本想先用VC++6.0创建一个CSplashWnd,然后看看源代码及调用该类的代码,不知道为什么,VC++6.0老了,找不到这个控件。本着刻苦专研,不到黄河心不死的精神,在论坛找到了如下代码。作者亲自试验,绝对可行,虽然效果很一般,凑合一下吧,谁让咱是初学者呢。

用//CSplashWindow.h class CSplashWindow : public CWnd { private: CDC MemDC; BITMAP bmBitmap; CBitmap m_Bitmap; CBitmap *Old_Bitmap; public: CSplashWindow(); ~CSplashWindow(); void CreateSplash(); afx_msg void OnPaint(); DECLARE_MESSAGE_MAP() }; // SplashWindow.cpp : CSplashWindow 类的实现 #include "stdafx.h" #include "resource.h" #include "SplashWindow.h" BEGIN_MESSAGE_MAP(CSplashWindow, CWnd) ON_WM_PAINT() END_MESSAGE_MAP() CSplashWindow::CSplashWindow() { m_Bitmap.LoadBitmap(MAKEINTRESOURCE(IDB_SPLASHWINDOW)); //Load Bitmap,这里修改成你的位图的ID m_Bitmap.GetBitmap(&bmBitmap); //Get Bitmap Info } CSplashWindow::~CSplashWindow() { } void CSplashWindow::CreateSplash() { //Create Splash Window CWnd::CreateEx(0, AfxRegisterWndClass( 0, AfxGetApp()->LoadStandardCursor(IDC_UPARROW)), NULL, // "SplashWindow Sample", WS_POPUP, 0, 0, bmBitmap.bmWidth, //Bitmap Width = Splash Window Width bmBitmap.bmHeight, //Bitmap Height = Splash Window Height NULL, NULL, NULL); } void CSplashWindow::OnPaint() { CPaintDC dc(this); CBrush brush; brush.CreateSolidBrush(RGB(64,64,255)); dc.SelectObject(&brush); dc.Rectangle(0,0,bmBitmap.bmWidth,bmBitmap.bmHeight); MemDC.CreateCompatibleDC(NULL); //Create Memory DC Old_Bitmap = MemDC.SelectObject(&m_Bitmap); //Select DC int num = bmBitmap.bmWidth/40; dc.StretchBlt(0,0,bmBitmap.bmWidth,bmBitmap.bmHeight,&MemDC,0,0,bmBitmap.bmWidth,bmBitmap.bmHeight,SRCCOPY); /* for(int k=0; k<40; k++) //百叶窗效果 { for(int m=0; m<num+1; m++) { dc.BitBlt(m*40+k,0,1,bmBitmap.bmHeight,&MemDC,m*40+k,0,SRCCOPY); } Sleep(1); }*/ MemDC.SelectObject(Old_Bitmap); //Select Bitmap } 在你App类的InitInstance函数中 C/C++ codeBOOL CXxxxApp::InitInstance() { CWinApp::InitInstance(); CSplashWindow *pSplashWindow = new CSplashWindow; pSplashWindow->CreateSplash(); pSplashWindow->CenterWindow(); pSplashWindow->ShowWindow(SW_SHOW); pSplashWindow->UpdateWindow(); Sleep(3000); //Delay 3 Second pSplashWindow->DestroyWindow(); delete pSplashWindow; ... return true; }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值