mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-11-17 07:28:44 +00:00
Some checks failed
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / module (push) Has been cancelled
build / host-linux (push) Has been cancelled
build / host-windows-cross (push) Has been cancelled
build / host-windows-native (push) Has been cancelled
build / idd (push) Has been cancelled
build / obs (clang) (push) Has been cancelled
build / obs (gcc) (push) Has been cancelled
build / docs (push) Has been cancelled
58 lines
1.2 KiB
C++
58 lines
1.2 KiB
C++
#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;
|
|
}
|
|
|
|
void CListBox::delItem(int index)
|
|
{
|
|
if (!ListBox_DeleteString(m_hwnd, index))
|
|
DEBUG_ERROR("listbox: failed to delete string at %d", index);
|
|
}
|
|
|
|
int CListBox::getSel()
|
|
{
|
|
return ListBox_GetCurSel(m_hwnd);
|
|
}
|
|
|
|
int CListBox::getData(int index)
|
|
{
|
|
return ListBox_GetItemData(m_hwnd, index);
|
|
}
|
|
|
|
void CListBox::setSel(int index)
|
|
{
|
|
if (!ListBox_SetCurSel(m_hwnd, index))
|
|
DEBUG_ERROR("listbox: failed to set selection to %d", index);
|
|
}
|
|
|
|
void CListBox::clear()
|
|
{
|
|
ListBox_ResetContent(m_hwnd);
|
|
}
|