diff options
Diffstat (limited to 'src/T2OpenningWindow.cpp')
-rw-r--r-- | src/T2OpenningWindow.cpp | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/src/T2OpenningWindow.cpp b/src/T2OpenningWindow.cpp index d16135f..ee1cb40 100644 --- a/src/T2OpenningWindow.cpp +++ b/src/T2OpenningWindow.cpp @@ -1,2 +1,144 @@ +#include "Bitmap.h" +#include "T2.h" #include "T2OpenningWindow.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#line 27 +IMPLEMENT_DYNCREATE(T2OpenningWindow, CFrameWnd) + +T2OpenningWindow::T2OpenningWindow() { + _CC = 1; + +#line 32 + mBitmap = new Bitmap; + if (!mBitmap->LoadFile("T2.dat")) { + delete mBitmap; + mBitmap = NULL; + } +} + +/*virtual*/ T2OpenningWindow::~T2OpenningWindow() { + if (mBitmap) + delete mBitmap; +} + +BEGIN_MESSAGE_MAP(T2OpenningWindow, CFrameWnd) + ON_WM_PAINT() + ON_WM_LBUTTONDOWN() + ON_WM_ERASEBKGND() +END_MESSAGE_MAP() + +void T2OpenningWindow::ShowOpenningWindow() { + CString text; + + mWndClass = AfxRegisterWndClass(0, NULL, (HBRUSH) GetStockObject(BLACK_BRUSH)); + + RECT windowRect; + windowRect.left = 0; + windowRect.top = 0; + windowRect.right = 640; + windowRect.bottom = 480; + + Create(mWndClass, text, WS_MAXIMIZE | WS_POPUP, windowRect, AfxGetMainWnd(), NULL, WS_EX_TOPMOST); + + RECT rect; + ::GetWindowRect(::GetDesktopWindow(), &rect); + MoveWindow(-5, -5, rect.right + 10, rect.bottom + 10); + ShowWindow(SW_SHOW); + SetActiveWindow(); + + PlaySound(MAKEINTRESOURCE(1), AfxGetInstanceHandle(), SND_ASYNC | SND_NOWAIT | SND_RESOURCE); + T2_APP->app_vfB4(); + + DWORD startTick = GetTickCount(); + while (labs(GetTickCount() - startTick) < 2000) + T2_APP->app_vfB4(); + + if (mBitmap) + _CC = 0; + + InvalidateRect(NULL); + + startTick = GetTickCount(); + while (labs(GetTickCount() - startTick) < 3000) + T2_APP->app_vfB4(); + + ShowWindow(SW_HIDE); + DestroyWindow(); +} + +void T2OpenningWindow::OnPaint() { +#pragma var_order(rect, centerY, dc, centerX) + CPaintDC dc(this); + + RECT rect; + ::GetWindowRect(::GetDesktopWindow(), &rect); + int centerX = rect.right / 2; + int centerY = rect.bottom / 2; + + if (_CC == 0) { +#pragma var_order(paletteH, width, height, hdc, palette) + HDC hdc = dc; + HPALETTE paletteH = mBitmap->CreatePalette(); + CPalette palette; + + SelectPalette(dc, paletteH, false); + RealizePalette(dc); + + int width = mBitmap->GetWidth(); + int height = mBitmap->GetHeight(); + mBitmap->Draw(hdc, centerX - width / 2, centerY - height / 2); + + SelectPalette(hdc, palette, false); + DeleteObject(paletteH); + } + + if (_CC == 1) { + CDC newDC; + + CBitmap bitmap; + bitmap.LoadBitmap(175); + + newDC.CreateCompatibleDC(&dc); + newDC.SelectObject(&bitmap); + dc.SelectPalette(&mPalette, false); + dc.RealizePalette(); + dc.BitBlt(centerX - 240, centerY - 188, 480, 376, &newDC, 0, 0, SRCCOPY); + } +} + +void T2OpenningWindow::OnLButtonDown(UINT nFlags, CPoint point) { + CWnd::OnLButtonDown(nFlags, point); +} + +BOOL T2OpenningWindow::OnEraseBkgnd(CDC *pDC) { +#pragma var_order(brush, pen, clientRect, windowRect) + CBrush brush; + brush.CreateSolidBrush(PALETTERGB(204, 204, 204)); + + CRect clientRect; + GetClientRect(clientRect); + + CPen pen; + pen.CreatePen(PS_SOLID, 0, PALETTERGB(255, 0, 0)); + + CRect windowRect; + GetWindowRect(windowRect); + + pDC->SelectObject(pen); + + pDC->MoveTo(windowRect.right, windowRect.top); + pDC->LineTo(windowRect.left - 1, windowRect.top); + pDC->LineTo(windowRect.left - 1, windowRect.bottom); + + pDC->MoveTo(windowRect.right, windowRect.top); + pDC->LineTo(windowRect.right, windowRect.bottom); + pDC->LineTo(windowRect.left, windowRect.bottom); + + return CFrameWnd::OnEraseBkgnd(pDC); +} |