Cxbx-Reloaded/Source/Win32/Cxbx/WndAbout.cpp

162 lines
5.0 KiB
C++
Raw Normal View History

2003-01-26 06:18:56 +00:00
// ******************************************************************
// *
// * .,-::::: .,:: .::::::::. .,:: .:
// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;;
// * [[[ '[[,,[[' [[[__[[\. '[[,,[['
// * $$$ Y$$$P $$""""Y$$ Y$$$P
// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
// *
// * Cxbx->Win32->Cxbx->WndAbout.cpp
// *
// * This file is part of the Cxbx project.
// *
// * Cxbx and Cxbe are free software; you can redistribute them
// * and/or modify them under the terms of the GNU General Public
// * License as published by the Free Software Foundation; either
// * version 2 of the license, or (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have recieved a copy of the GNU General Public License
// * along with this program; see the file COPYING.
// * If not, write to the Free Software Foundation, Inc.,
// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA.
// *
// * (c) 2002-2003 Aaron Robinson <caustik@caustik.com>
// *
// * All rights reserved
// *
// ******************************************************************
#include "WndAbout.h"
2003-03-04 07:05:25 +00:00
#include "ResCxbx.h"
2003-01-26 06:18:56 +00:00
2003-03-08 00:38:51 +00:00
// ******************************************************************
// * constructor
// ******************************************************************
2003-01-26 06:18:56 +00:00
WndAbout::WndAbout(HINSTANCE x_hInstance, HWND x_parent) : Wnd(x_hInstance)
{
m_classname = "WndAbout";
2003-04-08 03:34:05 +00:00
m_wndname = "Cxbx " _CXBX_VERSION;
2003-01-26 06:18:56 +00:00
2003-02-15 08:56:27 +00:00
m_w = 285;
m_h = 180;
2003-01-26 06:18:56 +00:00
2003-03-08 00:38:51 +00:00
// ******************************************************************
// * center to parent
// ******************************************************************
2003-01-26 06:18:56 +00:00
{
RECT rect;
GetWindowRect(x_parent, &rect);
m_x = rect.left + (rect.right - rect.left)/2 - m_w/2;
m_y = rect.top + (rect.bottom - rect.top)/2 - m_h/2;
}
m_parent = x_parent;
m_wndstyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_VISIBLE;
return;
}
// ******************************************************************
// * deconstructor
// ******************************************************************
WndAbout::~WndAbout()
{
}
// ******************************************************************
// * WndProc
// ******************************************************************
LRESULT CALLBACK WndAbout::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_CREATE:
{
EnableWindow(m_parent, FALSE);
HDC hDC = GetDC(hwnd);
int nHeight = -MulDiv(8, GetDeviceCaps(hDC, LOGPIXELSY), 72);
2003-03-07 18:22:13 +00:00
m_hFont = CreateFont(nHeight, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, FF_ROMAN, "Verdana");
2003-01-26 06:18:56 +00:00
2003-03-07 18:22:13 +00:00
m_BackBmp = (HBITMAP)LoadImage(m_hInstance, MAKEINTRESOURCE(IDB_ABOUT), IMAGE_BITMAP, 0, 0, 0);
2003-02-15 08:56:27 +00:00
2003-03-07 18:22:13 +00:00
m_BackDC = CreateCompatibleDC(hDC);
2003-02-15 08:56:27 +00:00
2003-03-07 18:22:13 +00:00
m_OrigBmp = (HBITMAP)SelectObject(m_BackDC, m_BackBmp);
2003-02-15 08:56:27 +00:00
2003-01-26 06:18:56 +00:00
ReleaseDC(hwnd, hDC);
2003-04-01 23:11:03 +00:00
SetClassLong(hwnd, GCL_HICON, (LONG)LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_CXBX)));
2003-01-26 06:18:56 +00:00
}
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint(hwnd, &ps);
HDC hDC = GetDC(hwnd);
2003-03-08 00:38:51 +00:00
HGDIOBJ OrgObj = SelectObject(hDC, m_hFont);
// ******************************************************************
// * draw bottom URL bar
// ******************************************************************
2003-01-26 06:18:56 +00:00
{
2003-03-08 00:38:51 +00:00
SetBkColor(hDC, GetSysColor(COLOR_HIGHLIGHT));
2003-01-26 06:18:56 +00:00
2003-03-08 00:38:51 +00:00
SetTextColor(hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
2003-01-26 06:18:56 +00:00
2003-03-08 00:38:51 +00:00
char buffer[] = " Contact the author : caustik@caustik.com";
2003-01-26 06:18:56 +00:00
2003-03-08 00:38:51 +00:00
RECT rect = {0, 134, 280, 148};
2003-01-26 06:18:56 +00:00
2003-03-08 00:38:51 +00:00
ExtTextOut(hDC, 0, 134, ETO_OPAQUE, &rect, buffer, strlen(buffer), 0);
}
2003-01-26 06:18:56 +00:00
2003-03-08 00:38:51 +00:00
// ******************************************************************
// * draw bitmap
// ******************************************************************
{
2003-03-07 18:22:13 +00:00
BitBlt(hDC, 2, 4, 275, 125, m_BackDC, 0, 0, SRCCOPY);
2003-01-26 06:18:56 +00:00
}
2003-03-08 00:38:51 +00:00
SelectObject(hDC, OrgObj);
2003-01-26 06:18:56 +00:00
if(hDC != NULL)
ReleaseDC(hwnd, hDC);
EndPaint(hwnd, &ps);
}
break;
case WM_LBUTTONUP:
SendMessage(hwnd, WM_CLOSE, 0, 0);
2003-03-07 18:22:13 +00:00
break;
2003-01-26 06:18:56 +00:00
case WM_CLOSE:
EnableWindow(m_parent, TRUE);
DestroyWindow(hwnd);
2003-03-07 18:22:13 +00:00
break;
2003-01-26 06:18:56 +00:00
case WM_DESTROY:
DeleteObject(m_hFont);
PostQuitMessage(0);
2003-03-07 18:22:13 +00:00
break;
2003-01-26 06:18:56 +00:00
default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
return 0;
}