mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-12-02 22:28:14 +00:00
[idd] helper: prevent saving when no mode is selected
This commit is contained in:
@@ -110,6 +110,7 @@ LRESULT CConfigWindow::onCreate()
|
|||||||
m_modeRefresh.reset(new CEditWidget(WS_CHILD | WS_VISIBLE | ES_LEFT, m_hwnd));
|
m_modeRefresh.reset(new CEditWidget(WS_CHILD | WS_VISIBLE | ES_LEFT, m_hwnd));
|
||||||
|
|
||||||
m_modeUpdate.reset(new CButton(L"Save", WS_CHILD | WS_VISIBLE, m_hwnd));
|
m_modeUpdate.reset(new CButton(L"Save", WS_CHILD | WS_VISIBLE, m_hwnd));
|
||||||
|
EnableWindow(*m_modeUpdate, FALSE);
|
||||||
|
|
||||||
updateFont();
|
updateFont();
|
||||||
|
|
||||||
@@ -143,14 +144,25 @@ LRESULT CConfigWindow::onCommand(WORD id, WORD code, HWND hwnd)
|
|||||||
{
|
{
|
||||||
if (hwnd == *m_modeBox && code == LBN_SELCHANGE && m_modes)
|
if (hwnd == *m_modeBox && code == LBN_SELCHANGE && m_modes)
|
||||||
{
|
{
|
||||||
auto &mode = (*m_modes)[m_modeBox->getSelData()];
|
int sel = m_modeBox->getSel();
|
||||||
|
if (sel == LB_ERR)
|
||||||
|
{
|
||||||
|
EnableWindow(*m_modeUpdate, FALSE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto &mode = (*m_modes)[m_modeBox->getData(sel)];
|
||||||
m_modeWidth->setNumericValue(mode.width);
|
m_modeWidth->setNumericValue(mode.width);
|
||||||
m_modeHeight->setNumericValue(mode.height);
|
m_modeHeight->setNumericValue(mode.height);
|
||||||
m_modeRefresh->setNumericValue(mode.refresh);
|
m_modeRefresh->setNumericValue(mode.refresh);
|
||||||
|
EnableWindow(*m_modeUpdate, TRUE);
|
||||||
}
|
}
|
||||||
else if (hwnd == *m_modeUpdate && code == BN_CLICKED && m_modes)
|
else if (hwnd == *m_modeUpdate && code == BN_CLICKED && m_modes)
|
||||||
{
|
{
|
||||||
int sel = m_modeBox->getSel();
|
int sel = m_modeBox->getSel();
|
||||||
|
if (sel == LB_ERR)
|
||||||
|
return 0;
|
||||||
|
|
||||||
int index = m_modeBox->getData(sel);
|
int index = m_modeBox->getData(sel);
|
||||||
auto &mode = (*m_modes)[index];
|
auto &mode = (*m_modes)[index];
|
||||||
mode.width = m_modeWidth->getNumericValue();
|
mode.width = m_modeWidth->getNumericValue();
|
||||||
|
|||||||
@@ -40,11 +40,6 @@ int CListBox::getSel()
|
|||||||
return ListBox_GetCurSel(m_hwnd);
|
return ListBox_GetCurSel(m_hwnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CListBox::getSelData()
|
|
||||||
{
|
|
||||||
return getData(getSel());
|
|
||||||
}
|
|
||||||
|
|
||||||
int CListBox::getData(int index)
|
int CListBox::getData(int index)
|
||||||
{
|
{
|
||||||
return ListBox_GetItemData(m_hwnd, index);
|
return ListBox_GetItemData(m_hwnd, index);
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ public:
|
|||||||
int addItem(const std::wstring &display, LPARAM data);
|
int addItem(const std::wstring &display, LPARAM data);
|
||||||
void delItem(int index);
|
void delItem(int index);
|
||||||
int getSel();
|
int getSel();
|
||||||
int getSelData();
|
|
||||||
int getData(int index);
|
int getData(int index);
|
||||||
void setSel(int index);
|
void setSel(int index);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user