#include "GlobalFunc.h" #include "T2ArrowWnd.h" #include "T2TowerDoc.h" #include "T2TowerMainView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif static POINT rgnPoints[7] = { {20,35}, {0, 15}, {10,15}, {10,0}, {30,0}, {30,15}, {40,15} }; #line 33 IMPLEMENT_DYNCREATE(T2ArrowWnd, CFrameWnd); T2ArrowWnd::T2ArrowWnd() { } /*virtual*/ T2ArrowWnd::~T2ArrowWnd() { } void T2ArrowWnd::Show(int inX, int inY, T2TowerDoc* inDoc) { mWndClass = AfxRegisterWndClass(CS_NOCLOSE, NULL, (HBRUSH) GetStockObject(WHITE_BRUSH)); CRect rect(0, 0, 50, 50); Create(mWndClass, "ArrowWnd", WS_CHILD, rect, inDoc->GetMainView(), NULL, WS_EX_TOPMOST); mRgn.CreatePolygonRgn(rgnPoints, 7, ALTERNATE); CRect clientRect; GetClientRect(clientRect); CPoint center; center.x = ((rect.right - rect.left) - (clientRect.right - clientRect.left)) / 2; center.y = ((rect.bottom - rect.top) - (clientRect.bottom - clientRect.top)) / 2; CRgn region; region.CreateRectRgn(0, 0, 1, 1); region.CopyRgn(&mRgn); region.OffsetRgn(center.x, center.y); SetWindowRgn(region, true); region.Detach(); SetWindowPos(NULL, inX - 20, inY - 45, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); GetCurrentT2TowerDoc()->towerDoc_vf290(true); GetCurrentT2TowerDoc()->towerDoc_vf1A0(true); mCounter = 0; SetTimer(1, 50, NULL); } BEGIN_MESSAGE_MAP(T2ArrowWnd, CFrameWnd) ON_WM_ERASEBKGND() ON_WM_TIMER() ON_WM_DESTROY() END_MESSAGE_MAP() afx_msg BOOL T2ArrowWnd::OnEraseBkgnd(CDC* pDC) { int save = pDC->SaveDC(); { CRect rect; GetClientRect(rect); COLORREF bkColor; if (mCounter & 1) bkColor = RGB(255, 0, 0); else bkColor = RGB(255, 255, 0); pDC->FillSolidRect(rect, bkColor); CBrush brush; brush.CreateStockObject(BLACK_BRUSH); pDC->FrameRgn(&mRgn, &brush, 1, 1); } pDC->RestoreDC(save); return true; } afx_msg void T2ArrowWnd::OnTimer(UINT nIDEvent) { if (nIDEvent == 1) { if (mCounter == 0) ShowWindow(SW_SHOWNA); mCounter++; if (mCounter > 30) { ShowWindow(SW_HIDE); DestroyWindow(); } else { InvalidateRect(NULL); } } } afx_msg void T2ArrowWnd::OnDestroy() { CFrameWnd::OnDestroy(); DeleteObject(mRgn); GetCurrentT2TowerDoc()->towerDoc_vf294(); GetCurrentT2TowerDoc()->towerDoc_vf1A0(false); KillTimer(1); }