-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListBox.cpp
More file actions
67 lines (52 loc) · 1.42 KB
/
ListBox.cpp
File metadata and controls
67 lines (52 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// ListBox.cpp: implementation of the ListBox class.
//
//////////////////////////////////////////////////////////////////////
#include "ListBox.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
ListBox::ListBox()
{
this->strControlClass = "LISTBOX";
}
ListBox::~ListBox()
{
}
DWORD ListBox::AddItem(LPTSTR item, UINT index, DWORD data)
{
UINT i = ::SendMessage(this->hWnd, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR)item);
::SendMessage(this->hWnd, LB_SETITEMDATA, (WPARAM)i, (LPARAM)data);
return i;
}
BOOL ListBox::RemoveItem(UINT index)
{
return ::SendMessage(this->hWnd, LB_DELETESTRING, (WPARAM)index, 0) != CB_ERR;
}
UINT ListBox::Count()
{
return ::SendMessage(this->hWnd, LB_GETCOUNT, 0, 0);
}
UINT ListBox::GetTextLength(UINT index)
{
return ::SendMessage(this->hWnd, LB_GETTEXTLEN, 0, 0);
}
BOOL ListBox::GetText(UINT index, LPTSTR text)
{
return ::SendMessage(this->hWnd, LB_GETTEXT, (WPARAM)index, (LPARAM)(LPCTSTR)text);
}
DWORD ListBox::GetData(UINT index)
{
return (DWORD)::SendMessage(this->hWnd, LB_GETITEMDATA, (WPARAM)index, 0);
}
UINT ListBox::GetSelectedIndex()
{
return ::SendMessage(this->hWnd, LB_GETCURSEL, 0, 0);
}
VOID ListBox::Clear()
{
::SendMessage(this->hWnd, LB_RESETCONTENT, 0, 0);
}
VOID ListBox::Select(UINT index)
{
::SendMessage(this->hWnd, LB_SETCURSEL, (WPARAM)index, 0);
}