📄 showmsgdlg.cpp
字号:
/** \file ShowMsgDlg.cpp
\brief 消息显示对话框:类似FoxMail收发邮件的信息框
\brief http://www.zhugang.net
\author zhugang
\date 2004-4
\warning
\todo
*/
// ShowMsgDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ShowMsgDlg.h"
#include "ZgTools.h"
#include "PublicClass.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CShowMsgDlg dialog
CShowMsgDlg::CShowMsgDlg(CWnd* pParent /*=NULL*/)
: CDialog(CShowMsgDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CShowMsgDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
mi_TimerResize = 0;
mi_Height = 0;
mi_ScreenX = GetSystemMetrics(SM_CXFULLSCREEN);
mi_ScreenY = GetSystemMetrics(SM_CYFULLSCREEN);
mi_WndWidth = 170;
mi_WndHeight = 120;
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
lf.lfHeight = 16;
strcpy(lf.lfFaceName ,"宋体");
lf.lfUnderline = TRUE;
lf.lfWeight = FW_BOLD;
m_TitleFont.CreateFontIndirect(&lf);
lf.lfHeight = 12;
strcpy(lf.lfFaceName ,"宋体");
lf.lfUnderline = FALSE;
lf.lfWeight = FW_NORMAL;
m_TextFont.CreateFontIndirect(&lf);
}
void CShowMsgDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CShowMsgDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CShowMsgDlg, CDialog)
//{{AFX_MSG_MAP(CShowMsgDlg)
ON_WM_ERASEBKGND()
ON_WM_SHOWWINDOW()
ON_WM_TIMER()
ON_WM_LBUTTONDOWN()
ON_WM_SETCURSOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CShowMsgDlg message handlers
BOOL CShowMsgDlg::DestroyWindow()
{
// TODO: Add your specialized code here and/or call the base class
m_TitleFont.DeleteObject();
m_TextFont.DeleteObject();
return CDialog::DestroyWindow();
}
BOOL CShowMsgDlg::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
CZgClientRect rcClient(this);
COLORREF crLeft = RGB(248, 255, 254);
COLORREF crRight = RGB(111, 255, 254);
CPublicClass::GradientFillRect(pDC->GetSafeHdc(), rcClient, GRADIENT_FILL_RECT_H, crLeft, crRight);
CPoint pt=CPoint(8,12);
HICON hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
pDC->DrawIcon(pt, hIcon);
CRect rcTitle = CRect(40, 12, rcClient.right, 44);
CFont *pOldFont = (CFont*)pDC->SelectObject(&m_TitleFont);
UINT nFormat = DT_VCENTER|DT_SINGLELINE|DT_CENTER;
pDC->SetTextColor(RGB(0,0,255));
pDC->SetBkMode(TRANSPARENT);
pDC->DrawText(m_strTitle, &rcTitle, nFormat);
CRect rcText = CRect(16, 50, rcClient.right-8, mi_WndHeight-8);
nFormat = DT_WORDBREAK|DT_LEFT;
pDC->SelectObject(&m_TextFont);
pDC->SetTextColor(RGB(0,0,0));
pDC->DrawText(m_strText, &rcText, nFormat);
pDC->SelectObject(pOldFont);
return TRUE;
}
void CShowMsgDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
// TODO: Add your message handler code here
if (mi_TimerResize!=0)
{
AnimateWindow(GetSafeHwnd(), 800, AW_BLEND|AW_HIDE);
KillTimer(mi_TimerResize);
mi_TimerResize = 0;
}
if (bShow && nStatus!=SW_PARENTOPENING)
{
mi_ScreenX = GetSystemMetrics(SM_CXFULLSCREEN);
mi_ScreenY = GetSystemMetrics(SM_CYFULLSCREEN)+20;
mi_Height = 0;
mi_TimerResize = SetTimer(1, 10, NULL);
SetWindowPos(&wndTopMost, mi_ScreenX-mi_WndWidth, mi_ScreenY, mi_WndWidth, mi_WndHeight, SWP_SHOWWINDOW|SWP_NOACTIVATE);
}
}
void CShowMsgDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
if (nIDEvent == mi_TimerResize)
{
mi_Height += 3;
SetWindowPos(&wndTopMost, mi_ScreenX-mi_WndWidth, mi_ScreenY-mi_Height, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW);
if (mi_Height >= mi_WndHeight)
{
KillTimer(mi_TimerResize);
mi_TimerResize = 0;
mi_TimerClose = SetTimer(2, 6000, NULL);
}
}
else if (nIDEvent == mi_TimerClose)
{
CloseMsg();
return;
}
CDialog::OnTimer(nIDEvent);
}
void CShowMsgDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CDialog::OnLButtonDown(nFlags, point);
//AfxGetMainWnd()->ShowWindow(SW_NORMAL);
//AfxGetMainWnd()->SetForegroundWindow();
CloseMsg();
}
BOOL CShowMsgDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
// TODO: Add your message handler code here and/or call default
SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(32649)));
return TRUE;
return CDialog::OnSetCursor(pWnd, nHitTest, message);
}
void CShowMsgDlg::CloseMsg(BOOL bAntimate)
{
if (mi_TimerClose!=0)
{
KillTimer(mi_TimerClose);
mi_TimerClose = 0;
}
if (bAntimate)
AnimateWindow(GetSafeHwnd(), 500, AW_BLEND|AW_HIDE);
OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -