mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
New installer: Add UI controls
This commit is contained in:
parent
99e2b69ff8
commit
e35a65eeaa
@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "Install.h"
|
||||
#include "DialogInstall.h"
|
||||
#include "Resource.h"
|
||||
#include "Application.h"
|
||||
|
||||
@ -66,6 +66,8 @@ int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int)
|
||||
return (int)InstallStatus::UnsupportedPlatform;
|
||||
}
|
||||
|
||||
CDialogInstall::Create();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -18,9 +18,63 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "DialogInstall.h"
|
||||
#include "Resource.h"
|
||||
#include "../Common/ControlTemplate.h"
|
||||
|
||||
CDialogInstall::CDialogInstall() : CDialog()
|
||||
CDialogInstall* CDialogInstall::c_Dialog = nullptr;
|
||||
|
||||
HICON GetIcon(UINT id, bool large)
|
||||
{
|
||||
typedef HRESULT (WINAPI * FPLOADICONMETRIC)(HINSTANCE hinst, PCWSTR pszName, int lims, HICON* phico);
|
||||
|
||||
HINSTANCE hExe = GetModuleHandle(nullptr);
|
||||
HINSTANCE hComctl = GetModuleHandle(L"Comctl32");
|
||||
if (hComctl)
|
||||
{
|
||||
// Try LoadIconMetric for better quality with high DPI
|
||||
FPLOADICONMETRIC loadIconMetric = (FPLOADICONMETRIC)GetProcAddress(hComctl, "LoadIconMetric");
|
||||
if (loadIconMetric)
|
||||
{
|
||||
HICON icon;
|
||||
HRESULT hr = loadIconMetric(hExe, MAKEINTRESOURCE(id), large ? LIM_LARGE : LIM_SMALL, &icon);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
return icon;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (HICON)LoadImage(
|
||||
hExe,
|
||||
MAKEINTRESOURCE(id),
|
||||
IMAGE_ICON,
|
||||
GetSystemMetrics(large ? SM_CXICON : SM_CXSMICON),
|
||||
GetSystemMetrics(large ? SM_CYICON : SM_CYSMICON),
|
||||
LR_SHARED);
|
||||
}
|
||||
|
||||
WCHAR* GetString(UINT id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case 1: return L"Install";
|
||||
case 2: return L"Rainmeter 3.0.2 beta setup";
|
||||
case 3: return L"Click 'Install' to proceed. Rainmeter will launch after setup.";
|
||||
case 5: return L"Close";
|
||||
case 6: return L"Language:";
|
||||
case 7: return L"Destination folder:";
|
||||
case 9: return L"...";
|
||||
case 10: return L"Launch Rainmeter automatically on login";
|
||||
case 13: return L"Cancel";
|
||||
case 14: return L"C:\\Program Files\\Rainmeter";
|
||||
case 15: return L"Standard install (recommended)";
|
||||
case 16: return L"Portable install";
|
||||
case 17: return L"Installation type:";
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
CDialogInstall::CDialogInstall() : Dialog()
|
||||
{
|
||||
}
|
||||
|
||||
@ -30,17 +84,17 @@ CDialogInstall::~CDialogInstall()
|
||||
|
||||
CDialogInstall* CDialogInstall::Create()
|
||||
{
|
||||
auto dialog = new CDialogInstall();
|
||||
c_Dialog = new CDialogInstall();
|
||||
|
||||
dialog->ShowDialogWindow(
|
||||
c_Dialog->ShowDialogWindow(
|
||||
L"Installer",
|
||||
0, 0, 350, 210,
|
||||
DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME,
|
||||
DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU,
|
||||
WS_EX_APPWINDOW | WS_EX_CONTROLPARENT,
|
||||
nullptr,
|
||||
false);
|
||||
|
||||
return dialog;
|
||||
return c_Dialog;
|
||||
}
|
||||
|
||||
INT_PTR CDialogInstall::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
@ -69,25 +123,52 @@ INT_PTR CDialogInstall::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
WCHAR* GetString(UINT id) { return L"test"; }
|
||||
|
||||
INT_PTR CDialogInstall::OnInitDialog(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
static const ControlTemplate::Control s_Controls[] =
|
||||
{
|
||||
CT_BUTTON(Id_CloseButton, 0,
|
||||
294, 191, 50, 14,
|
||||
WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON, 0)
|
||||
CT_ICON(Id_HeaderIcon, 0,
|
||||
8, 10, 24, 24,
|
||||
WS_VISIBLE, 0),
|
||||
|
||||
CT_LABEL(Id_HeaderTitleLabel, 2,
|
||||
40, 6, 250, 14,
|
||||
WS_VISIBLE | SS_ENDELLIPSIS | SS_NOPREFIX, 0),
|
||||
|
||||
CT_LABEL(-1, 3,
|
||||
40, 20, 250, 9,
|
||||
WS_VISIBLE | SS_ENDELLIPSIS | SS_NOPREFIX, 0),
|
||||
|
||||
|
||||
CT_BUTTON(Id_InstallButton, 1,
|
||||
199, 191, 70, 14,
|
||||
WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON, 0),
|
||||
|
||||
CT_BUTTON(Id_CancelButton, 13,
|
||||
274, 191, 70, 14,
|
||||
WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON, 0),
|
||||
|
||||
CT_TAB(Id_Tab, 0,
|
||||
-2, 38, 400, 148,
|
||||
WS_VISIBLE | WS_TABSTOP | TCS_FIXEDWIDTH, 0) // Last for correct tab order.
|
||||
};
|
||||
|
||||
CreateControls(s_Controls, _countof(s_Controls), m_Font, GetString);
|
||||
|
||||
m_TabContents.Create(m_Window);
|
||||
m_TabContents.Activate();
|
||||
|
||||
// HICON hIcon = GetIcon(IDI_APPLICATION);
|
||||
// SendMessage(m_Window, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
|
||||
SendMessage(m_Window, WM_SETICON, ICON_SMALL, (LPARAM)GetIcon(IDI_APPICON, false));
|
||||
|
||||
HWND item = GetControl(Id_CloseButton);
|
||||
HWND item = GetControl(Id_HeaderIcon);
|
||||
Static_SetIcon(item, GetIcon(IDI_APPICON, true));
|
||||
|
||||
item = GetControl(Id_HeaderTitleLabel);
|
||||
SendMessage(item, WM_SETFONT, (WPARAM)m_FontBold, 0);
|
||||
|
||||
item = GetControl(Id_InstallButton);
|
||||
SendMessage(m_Window, WM_NEXTDLGCTL, (WPARAM)item, TRUE);
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -95,7 +176,7 @@ INT_PTR CDialogInstall::OnCommand(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case Id_CloseButton:
|
||||
case Id_CancelButton:
|
||||
PostMessage(m_Window, WM_CLOSE, 0, 0);
|
||||
break;
|
||||
|
||||
@ -110,3 +191,84 @@ INT_PTR CDialogInstall::OnNotify(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Constructor.
|
||||
**
|
||||
*/
|
||||
CDialogInstall::TabContents::TabContents() : Tab()
|
||||
{
|
||||
}
|
||||
|
||||
void CDialogInstall::TabContents::Create(HWND owner)
|
||||
{
|
||||
Tab::CreateTabWindow(10, 50, 380, 135, owner);
|
||||
|
||||
static const ControlTemplate::Control s_Controls[] =
|
||||
{
|
||||
CT_LABEL(-1, 6,
|
||||
0, 3, 107, 9,
|
||||
WS_VISIBLE, 0),
|
||||
|
||||
CT_COMBOBOX(Id_LanguageComboBox, 0,
|
||||
107, 0, 222, 14,
|
||||
WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL, 0),
|
||||
|
||||
CT_LABEL(-1, 17,
|
||||
0, 21, 107, 9,
|
||||
WS_VISIBLE, 0),
|
||||
|
||||
CT_COMBOBOX(Id_InstallationTypeComboBox, 0,
|
||||
107, 18, 222, 14,
|
||||
WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST | WS_VSCROLL, 0),
|
||||
|
||||
CT_LABEL(-1, 7,
|
||||
0, 43, 107, 9,
|
||||
WS_VISIBLE, 0),
|
||||
|
||||
CT_EDIT(Id_DestinationEdit, 14,
|
||||
107, 40, 192, 14,
|
||||
WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL | ES_READONLY, WS_EX_CLIENTEDGE),
|
||||
|
||||
CT_BUTTON(Id_DestinationBrowseButton, 9,
|
||||
303, 40, 25, 14,
|
||||
WS_VISIBLE | WS_TABSTOP, 0),
|
||||
|
||||
CT_CHECKBOX(Id_LaunchOnLoginCheckBox, 10,
|
||||
0, 69, 250, 9,
|
||||
WS_VISIBLE | WS_TABSTOP, 0),
|
||||
};
|
||||
|
||||
CreateControls(s_Controls, _countof(s_Controls), c_Dialog->m_Font, GetString);
|
||||
|
||||
HWND item = GetControl(Id_LanguageComboBox);
|
||||
ComboBox_AddString(item, L"English - English (United States)");
|
||||
ComboBox_SetCurSel(item, 0);
|
||||
|
||||
item = GetControl(Id_InstallationTypeComboBox);
|
||||
ComboBox_AddString(item, L"Standard 64-bit installation (reccomended)");
|
||||
ComboBox_AddString(item, L"Standard 32-bit installation");
|
||||
ComboBox_AddString(item, L"Portable 64-bit installation");
|
||||
ComboBox_AddString(item, L"Portable 32-bit installation");
|
||||
ComboBox_SetCurSel(item, 0);
|
||||
}
|
||||
|
||||
void CDialogInstall::TabContents::Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
INT_PTR CDialogInstall::TabContents::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_COMMAND:
|
||||
return OnCommand(wParam, lParam);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
INT_PTR CDialogInstall::TabContents::OnCommand(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "../Common/Dialog.h"
|
||||
|
||||
class CDialogInstall : public CDialog
|
||||
class CDialogInstall : public Dialog
|
||||
{
|
||||
public:
|
||||
CDialogInstall();
|
||||
@ -34,15 +34,47 @@ public:
|
||||
static void ShowAboutLog();
|
||||
|
||||
protected:
|
||||
// Layouts tab
|
||||
class TabContents : public Tab
|
||||
{
|
||||
public:
|
||||
enum Id
|
||||
{
|
||||
Id_LanguageComboBox = 100,
|
||||
Id_InstallationTypeComboBox,
|
||||
Id_DestinationEdit,
|
||||
Id_DestinationBrowseButton,
|
||||
Id_LaunchOnLoginCheckBox
|
||||
};
|
||||
|
||||
TabContents();
|
||||
|
||||
void Create(HWND owner);
|
||||
virtual void Initialize();
|
||||
|
||||
protected:
|
||||
virtual INT_PTR HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);
|
||||
};
|
||||
|
||||
static CDialogInstall* c_Dialog;
|
||||
|
||||
virtual INT_PTR HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
INT_PTR OnInitDialog(WPARAM wParam, LPARAM lParam);
|
||||
INT_PTR OnNotify(WPARAM wParam, LPARAM lParam);
|
||||
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);
|
||||
|
||||
private:
|
||||
TabContents m_TabContents;
|
||||
|
||||
enum Id
|
||||
{
|
||||
Id_CloseButton = IDCLOSE
|
||||
Id_CancelButton = IDCANCEL,
|
||||
|
||||
Id_HeaderIcon = 100,
|
||||
Id_HeaderTitleLabel,
|
||||
Id_InstallButton,
|
||||
Id_Tab
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user