Easy Win 32
List Box Class – cEasyListBox
cEasyListBox Public Members:
HWND listbox;
cEasyListBox Functions:
Functions to modify and/or setup the ListBox (HWND listbox):
int ChangeListBoxInstance(HINSTANCE)
int ChangeListBoxParent(HWND)
int ChangeListBoxMenu(HMENU
hmenu)
int ChangeListBoxPos(int x1, int y1, int w1, int h1)
int ChangeListBoxStyles(DWORD
dwstyle,DWORD dwexstyle)
int ChangeListBoxName(LPCTSTR
name)
As a general rule
this functions return 1 on success, 0 on error.
After created functions (They
help to handle the Edit Control):
DWORD GetSelectedItem() à Tested Function
DWORD GetSelectedItems(INT MaxArrayItem, LPINT SelectedItemsArray) à Untested
Function
If the ListBox is of the type Multiple Selection please use GetSelectedItems.
GetSelectedItem returns the Zero-based index of the User
Selected Item.
GetSelectedItems copies as much as MaxArrayItem
selected items into the SelectedItemsArray.
int SetSelectedItem(INT
index)
BOOL GetItemState(INT index)
Returns
the
int SetItemState(BOOL
selected, INT index)
INT NumberofItems()
Returns
the Number of Items of the List Box.
DWORD GetItemData(INT index)
Returns the Data
associated with the Index Item.
INT SetItemData(INT index,DWORD data)
Associated
the data with the index Item.
INT FindItem(LPCTSTR name)
Finds
the Zero-Based Index of the Item matching the name.
void ResetContent()
Deletes all items of the ListBox.
int AddItem(LPCTSTR name,DWORD data)
Adds
an Item to the List Box, and associates data
with it.
int DeleteItem(LPCTSTR
name)
Deletes
the Item that matches the name.
As a general rule, the functions
with Set (Example: SetItemState(…)), return 1 on success, 0 on error.
Other Functions:
void InitListBox()
Initializes the Edit Control
Class with these values:
lpWindowName="ListBox";
dwStyle=0;
x=10;
y=10;
nWidth=300;
nHeight=300;
hWndParent=NULL;
hMenu=NULL;
hInst1=programInstance;
_listcreated_=FALSE;
HWND
Create_ListBox(HWND AuxiliarWindow)
On success it returns the handle of
the list box (you don’t have to store it, it is
already stored in the public class member “listbox”).
On error it return NULL.
int Destroy_ListBox()
Destroys the ListBox. On error
returns 0, else non-zero.
LONG
GetListboxId()
HWND
GetListboxParent()
DWORD
GetListboxExStyle()
DWORD
GetListboxStyle()
HINSTANCE
GetListBoxInstance()
Returns a List Box
Property according to the name of the Function.
BOOL
Is_Enabled()
void Disable_ListBox()
void Enable_Button()
cEasyListBox Private Members:
DWORD dwExStyle; // extended window style
LPCTSTR lpWindowName; // pointer to window name
DWORD dwStyle; // window style
int x; //
horizontal position of window
int y; //
vertical position of window
int nWidth; // window width
int nHeight; // window height
HWND hWndParent; // handle to parent or owner window
HMENU hMenu; // handle to menu or child-window
identifier
HANDLE hInst1; // handle to application instance
BOOL _listcreated_;