SPLASH.CPP
资源名称:SNMP范例源代码.zip [点击查看]
上传用户:shgx688
上传日期:2009-12-27
资源大小:855k
文件大小:5k
源码类别:
SNMP编程
开发平台:
MultiPlatform
- // CG: This file was added by the Splash Screen component.
- // Splash.cpp : implementation file
- //
- #include "stdafx.h" // e. g. stdafx.h
- #include "resource.h" // e.g. resource.h
- #include "Splash.h" // e.g. splash.h
- #include "MemDC.h" // e.g.
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // Splash Screen class
- BOOL CSplashWnd::c_bShowSplashWnd;
- CSplashWnd* CSplashWnd::c_pSplashWnd;
- CSplashWnd::CSplashWnd()
- {
- }
- CSplashWnd::~CSplashWnd()
- {
- // Clear the static window pointer.
- ASSERT(c_pSplashWnd == this);
- c_pSplashWnd = NULL;
- }
- BEGIN_MESSAGE_MAP(CSplashWnd, CWnd)
- //{{AFX_MSG_MAP(CSplashWnd)
- ON_WM_CREATE()
- ON_WM_PAINT()
- ON_WM_TIMER()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- void CSplashWnd::EnableSplashScreen(BOOL bEnable /*= TRUE*/)
- {
- c_bShowSplashWnd = bEnable;
- }
- void CSplashWnd::ShowSplashScreen(CWnd* pParentWnd /*= NULL*/)
- {
- if (!c_bShowSplashWnd || c_pSplashWnd != NULL)
- {
- c_pSplashWnd->DestroyWindow();
- }
- // Allocate a new splash screen, and create the window.
- c_pSplashWnd = new CSplashWnd;
- if (!c_pSplashWnd->Create(pParentWnd))
- delete c_pSplashWnd;
- else
- {
- c_pSplashWnd->UpdateWindow();
- }
- }
- BOOL CSplashWnd::PreTranslateAppMessage(MSG* pMsg)
- {
- if (c_pSplashWnd == NULL)
- return FALSE;
- // If we get a keyboard or mouse message, hide the splash screen.
- if (pMsg->message == WM_KEYDOWN ||
- pMsg->message == WM_SYSKEYDOWN ||
- pMsg->message == WM_LBUTTONDOWN ||
- pMsg->message == WM_RBUTTONDOWN ||
- pMsg->message == WM_MBUTTONDOWN ||
- pMsg->message == WM_NCLBUTTONDOWN ||
- pMsg->message == WM_NCRBUTTONDOWN ||
- pMsg->message == WM_NCMBUTTONDOWN)
- {
- c_pSplashWnd->HideSplashScreen();
- return TRUE; // message handled here
- }
- return FALSE; // message not handled
- }
- BOOL CSplashWnd::Create(CWnd* pParentWnd /*= NULL*/)
- {
- imageList.Load("splash.bmp", 1, RGB(255,0,255));
- // if (!m_bitmap.LoadBitmap(IDB_SPLASH))
- // return FALSE;
- // BITMAP bm;
- // m_bitmap.GetBitmap(&bm);
- if(CreateEx(0,
- AfxRegisterWndClass(0, AfxGetApp()->LoadStandardCursor(IDC_ARROW)),
- NULL, WS_POPUP | WS_VISIBLE, 0, 0, imageList.m_nEveryCx, imageList.m_nEveryCy,
- pParentWnd->GetSafeHwnd(), NULL)
- == FALSE)
- return FALSE;
- // CRgn rgn;
- // BOOL bRegRet = rgn.CreateEllipticRgn(0, 0, imageList.m_nEveryCx, imageList.m_nEveryCy);
- // SetWindowRgn(rgn.operator HRGN( ), FALSE);
- return TRUE;
- }
- void CSplashWnd::HideSplashScreen()
- {
- // Destroy the window, and update the mainframe.
- DestroyWindow();
- CWnd * pWnd = AfxGetMainWnd();
- if(pWnd && ::IsWindow(pWnd->m_hWnd))
- pWnd->UpdateWindow();
- }
- void CSplashWnd::PostNcDestroy()
- {
- // Free the C++ class.
- delete this;
- }
- int CSplashWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
- m_wndAnimate.Create(WS_CHILD|WS_VISIBLE,CRect(0,40,100,100),this,-1);
- BOOL q = m_wndAnimate.Open(IDR_VC6);
- m_wndAnimate.Play(0,-1,-1);
- // Center the window.
- CenterWindow();
- // Set a timer to destroy the splash screen.
- SetTimer(1, 5000, NULL);
- return 0;
- }
- void CSplashWnd::OnPaint()
- {
- CPaintDC dc(this);
- /* CRect rect;
- GetClientRect(rect);
- dc.SetBkColor(::GetSysColor(COLOR_3DHIGHLIGHT));
- dc.ExtTextOut(0,0,ETO_OPAQUE,rect,NULL,0,NULL);
- CRgn rgn;
- BOOL bRegRet = rgn.CreateEllipticRgn(0, 0, imageList.m_nEveryCx, imageList.m_nEveryCy);
- dc.FillRgn( &rgn, &CBrush(::GetSysColor(COLOR_3DHIGHLIGHT)));
- */
- /* CDC dcImage;
- if (!dcImage.CreateCompatibleDC(&dc))
- return;
- BITMAP bm;
- m_bitmap.GetBitmap(&bm);
- // Paint the image.
- CBitmap* pOldBitmap = dcImage.SelectObject(&m_bitmap);
- dc.BitBlt(0, 0, bm.bmWidth, bm.bmHeight, &dcImage, 0, 0, SRCCOPY);
- dcImage.SelectObject(pOldBitmap);
- */
- CRect rect;
- GetClientRect(rect);
- // CStretchDC dcEx(&dc,CRect(0,0,imageList.m_nEveryCx, imageList.m_nEveryCy),rect);
- imageList.Draw(&dc,0,CPoint(0,0),ILD_TRANSPARENT);
- dc.SetBkMode(TRANSPARENT);
- dc.SetTextColor(RGB(0,255,255));
- dc.SelectObject(&m_fontSys);
- dc.TextOut(10,10,m_strHint);
- }
- void CSplashWnd::OnTimer(UINT nIDEvent)
- {
- // Destroy the splash screen window.
- HideSplashScreen();
- }
- void CSplashWnd::ShowHint(LPCSTR strShow)
- {
- if (!c_bShowSplashWnd || c_pSplashWnd == NULL)
- {
- CSplashWnd::ShowSplashScreen(NULL);
- if (!c_bShowSplashWnd || c_pSplashWnd == NULL)
- return;
- }
- c_pSplashWnd->m_strHint = strShow;
- c_pSplashWnd->RedrawWindow(CRect(10,10,400,30));
- }
- BOOL CSplashWnd::IsExistence()
- {
- return (c_pSplashWnd != NULL);
- }