|
| 1 | +/*----------------------------------------------------------------------------- |
| 2 | + Lua Studio |
| 3 | +
|
| 4 | +Copyright (c) 1996-2008 Michal Kowalski |
| 5 | +-----------------------------------------------------------------------------*/ |
| 6 | + |
| 7 | +#include "StdAfx.h" |
| 8 | +#include "About.h" |
| 9 | + |
| 10 | + |
| 11 | +CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) |
| 12 | +{ |
| 13 | +} |
| 14 | + |
| 15 | +void CAboutDlg::DoDataExchange(CDataExchange* DX) |
| 16 | +{ |
| 17 | + CDialog::DoDataExchange(DX); |
| 18 | + |
| 19 | + DDX_Control(DX, IDC_TITLE, title_ctrl_); |
| 20 | + DDX_Text(DX, IDC_ABOUT_VER, version_string_); |
| 21 | +} |
| 22 | + |
| 23 | +BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) |
| 24 | + ON_WM_ERASEBKGND() |
| 25 | + ON_WM_CTLCOLOR() |
| 26 | +END_MESSAGE_MAP() |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | +BOOL CAboutDlg::OnInitDialog() |
| 31 | +{ |
| 32 | + if (HRSRC rsrc= ::FindResource(AfxGetResourceHandle(), MAKEINTRESOURCE(VS_VERSION_INFO), RT_VERSION)) |
| 33 | + if (HGLOBAL global = ::LoadResource(AfxGetResourceHandle(), rsrc)) |
| 34 | + { |
| 35 | + VS_FIXEDFILEINFO* ver= (VS_FIXEDFILEINFO *)((char *)::LockResource(global) + 0x28); |
| 36 | + if (ver->dwSignature == 0xfeef04bd) |
| 37 | + version_string_.Format(IDS_ABOUT_VER, |
| 38 | + (int)HIWORD(ver->dwProductVersionMS), (int)LOWORD(ver->dwProductVersionMS), |
| 39 | + (int)HIWORD(ver->dwProductVersionLS), (int)LOWORD(ver->dwProductVersionLS)); |
| 40 | + |
| 41 | + ::FreeResource(global); |
| 42 | + } |
| 43 | + |
| 44 | + about_.Attach(::LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDB_ABOUT), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION)); |
| 45 | + |
| 46 | + CDialog::OnInitDialog(); |
| 47 | + |
| 48 | + LOGFONT lf; |
| 49 | + title_ctrl_.GetFont()->GetLogFont(&lf); |
| 50 | + |
| 51 | + GetFont()->GetLogFont(&lf); |
| 52 | + // CClientDC dc(this); |
| 53 | + // lf.lfHeight = -MulDiv(9, dc.GetDeviceCaps(LOGPIXELSY), 96); |
| 54 | + lf.lfWeight = 700; // bold |
| 55 | + lf.lfHeight -= 2; // larger |
| 56 | + title_font_.CreateFontIndirect(&lf); |
| 57 | + title_ctrl_.SetFont(&title_font_); |
| 58 | + |
| 59 | + web_page_link_.SubclassDlgItem(IDC_LINK, this, "http://lua-studio.luaforge.net"); |
| 60 | + lua_org_link_.SubclassDlgItem(IDC_LINK_LUA, this, "http://www.lua.org/"); |
| 61 | + |
| 62 | + return true; |
| 63 | +} |
| 64 | + |
| 65 | + |
| 66 | +BOOL CAboutDlg::OnEraseBkgnd(CDC* dc) |
| 67 | +{ |
| 68 | + CRect rect(0,0,0,0); |
| 69 | + GetClientRect(rect); |
| 70 | + |
| 71 | + dc->FillSolidRect(rect, RGB(255,255,255)); // white to match image |
| 72 | + |
| 73 | + // bitmap (x, y) location in the dialog |
| 74 | + CPoint pos(180, 40); |
| 75 | + |
| 76 | + DIBSECTION bmp; |
| 77 | + if (about_.m_hObject && about_.GetObject(sizeof bmp, &bmp) && bmp.dsBm.bmBits) |
| 78 | + { |
| 79 | + dc->SetStretchBltMode(COLORONCOLOR); |
| 80 | + |
| 81 | + ::StretchDIBits(*dc, pos.x, pos.y, bmp.dsBm.bmWidth, bmp.dsBm.bmHeight, |
| 82 | + 0, 0, bmp.dsBm.bmWidth, bmp.dsBm.bmHeight, bmp.dsBm.bmBits, |
| 83 | + reinterpret_cast<BITMAPINFO*>(&bmp.dsBmih), DIB_RGB_COLORS, SRCCOPY); |
| 84 | + } |
| 85 | + |
| 86 | + return true; |
| 87 | +} |
| 88 | + |
| 89 | + |
| 90 | +HBRUSH CAboutDlg::OnCtlColor(CDC* dc, CWnd* wnd, UINT ctlColor) |
| 91 | +{ |
| 92 | + if (wnd == &web_page_link_) |
| 93 | + return web_page_link_.CtlColor(dc, ctlColor); |
| 94 | + else if (wnd == &lua_org_link_) |
| 95 | + return lua_org_link_.CtlColor(dc, ctlColor); |
| 96 | + else |
| 97 | + return static_cast<HBRUSH>(::GetStockObject(WHITE_BRUSH)); |
| 98 | +} |
0 commit comments