mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-01-18 17:52:30 +00:00
[idd] helper: add mode edit controls
This commit is contained in:
36
idd/LGIddHelper/CEditWidget.cpp
Normal file
36
idd/LGIddHelper/CEditWidget.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "CEditWidget.h"
|
||||
#include <commctrl.h>
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <CDebug.h>
|
||||
|
||||
CEditWidget::CEditWidget(DWORD style, HWND parent)
|
||||
{
|
||||
m_hwnd = createWindowSimple(WC_EDIT, nullptr, style, parent, WS_EX_CLIENTEDGE);
|
||||
if (!m_hwnd)
|
||||
DEBUG_ERROR_HR(GetLastError(), "Failed to create edit control");
|
||||
}
|
||||
|
||||
std::wstring CEditWidget::getValue()
|
||||
{
|
||||
std::wstring result;
|
||||
result.resize(Edit_GetTextLength(m_hwnd));
|
||||
Edit_GetText(m_hwnd, result.data(), result.size() + 1);
|
||||
return result;
|
||||
}
|
||||
|
||||
int CEditWidget::getNumericValue()
|
||||
{
|
||||
return std::stoi(getValue());
|
||||
}
|
||||
|
||||
void CEditWidget::setValue(const std::wstring &value)
|
||||
{
|
||||
if (!Edit_SetText(m_hwnd, value.c_str()))
|
||||
DEBUG_ERROR("Failed to update text for edit control");
|
||||
}
|
||||
|
||||
void CEditWidget::setNumericValue(int value)
|
||||
{
|
||||
setValue(std::to_wstring(value));
|
||||
}
|
||||
Reference in New Issue
Block a user