SmsManager/DLG_ShowWarning.cpp

203 lines
8.8 KiB
C++
Raw Normal View History

2025-01-14 10:46:18 +08:00
<EFBFBD><EFBFBD>// DLG_ShowWarning.cpp: <EFBFBD>[<EFBFBD>s<EFBFBD>e<EFBFBD>N
//
#include "stdafx.h"
#include "SmsManager.h"
#include "DLG_ShowWarning.h"
#include "afxdialogex.h"
#include "MemdcR.h"
#include "MainFrm.h"
// DLG_ShowWarning <EFBFBD>[݋Fh
IMPLEMENT_DYNAMIC(DLG_ShowWarning, CDialogEx)
DLG_ShowWarning::DLG_ShowWarning(CWnd* pParent /*=nullptr*/)
: CDialogEx(IDD_SHOWWARNING, pParent)
{
m_lCount = 0;
m_pMainFrame = NULL;
m_ppDlgWarning = NULL;
}
DLG_ShowWarning::~DLG_ShowWarning()
{
}
void DLG_ShowWarning::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(DLG_ShowWarning, CDialogEx)
ON_WM_CLOSE()
ON_WM_PAINT()
ON_WM_LBUTTONDOWN()
ON_WM_TIMER()
END_MESSAGE_MAP()
// DLG_ShowWarning <EFBFBD>mo`Yt z<EFBFBD>^
BOOL DLG_ShowWarning::OnInitDialog()
{
CDialogEx::OnInitDialog();
CBitmap bmpMain; //(u<EFBFBD>N}<EFBFBD>eQYe<EFBFBD>[<EFBFBD>Vb_
BITMAP BitMap; //(u<EFBFBD>N<EFBFBD>SMO<EFBFBD>V<EFBFBD>v'Y\
long lTemp;
lTemp = bmpMain.LoadBitmap(IDB_S_RECVSMS); //ňeQMO<EFBFBD>V
lTemp = bmpMain.GetBitmap(&BitMap); //<EFBFBD>S<EFBFBD>_MO<EFBFBD>V<EFBFBD>v'Y\
xBmp = BitMap.bmWidth + 2;
yBmp = BitMap.bmHeight + 2;
HDC hScrDC; // O\U^<EFBFBD>T<EFBFBD>QX[<EFBFBD><EFBFBD>Y<EFBFBD>c<EFBFBD><EFBFBD>h<EFBFBD>
//:NO\U^R<EFBFBD>^<EFBFBD><EFBFBD>Y<EFBFBD>c<EFBFBD><EFBFBD>h<EFBFBD>
hScrDC = CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
//<EFBFBD><EFBFBD><EFBFBD>_O\U^R<EFBFBD><EFBFBD><EFBFBD>s
xScrn = GetDeviceCaps(hScrDC, HORZRES);
yScrn = GetDeviceCaps(hScrDC, VERTRES);
MoveWindow(xScrn, yScrn, xBmp, yBmp);
CRect rect;
GetClientRect(&rect);
::SetWindowPos(m_hWnd, HWND_TOPMOST, 0, 0, rect.Width(), rect.Height() + 20, SWP_NOMOVE);
SetTimer(1, 100, NULL);
return TRUE; // return TRUE unless you set the focus to a control
// _8^: OCX ^\'`u<EFBFBD><EFBFBD>^ԏ<EFBFBD>V FALSE
}
void DLG_ShowWarning::OnClose()
{
KillTimer(1);
KillTimer(2);
KillTimer(3);
if (m_ppDlgWarning)
{
*m_ppDlgWarning = NULL;
}
CDialogEx::OnClose();
this->DestroyWindow();
delete this;
}
void DLG_ShowWarning::SetParam(CString strText, CWnd * pMainFrame, DLG_ShowWarning* * pdlgWarning)
{
m_strShowText = strText;
m_pMainFrame = pMainFrame;
m_ppDlgWarning = pdlgWarning;
}
void DLG_ShowWarning::OnPaint()
{
CPaintDC dc(this); // device context for painting
CMemDC_R memDC(&dc);
CDC pDispDC;
pDispDC.CreateCompatibleDC(&memDC);
CBitmap bmpMain; //(u<EFBFBD>N}<EFBFBD>eQYe<EFBFBD>[<EFBFBD>Vb_
CBitmap * OldBmp; //<EFBFBD><EFBFBD>U_<EFBFBD>e<EFBFBD>vBitmap
BITMAP BitMap; //(u<EFBFBD>N<EFBFBD>SMO<EFBFBD>V<EFBFBD>v'Y\
long lTemp;
lTemp = bmpMain.LoadBitmap(IDB_S_RECVSMS); //ňeQMO<EFBFBD>V
lTemp = bmpMain.GetBitmap(&BitMap); //<EFBFBD>S<EFBFBD>_MO<EFBFBD>V<EFBFBD>v'Y\
//HBITMAP bmp;
//bmp = (HBITMAP)LoadImage( NULL,"Main.bmp",IMAGE_BITMAP,0,0,LR_DEFAULTCOLOR|LR_LOADFROMFILE);
//GetObject(bmp, sizeof(BitMap), &BitMap);
//CBitmap * pbmp;
//pbmp = CBitmap::FromHandle( bmp );
//OldBmp = pDispDC.SelectObject( &bmpMain );// <EFBFBD>eQMO<EFBFBD>V
OldBmp = pDispDC.SelectObject(&bmpMain);// <EFBFBD>eQMO<EFBFBD>V
memDC.BitBlt(0, 0, BitMap.bmWidth, BitMap.bmHeight, &pDispDC, 0, 0, SRCCOPY);
memDC.SetBkMode(TRANSPARENT);
CFont* pOldfont = NULL;
CFont font1;
font1.CreateFont(-MulDiv(10, dc.GetDeviceCaps(LOGPIXELSY), 24),
0, 0, 0, FW_NORMAL, 0, 0, 0, GB2312_CHARSET,
OUT_STROKE_PRECIS, CLIP_STROKE_PRECIS, DRAFT_QUALITY,
VARIABLE_PITCH | FF_SWISS, _T("ўSO"));
pOldfont = dc.SelectObject(&font1);
//memDC.TextOut(10, 50, m_strShowText);
RECT rect;
rect.left = 10; rect.top = 50;
rect.right = 200; rect.bottom = 200;
memDC.SetTextColor(RGB(255, 0, 0));
memDC.DrawText(m_strShowText, &rect, DT_LEFT | DT_WORDBREAK | DT_EDITCONTROL);
if (pOldfont)
dc.SelectObject(pOldfont);
font1.DeleteObject();
//b` Y<EFBFBD>Seg<EFBFBD>vBMP
pDispDC.SelectObject(OldBmp);
//CDialog::OnPaint();
}
void DLG_ShowWarning::OnLButtonDown(UINT nFlags, CPoint point)
{
//KillTimer(1);
//KillTimer(2);
//SetTimer(3, 30, NULL); ///T<EFBFBD>RM<EFBFBD><EFBFBD>e<EFBFBD><EFBFBD>
if (m_pMainFrame)
{
((CMainFrame *)m_pMainFrame)->ShowCheckUpDlg();
}
CDialogEx::OnLButtonDown(nFlags, point);
}
void DLG_ShowWarning::OnTimer(UINT_PTR nIDEvent)
{
switch (nIDEvent)
{
case 1:
m_lCount += 5;
if (m_lCount >= yBmp + 50) //GS<EFBFBD><EFBFBD>
NP<EFBFBD>
{
KillTimer(1);
//SetTimer(2, 5000, NULL); //5<EFBFBD>y<EFBFBD><EFBFBD>T<EFBFBD><EFBFBD>Q,9eb<EFBFBD>p<EFBFBD>QT NM<EFBFBD>
return;
}
MoveWindow(xScrn - xBmp - 20, yScrn - m_lCount, xBmp, yBmp);
break;
case 2:
KillTimer(2);
SetTimer(3, 70, NULL); ///T<EFBFBD>RM<EFBFBD><EFBFBD>e<EFBFBD><EFBFBD>
break;
case 3:
m_lCount -= 5;
if (m_lCount <= 0) //M<EFBFBD><EFBFBD><EFBFBD>
NP<EFBFBD>
{
KillTimer(3);
this->OnClose();
return;
}
MoveWindow(xScrn - xBmp - 20, yScrn - m_lCount, xBmp, yBmp);
break;
}
CDialogEx::OnTimer(nIDEvent);
}