From 22406cde19e36a50bec2e88b8ae19ef24af4a1c1 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Sun, 24 Jun 2012 16:43:51 +0300 Subject: [PATCH] Skin Installer: Removed default header image --- SkinInstaller/DialogInstall.cpp | 32 +++++++++++++++++++++++++++++--- SkinInstaller/DialogInstall.h | 2 ++ SkinInstaller/SkinInstaller.rc | 10 +--------- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/SkinInstaller/DialogInstall.cpp b/SkinInstaller/DialogInstall.cpp index 95dd58e6..546e478e 100644 --- a/SkinInstaller/DialogInstall.cpp +++ b/SkinInstaller/DialogInstall.cpp @@ -45,6 +45,7 @@ inline bool IsWin32Build() */ CDialogInstall::CDialogInstall(HWND wnd, const WCHAR* file) : CDialog(wnd), m_TabInstall(wnd), + m_HeaderBitmap(), m_InstallThread(), m_PackageUnzFile(), m_PackageFileName(file), @@ -165,6 +166,33 @@ INT_PTR CDialogInstall::OnInitDialog(WPARAM wParam, LPARAM lParam) if (ReadPackage()) { + item = GetDlgItem(m_Window, IDC_INSTALL_HEADER_BITMAP); + if (m_HeaderBitmap) + { + SendMessage(item, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)m_HeaderBitmap); + } + else + { + RECT r; + GetClientRect(item, &r); + ShowWindow(item, SW_HIDE); + int yDiff = r.bottom; + + // Move all controls on the main dialog up to "fill" header area. + int controlIds[] = { IDC_INSTALL_TAB, IDC_INSTALL_ADVANCED_BUTTON, IDC_INSTALL_INSTALL_BUTTON, IDCANCEL, 0 }; + for (int i = 0; i < _countof(controlIds); ++i) + { + HWND control = controlIds[i] ? GetDlgItem(m_Window, controlIds[i]) : m_TabInstall.GetWindow(); + GetWindowRect(control, &r); + MapWindowPoints(NULL, m_Window, (POINT*)&r, sizeof(RECT) / sizeof(POINT)); + MoveWindow(control, r.left, r.top - yDiff, r.right - r.left, r.bottom - r.top, TRUE); + } + + // Remove blank area at the bottom of the dialog and center it. + GetWindowRect(m_Window, &r); + MoveWindow(m_Window, r.left, r.top + (yDiff / 2), r.right - r.left, r.bottom - r.top - yDiff, TRUE); + } + m_TabInstall.Activate(); } else @@ -468,9 +496,7 @@ bool CDialogInstall::ReadPackage() return false; } - HBITMAP bitmap = (HBITMAP)LoadImage(NULL, tempFileSz, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); - HWND header = GetDlgItem(m_Window, IDC_INSTALL_HEADER_BITMAP); - SendMessage(header, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)bitmap); + m_HeaderBitmap = (HBITMAP)LoadImage(NULL, tempFileSz, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); DeleteFile(tempFileSz); } diff --git a/SkinInstaller/DialogInstall.h b/SkinInstaller/DialogInstall.h index 031d77a6..ef0dd797 100644 --- a/SkinInstaller/DialogInstall.h +++ b/SkinInstaller/DialogInstall.h @@ -106,6 +106,8 @@ private: CTabInstall m_TabInstall; + HBITMAP m_HeaderBitmap; + HANDLE m_InstallThread; std::wstring m_ErrorMessage; diff --git a/SkinInstaller/SkinInstaller.rc b/SkinInstaller/SkinInstaller.rc index 3e9944d3..e7e666db 100644 --- a/SkinInstaller/SkinInstaller.rc +++ b/SkinInstaller/SkinInstaller.rc @@ -174,8 +174,7 @@ STYLE DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Rainmeter Skin Installer" FONT 8, "MS Shell Dlg 2" { - CONTROL IDB_INSTALLHEADER, IDC_INSTALL_HEADER_BITMAP, STATIC, SS_BITMAP | WS_CHILD | WS_VISIBLE, 0, 0, 266, 37 - CONTROL "", IDC_STATIC, STATIC, SS_ETCHEDHORZ | WS_CHILD | WS_VISIBLE, 0, 37, 270, 1 + CONTROL 0, IDC_INSTALL_HEADER_BITMAP, STATIC, SS_BITMAP | WS_CHILD | WS_VISIBLE, 0, 0, 266, 37 CONTROL "", IDC_INSTALL_TAB, "SysTabControl32", TCS_TABS | TCS_FIXEDWIDTH, 6, 42, 254, 185 PUSHBUTTON "Advanced", IDC_INSTALL_ADVANCED_BUTTON, 6, 231, 70, 14 DEFPUSHBUTTON "Install", IDC_INSTALL_INSTALL_BUTTON, 155, 231, 50, 14 @@ -200,13 +199,6 @@ FONT 8, "MS Shell Dlg 2" CONTROL "", IDC_INSTALLTAB_PROGRESS, "msctls_progress32", PBS_MARQUEE | NOT WS_VISIBLE | WS_BORDER, 0, 15, 236, 11 } -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDB_INSTALLHEADER BITMAP "res/Rainstaller.bmp" - ///////////////////////////////////////////////////////////////////////////// // // Icon