void CAppInfo::ShowAppInfo(CWnd *parent)
{
if (m_pWnd == NULL)
{
m_pWnd = new CAppInfo();
}
if (m_pWnd->Create(parent))
{
m_pWnd->UpdateWindow();
}
}
BOOL CAppInfo::Create(CWnd *parent)
{
if (!m_bitmap.LoadBitmap(IDB_SPLASH))
{
return FALSE;
}
BITMAP bt;
m_bitmap.GetBitmap(&bt);
CreateEx(0, AfxRegisterWndClass(0, AfxGetApp()->LoadStandardCursor(IDC_ARROW)),
NULL, WS_POPUP | WS_VISIBLE, CRect(0, 0, bt.bmWidth, bt.bmHeight),
parent,0);
return TRUE;
}
int CAppInfo::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
SetTimer(1, 3000, 0);
return 0;
}
void CAppInfo::OnPaint()
{
CPaintDC pDC(this); // device context for painting
// TODO: Add your message handler code here
CDC cDC;
BITMAP bt;
m_bitmap.GetBitmap(&bt);
cDC.CreateCompatibleDC(&pDC);
CBitmap *poldBt = (CBitmap *)cDC.SelectObject(&m_bitmap);
pDC.BitBlt(0, 0, bt.bmWidth, bt.bmHeight, &cDC, 0, 0, SRCCOPY);
cDC.SelectObject(poldBt);
CRect rt1, rt2;
GetParent()->GetWindowRect(&rt1);
rt2.left = rt1.left + (rt1.Width()-bt.bmWidth)/2;
rt2.right = rt2.left +bt.bmWidth;
rt2.top = rt1.top + (rt1.Height()-bt.bmHeight)/2;
rt2.bottom = rt2.top + bt.bmHeight;
MoveWindow(&rt2);
// Do not call CWnd::OnPaint() for painting messages
}
void CAppInfo::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
HideInfo();
}
//DEL void CAppInfo::OnNcDestroy()
//DEL {
//DEL delete this;
//DEL m_pWnd = NULL;
//DEL CWnd::OnNcDestroy();
//DEL
//DEL // TODO: Add your message handler code here
//DEL }
void CAppInfo::PostNcDestroy()
{
// TODO: Add your specialized code here and/or call the base class
delete this;
m_pWnd = NULL;
}
BOOL CAppInfo::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (m_pWnd == 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)
{
m_pWnd->HideInfo();
return TRUE;
// message handled here
}
return FALSE;
}
void CAppInfo::HideInfo()
{
DestroyWindow();
AfxGetMainWnd()->UpdateWindow();
}