diff --git a/idd/LGIddHelper/CConfigWindow.cpp b/idd/LGIddHelper/CConfigWindow.cpp index 8e20331c..c8b7f9fe 100644 --- a/idd/LGIddHelper/CConfigWindow.cpp +++ b/idd/LGIddHelper/CConfigWindow.cpp @@ -1,4 +1,5 @@ #include "CConfigWindow.h" +#include "CListBox.h" #include #include #include @@ -20,16 +21,18 @@ bool CConfigWindow::registerClass() CConfigWindow::CConfigWindow() : m_scale(1) { + LSTATUS error = m_settings.open(); + if (error != ERROR_SUCCESS) + DEBUG_ERROR_HR(error, "Failed to load settings"); + else + m_modes = m_settings.getModes(); + if (!CreateWindowEx(0, MAKEINTATOM(s_atom), L"Looking Glass IDD Configuration", WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, 500, 400, NULL, NULL, hInstance, this)) { DEBUG_ERROR_HR(GetLastError(), "Failed to create window"); } - - m_scale = GetDpiForWindow(m_hwnd) / 96.0; - m_version.reset(new CStaticWidget(L"Looking Glass IDD " LG_VERSION_STR, WS_CHILD | WS_VISIBLE | SS_CENTERIMAGE, m_hwnd)); - updateFont(); } void CConfigWindow::updateFont() @@ -49,7 +52,7 @@ void CConfigWindow::updateFont() return; } - for (HWND child : std::initializer_list({ *m_version })) + for (HWND child : std::initializer_list({ *m_version, *m_modeBox })) SendMessage(child, WM_SETFONT, (WPARAM)m_font.Get(), 1); } @@ -77,6 +80,18 @@ LRESULT CConfigWindow::handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) LRESULT CConfigWindow::onCreate() { + m_scale = GetDpiForWindow(m_hwnd) / 96.0; + m_version.reset(new CStaticWidget(L"Looking Glass IDD " LG_VERSION_STR, WS_CHILD | WS_VISIBLE | SS_CENTERIMAGE, m_hwnd)); + + m_modeBox.reset(new CListBox(WS_CHILD | WS_VISIBLE | LBS_NOTIFY, m_hwnd)); + if (m_modes) + { + auto &modes = *m_modes; + for (size_t i = 0; i < modes.size(); ++i) + m_modeBox->addItem(modes[i].toString(), i); + } + updateFont(); + return 0; } @@ -91,5 +106,6 @@ LRESULT CConfigWindow::onResize(DWORD width, DWORD height) { WidgetPositioner pos(m_scale, width, height); pos.pinTopLeftRight(*m_version, 12, 12, 12, 20); + pos.pinLeftTopBottom(*m_modeBox, 12, 40, 200, 12); return 0; } diff --git a/idd/LGIddHelper/CConfigWindow.h b/idd/LGIddHelper/CConfigWindow.h index b25cdb2b..598b800e 100644 --- a/idd/LGIddHelper/CConfigWindow.h +++ b/idd/LGIddHelper/CConfigWindow.h @@ -1,20 +1,27 @@ #pragma once #include "CWindow.h" #include "CStaticWidget.h" +#include "CRegistrySettings.h" #include #include +#include #include #include "UIHelpers.h" +class CListBox; + class CConfigWindow : public CWindow { static ATOM s_atom; std::unique_ptr m_version; + std::unique_ptr m_modeBox; std::function m_onDestroy; double m_scale; Microsoft::WRL::Wrappers::HandleT m_font; + CRegistrySettings m_settings; + std::optional> m_modes; void updateFont();