[idd] helper: detect mode listbox selection change

This commit is contained in:
Quantum
2025-10-04 03:01:27 -04:00
committed by Geoffrey McRae
parent e082acbe44
commit 1d7cb35de8
4 changed files with 24 additions and 0 deletions

View File

@@ -74,6 +74,8 @@ LRESULT CConfigWindow::handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
RedrawWindow(m_hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_ALLCHILDREN);
return 0;
}
case WM_COMMAND:
return onCommand(LOWORD(wParam), HIWORD(wParam), (HWND)lParam);
default:
return CWindow::handleMessage(uMsg, wParam, lParam);
}
@@ -113,3 +115,12 @@ LRESULT CConfigWindow::onResize(DWORD width, DWORD height)
pos.pinLeftTopBottom(*m_modeBox, 24, 64, 176, 24);
return 0;
}
LRESULT CConfigWindow::onCommand(WORD id, WORD code, HWND hwnd)
{
if (hwnd == *m_modeBox && code == LBN_SELCHANGE && m_modes)
{
DEBUG_INFO(L"Selection changed to: %s", (*m_modes)[m_modeBox->getSelData()].toString().c_str());
}
return 0;
}

View File

@@ -31,6 +31,7 @@ class CConfigWindow : public CWindow
virtual LRESULT onCreate() override;
virtual LRESULT onFinal() override;
LRESULT onResize(DWORD width, DWORD height);
LRESULT onCommand(WORD id, WORD code, HWND hwnd);
public:
CConfigWindow();

View File

@@ -28,3 +28,13 @@ int CListBox::addItem(const std::wstring &display, LPARAM data)
ListBox_SetItemData(m_hwnd, result, data);
return result;
}
int CListBox::getSel()
{
return ListBox_GetCurSel(m_hwnd);
}
int CListBox::getSelData()
{
return ListBox_GetItemData(m_hwnd, getSel());
}

View File

@@ -8,4 +8,6 @@ public:
CListBox(DWORD style, HWND parent);
void initStorage(DWORD count, size_t perItem);
int addItem(const std::wstring &display, LPARAM data);
int getSel();
int getSelData();
};