mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-01-19 02:02:29 +00:00
[idd] helper: add CListBox widget
This commit is contained in:
30
idd/LGIddHelper/CListBox.cpp
Normal file
30
idd/LGIddHelper/CListBox.cpp
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#include "CListBox.h"
|
||||||
|
#include <commctrl.h>
|
||||||
|
#include <windows.h>
|
||||||
|
#include <windowsx.h>
|
||||||
|
#include <CDebug.h>
|
||||||
|
|
||||||
|
CListBox::CListBox(DWORD style, HWND parent)
|
||||||
|
{
|
||||||
|
m_hwnd = createWindowSimple(WC_LISTBOX, nullptr, style, parent, WS_EX_CLIENTEDGE);
|
||||||
|
if (!m_hwnd)
|
||||||
|
DEBUG_ERROR_HR(GetLastError(), "Failed to create listbox");
|
||||||
|
}
|
||||||
|
|
||||||
|
void CListBox::initStorage(DWORD count, size_t perItem)
|
||||||
|
{
|
||||||
|
SendMessage(m_hwnd, LB_INITSTORAGE, count, perItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CListBox::addItem(const std::wstring &display, LPARAM data)
|
||||||
|
{
|
||||||
|
int result = ListBox_AddString(m_hwnd, display.c_str());
|
||||||
|
if (result == LB_ERRSPACE)
|
||||||
|
{
|
||||||
|
DEBUG_ERROR(L"Out of memory while adding to listbox: %s", display.c_str());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ListBox_SetItemData(m_hwnd, result, data);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
11
idd/LGIddHelper/CListBox.h
Normal file
11
idd/LGIddHelper/CListBox.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "CWidget.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class CListBox : public CWidget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CListBox(DWORD style, HWND parent);
|
||||||
|
void initStorage(DWORD count, size_t perItem);
|
||||||
|
int addItem(const std::wstring &display, LPARAM data);
|
||||||
|
};
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#include "CWidget.h"
|
#include "CWidget.h"
|
||||||
|
|
||||||
HWND CWidget::createWindowSimple(LPCWSTR cls, LPCWSTR title, DWORD style, HWND parent)
|
HWND CWidget::createWindowSimple(LPCWSTR cls, LPCWSTR title, DWORD style, HWND parent, DWORD dwExStyle)
|
||||||
{
|
{
|
||||||
return CreateWindow(cls, title, style, 0, 0, 0, 0, parent,
|
return CreateWindowEx(dwExStyle, cls, title, style, 0, 0, 0, 0, parent,
|
||||||
NULL, (HINSTANCE)GetModuleHandle(NULL), NULL);
|
NULL, (HINSTANCE)GetModuleHandle(NULL), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class CWidget {
|
|||||||
protected:
|
protected:
|
||||||
HWND m_hwnd = NULL;
|
HWND m_hwnd = NULL;
|
||||||
|
|
||||||
HWND createWindowSimple(LPCWSTR cls, LPCWSTR title, DWORD style, HWND parent);
|
HWND createWindowSimple(LPCWSTR cls, LPCWSTR title, DWORD style, HWND parent, DWORD dwExStyle = 0);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~CWidget();
|
virtual ~CWidget();
|
||||||
|
|||||||
@@ -180,6 +180,7 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="$(SolutionDir)LGCommon\*.cpp" />
|
<ClCompile Include="$(SolutionDir)LGCommon\*.cpp" />
|
||||||
<ClCompile Include="CConfigWindow.cpp" />
|
<ClCompile Include="CConfigWindow.cpp" />
|
||||||
|
<ClCompile Include="CListBox.cpp" />
|
||||||
<ClCompile Include="CNotifyWindow.cpp" />
|
<ClCompile Include="CNotifyWindow.cpp" />
|
||||||
<ClCompile Include="CPipeClient.cpp" />
|
<ClCompile Include="CPipeClient.cpp" />
|
||||||
<ClCompile Include="CRegistrySettings.cpp" />
|
<ClCompile Include="CRegistrySettings.cpp" />
|
||||||
@@ -192,6 +193,7 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<CLInclude Include="$(SolutionDir)LGCommon\*.h" />
|
<CLInclude Include="$(SolutionDir)LGCommon\*.h" />
|
||||||
<ClInclude Include="CConfigWindow.h" />
|
<ClInclude Include="CConfigWindow.h" />
|
||||||
|
<ClInclude Include="CListBox.h" />
|
||||||
<ClInclude Include="CNotifyWindow.h" />
|
<ClInclude Include="CNotifyWindow.h" />
|
||||||
<ClInclude Include="CPipeClient.h" />
|
<ClInclude Include="CPipeClient.h" />
|
||||||
<ClInclude Include="CRegistrySettings.h" />
|
<ClInclude Include="CRegistrySettings.h" />
|
||||||
|
|||||||
@@ -43,6 +43,9 @@
|
|||||||
<ClCompile Include="CRegistrySettings.cpp">
|
<ClCompile Include="CRegistrySettings.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="CListBox.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="UIHelpers.cpp">
|
<ClCompile Include="UIHelpers.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@@ -79,6 +82,9 @@
|
|||||||
<ClInclude Include="CRegistrySettings.h">
|
<ClInclude Include="CRegistrySettings.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="CListBox.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
|
|||||||
Reference in New Issue
Block a user