Method descriptions

Buttons

Click GetBitmap GetImage GetState SetBitmap SetImage

Checkbox

GetCheck GetState GetStyle SetCheck SetState SetStyle

Combobox

AddString ClearSelection DeleteString FindString FindStringExact 

GetCount GetCurSel GetDroppedState GetDroppedWidth GetEditSel

GetEditSel GetItemHeight GetLBText GetLBTextLen GetTopIndex

InsertString LimitText ResetContent ShowDropDown SelectString

SetCurSel SetDroppedWidth SetEditSel SetItemHeight SetTopIndex

Edit control with only a single line

CanUndo CharFromPos ClearSelection EmptyUndoBuffer GetLimitText

GetMargins

Edit control with multiple lines

Listbox

AddString

Listview

Radiobuttons

Scrollbar

Tab control

Tree control


Buttons

Method Short description
void Click(void) This will simulate a click on the button.
HANDLE GetBitmap(void) Retrieves the handle of the bitmap associated with the button.  The return value is a handle to the image, if any; otherwise, it is NULL
HANDLE GetImage(int type) Retrieves the handle of the image associated with the button (bitmap or icon). The parameter should either IMAGE_BITMAP or IMAGE_ICON. Other values will provoke an undefined result.
int GetState(void) The return value specifies the current state of the button.  See button states
HANDLE SetBitmap(HANDLE) Sets a bitmap to a button. The return value is a handle to the image previously associated with the button, if any; otherwise, it is NULL
HANDLE SetImage(int type, HANDLE image) Sets a handle (of an image) to a button.The type parameter should either IMAGE_BITMAP or IMAGE_ICON. The return value is a handle to the image previously associated with the button, if any; otherwise, it is NULL

Checkbox

int GetCheck(void) Returns the check state of the button (checked or unchecked)
int GetState(void) Retrieves the state of the checkbox
DWORD GetStyle(void) Retrieves the style of the checkbox
int SetCheck(int state) Sets/unsets  the checked state. Returns always zero.
int SetState(int state) Sets the button state. Returns always zero.
int SetStyle(int style) Sets the style of the button window. Return always zero.

Combobox

int AddString(char *str) Adds a string to the combo box. If the combo box does not have the CBS_SORT style, the string is added to the end of the list. Otherwise, the string is inserted into the list, and the list is sorted.

The return value is the zero-based index to the string in the list box of the combo box. If an error occurs, the return value is CB_ERR. If insufficient space is available to store the new string, it is CB_ERRSPACE

void ClearSelection(void) Clears the selection if any.
int DeleteString(position) Deletes string at the given position, that must be a zero based index of the string to delete. The return value is a count of the strings remaining in the list. If the wParam parameter specifies an index greater than the number of items in the list, the return value is CB_ERR.
int FindString(int startAfter, char *pattern) Find the first line that matches the pattern.
startAfter
Specifies the zero-based index of the item preceding the first item to be searched. When the search reaches the bottom of the list box, it continues from the top of the list box back to the item specified by the startAfter parameter. If is –1, the entire list box is searched from the beginning.
pattern
Pointer to the null-terminated string that contains the characters for which to search. The search is not case sensitive, so this string can contain any combination of uppercase and lowercase letters.
The return value is the zero-based index of the matching item. If the search is unsuccessful, it is CB_ERR.
int FindStringExact(int startAfter, char *pattern) Find the first line that matches exactly the pattern.
startAfter
Specifies the zero-based index of the item preceding the first item to be searched. When the search reaches the bottom of the list box, it continues from the top of the list box back to the item specified by the startAfter parameter. If is –1, the entire list box is searched from the beginning.
pattern
Pointer to the null-terminated string that contains the characters for which to search. This string can contain any combination of uppercase and lowercase letters.
The return value is the zero-based index of the matching item. If the search is unsuccessful, it is CB_ERR.
int GetCount(void) Retrives the number of items in the combo box.
int GetCurSel(void) Retrieves the index of the current selection. If there is no selection, the returned value is CB_ERR.
int GetDroppedState(void) If the list box is visible, the return value is TRUE; otherwise, it is FALSE
int GetDroppedWidth(void) If the message succeeds, the return value is the width, in pixels. Otherwise the return value is FALSE.
unsigned int GetEditSel(int *pStart, int *pEnd) Retrieves the position of the selection.The return value is a zero-based DWORD value with the starting position of the selection in the low-order word and with the ending position of the first character after the last selected character in the high-order word.

Since this return value will go up to 65535 chars, the return values are stored in both pointers too.

int GetItemHeight(int index) Retrieves the height of an item.

The index argument specifies the combo box component whose height is to be retrieved. This parameter must be –1 to retrieve the height of the selection field. It must be zero to retrieve the height of list items, unless the combo box has the CBS_OWNERDRAWVARIABLE style. In that case, the wParam parameter is the zero-based index of a specific list item.

The return value is the height, in pixels, of the list items in a combo box. If the combo box has the CBS_OWNERDRAWVARIABLE style, it is the height of the item specified by the wParam parameter. If wParam is –1, the return value is the height of the edit control (or static-text) portion of the combo box. If an error occurs, the return value is CB_ERR

int GetLBText(int position,char *outbuf) Retrieves a string from the combo box at the given position. The data is copied to outbuf. It is assumed that the destination buffer is big enough to hold the data. You can query this length with the method GetLBTextLen.

The return value is the length of the string, in TCHARs, excluding the terminating null character. If wParam does not specify a valid index, the return value is CB_ERR.

int GetLBTextLen(int position) Retrieves the length of a string at a given position.

The return value is the length of the string, in TCHARs, excluding the terminating null character. If an ANSI string this is the number of bytes, and if it is a Unicode string this is the number of characters. Under certain conditions, this value may actually be greater than the length of the text.  This occurs with certain mixtures of ANSI and Unicode, and is due to the operating system allowing for the possible existence of double-byte character set (DBCS) characters within the text. The return value, however, will always be at least as large as the actual length of the text; so you can always use it to guide buffer allocation. This behavior can occur when an application uses both ANSI functions and common dialogs, which use Unicode.

If the position parameter does not specify a valid index, the return value is CB_ERR.

int GetTopIndex(void) Retrieves the index of the first visible line in the combo box.
int InsertString(int position, char *str) Inserts a string into the combo box at the given position. The combo box will not be sorted.
position
Specifies the zero-based index of the position at which to insert the string. If this parameter is –1, the string is added to the end of the list.
str
Pointer to the null-terminated string to be inserted. .

The return value is the index of the position at which the string was inserted. If an error occurs, the return value is CB_ERR. If there is insufficient space available to store the new string, it is CB_ERRSPACE.

If the combo box has WS_HSCROLL style and you insert a string wider than the combo box, you should send a LB_SETHORIZONTALEXTENT message to ensure the horizontal scrollbar appears.

int LimitText(int nchars) Sets the maximum number of chars that the control accepts. The nchars argument specifies the maximum number of characters the user can enter, not including the null terminator. If this parameter is zero, the text length is limited to 0x7FFFFFFE characters.

If the combo box does not have the CBS_AUTOHSCROLL style, setting the text limit to be larger than the size of the edit control has no effect. This method limits only the text the user can enter. It has no effect on any text already in the edit control when the message is sent, nor does it affect the length of the text copied to the edit control when a string in the list box is selected.

The default limit to the text a user can enter in the edit control is 30,000 characters.

The return value is always TRUE.

int ResetContent(void) Erases all strings from the combo box. Return value is always CB_OKAY.
int ShowDropDown(int bShow) Specifies if the combo box drop down list box is visible (bShow is TRUE) or hidden (bShow is FALSE). The return value is always TRUE.
int SelectString(int startAfter,char *line) Searches the list of a combo box for an item that begins with the characters in a specified string. If a matching item is found, it is selected and copied to the edit control.
startAfter
Specifies the zero-based index of the item preceding the first item to be searched. When the search reaches the bottom of the list, it continues from the top of the list back to the item specified by the wParam parameter. If wParam is –1, the entire list is searched from the beginning.
line
Pointer to the null-terminated string that contains the characters for which to search. The search is not case sensitive, so this string can contain any combination of uppercase and lowercase letters.

Return Value: if the string is found, the return value is the index of the selected item. If the search is unsuccessful, the return value is CB_ERR and the current selection is not changed.

int SetCurSel(int index) Sets the current line selection; The index parameter specifies the zero-based index of the string to select. If this parameter is –1, any current selection in the list is removed and the edit control is cleared.
int SetDroppedWidth(int width) Set the maximum allowable width, in pixels, of the list box of a combo box with the CBS_DROPDOWN or CBS_DROPDOWNLIST style. Returns the new width of the list box.if successful, CB_ERR otherwise.
int SetEditSel(int Start,int End) Selects characters in the edit control of a combo box. The Start parameter specifies the start of the selection. If this parameter is -1 the selection is removed. The End parameter specifies the position of the end of the selection. If this parameter is -1 all text from the start position to the end of the text will be selected.

Returns TRUE if successful.

int SetItemHeight(int index, int height) Sets the height of an item. The index parameter specifies the component of the combo box for which to set the height. This parameter must be –1 to set the height of the selection field. It must be zero to set the height of list items, unless the combo box has the CBS_OWNERDRAWVARIABLE style. In that case, the wParam parameter is the zero-based index of a specific list item.

The selection field height in a combo box is set independently of the height of the list items. An application must ensure that the height of the selection field is not smaller than the height of a particular list item. Returns CB_ERR if failure.

int SetTopIndex(int index) Retrieves the zero-based index of the first visible item in the list box portion of a combo box. Initially, the item with index 0 is at the top of the list box, but if the list box contents have been scrolled, another item may be at the top.

Edit control with only a single line

int CanUndo(void) If there are actions in the control's undo queue, the return value is nonzero.
If the undo queue is empty, the return value is zero.
int CharFromPos(POINT pt) Retrieves information about the character closest to a specified point in the client area of an edit control. The argument pt specifies the coordinates of a point in the control's client area. The coordinates are in screen units and are relative to the upper-left corner of the control's client area.

The low-order word specifies the zero-based index of the character nearest the specified point. This index is relative to the beginning of the control, not the beginning of the line. If the specified point is beyond the last character in the edit control, the return value indicates the last character in the control. The high-order word specifies the zero-based index of the line that contains the character. For single-line edit controls, this value is zero. The index indicates the line delimiter if the specified point is beyond the last visible character in a line

void ClearSelection(void) Clears the selection.
void EmptyUndoBuffer(void) Empties the undo buffer.
int GetLimitText(void) Retrieves the length of the maximum length of the text the control accepts
int GetMargins(int *pleft, int *pright) Retrives the borders of the selection.
GetModify(void) Returns non zero if the text has been modified, zero otherwise
GetPasswordChar(void) Returns the code of the password char.
GetRect(RECT *pRect) Retrieves the client area coordinates of a specified character in an edit control.
GetSel(void) Returns the index of the selection or CB_ERR if none exists.
PosFromChar(int index) Retrieves the position of a char
ReplaceSel(char *NewText,int bCanUndo) Replaces the current selection in an edit control with the specified text.
SetLimitText(int limit) Sets the maximum number of chars the control will accept.
SetMargins(int left,int right) Sets the widths of the left and right margins for an edit control. The message redraws the control to reflect the new margins.
SetModify(int bModified) Sets the state of the text to modified or not.
SetPasswordChar(int charCode) Sets the character that will be shown when the control is used as a password entry field.
SetReadOnly(int bReadOnly) Sets the control to read only or not.
SetSel(int start,int end,int bScroll) Sets the selection to the given limits. If bScroll is TRUE it scrolls the control
SetScrollCaret(void) Scrolls the caret into view if necessary
Undo(void) Undoes the last edit action.

Edit control with multiple lines

CanUndo(void) If there are actions in the control's undo queue, the return value is nonzero.
If the undo queue is empty, the return value is zero.
CharFromPos(POINT pt) Returns the index from a given position
ClearSelection(void) Clears the selection.
EmptyUndoBuffer() Empties the undo buffer.
FmtLines(void) Sets a flag that determines whether a multiline edit control includes soft line-break characters. A soft line break consists of two carriage returns and a line feed and is inserted at the end of a line that is broken because of wordwrapping.
GetFirstVisibleLine(void) Retrieves the index of the first visible line.
GetLimitText(void) Retrieves the length of the maximum length of the text the control accepts
GetLine(int Linenr,char *outbuf,int Nbmax) Retrieves a line from the control
GetLineCount(void) Returns the number of lines in the control
GetMargins(int *pleft, int *pright) Retrives the borders of the selection.
GetModify(void) Returns non zero if the text has been modified, zero otherwise
GetPasswordChar(void) Returns the code of the password char.
GetRect(RECT *pRect) Retrieves the client area coordinates of a specified character in an edit control.
GetSel(void) Returns the index of the selection or CB_ERR if none exists.
LineIndex(int lines,int chars) Retrieves the character index of the first character of a specified line in a multiline edit control. A character index is the zero-based index of the character from the beginning of the edit control
LineLength(int line) Retrieves the line length of the given line.
LineScroll(int line) Scrolls the text in a multiline edit control
PosFromChar(int index) Retrieves the position of a char
ReplaceSel(char *NewText,int bCanUndo) Replaces the current selection in an edit control with the specified text.
Scroll(void) Scrolls the text vertically in a multiline edit control.
SetLimitText(int limit) Sets the maximum number of chars the control will accept.
SetMargins(int left,int right) Sets the widths of the left and right margins for an edit control. The message redraws the control to reflect the new margins.
SetModify(int bModified) Sets the state of the text to modified or not.
SetPasswordChar(int charCode) Sets the character that will be shown when the control is used as a password entry field.
SetReadOnly(int bReadOnly) Sets the control to read only or not.
SetSel(int start,int end,int bScroll) Sets the selection to the given limits. If bScroll is TRUE it scrolls the control
SetScrollCaret(void) Scrolls the caret into view if necessary
SetTabsStops(int nTabs, int *TabArray) Sets the position of the tabulations.
Undo(void) Undoes the last edit action.

Listbox

AddString(char *str) Adds a string to a list box, sorting if the list box has the LBS_SORT style.
DeleteString(position) Deletes the string at the given position
FindString(int startAfter,char *pattern) Searches the listbox for a string that matches the given pattern
FindStringExact(int startAfter,char *pattern) Searches the listbox for a string that matcges exactly.
GetAnchorIndex(void) Retrieves the first index of a multiple selection.
GetCount(void) Retrieves the number of items in the listbox
GetCurSel(void) Retrieves the index of the current selection
GetCaretIndex(void) Retrieves the caret index of the current selection
GetHorizontalExtent(void) Retrieves from a list box the width, in pixels, by which the list box can be scrolled horizontally (the scrollable width) if the list box has a horizontal scroll bar.
GetItemHeight(int position) Retrieves the height of items in a list box.
GetItemRect(int index, RECT *prect) Retrieves the bounding rectangle for an item.
GetText(int position,char *outbuf) Retrieves the text of a line at the given position.
GetSel(void) Retrieves the selection of a list box.
GetTopIndex(void) Retrieves the index of the first visible item in a list box. Initially the item with index 0 is at the top of the list box, but if the list box contents have been scrolled another item may be at the top.
GetTextLen(int position) Retrieves the text length of a line in the list box
GetSelCount(void) Retrieves the number of items selected.
GetSelItems(int nbOfItems,int *items) Fills a buffer with an array of integers that specify the item numbers of selected items in a multiple-selection list box.
InsertString(int index ,char *str) Inserts the given string at the specified index position.
ItemFromPoint(POINT pt, int *bOutside) Retrieves the zero-based index of the item nearest the specified point in a list box.
SelectString(int startAfter, char *pattern) Searches a list box for an item that begins with the characters in a specified string. If a matching item is found, the item is selected. The search starts at the number given by the searchAfter parameter
SelItemRange(int bSelect,int first,int last) Selects or deselects one or more consecutive items in a multiple-selection list box.
SetAnchorIndex(int index) Sets the anchor item—that is, the item from which a multiple selection starts. A multiple selection spans all items from the anchor item to the caret item.
SetCaretIndex(int index) Sets the focus rectangle to the item at the specified index in a multiple-selection list box. If the item is not visible, it is scrolled into view.
SetColumnWidth(int Width) Sets the width, in pixels, of all columns in the list box.
SetHorizontalExtent(int cExtent) Sets the width, in pixels, by which a list box can be scrolled horizontally (the scrollable width). If the width of the list box is smaller than this value, the horizontal scroll bar horizontally scrolls items in the list box. If the width of the list box is equal to or greater than this value, the horizontal scroll bar is hidden.
SetItemHeight(int position, int height) Sets the height, in pixels, of items in a list box. If the list box has the LBS_OWNERDRAWVARIABLE style, this message sets the height of the item specified by the wParam parameter. Otherwise, this message sets the height of all items in the list box.
SetSel(int position, int bSelect) Sets the selection to the specified index
SetTabStops(int nTabs,int *array) Sets the tab stops positions in a list box.
SetTopIndex(int position) Set the position of the first line visible in a list box, scrolling if necessary to bring it into view.
ResetContent(void) Clears the list box from all strings

Listview

int Arrange(int code)
Arranges items in icon view.
code
Alignment. This can be one of the following values:
LVA_ALIGNLEFT
Aligns items along the left edge of the window.
LVA_ALIGNTOP
Aligns items along the top edge of the window.
LVA_DEFAULT
Aligns items according to the list-view control's current alignment styles (the default value).
LVA_SNAPTOGRID
Snaps all icons to the nearest grid position.

Returns TRUE if successful, or FALSE otherwise.

int DeleteAllItems(void) Removes all items from a list-view control. Returns TRUE if successful, or FALSE otherwise.
int DeleteColumn(int iColumn) Removes a column from a list-view control. Returns TRUE if successful, or FALSE otherwise. iColumn is the index of the column to delete.
int DeleteItem(int iItem) Removes an item from a list-view control. The iItem parameter is the index of the list view item to delete.Returns TRUE if successful, or FALSE otherwise. 
   

Radiobuttons

GetCheck(void) Returns the state of the button (checked or unchecked)
GetState(void) Retrieves the state of the checkbox
GetStyle(void) Retrieves the style of the checkbox
SetCheck(int bChecked) Sets/unsets  the checked state.
SetState(int state) Sets the button state
SetStyle(int style) Sets the style of the button window

Scrollbar

EnableScrollbar(int arrowState) Enables or disables one or both scroll bar arrows
EnableArrows(void) Enables the arrows of the scroll bar.
GetInfo(SCROLLINFO *lpsi) Retrieves the parameters of a scroll bar, including the minimum and maximum scrolling positions, the page size, and the position of the scroll box (thumb).
GetPos(void) Retrieves the position of the thumb.
GetRange(int *pMin,int *pmax) Retrieves the current minimum and maximum scroll box (thumb) positions for the specified scroll bar.
SetInfo(SCROLLINFO *lpsi,int bRedraw) Sets the parameters of a scroll bar, including the minimum and maximum scrolling positions, the page size, and the position of the scroll box (thumb). The function also redraws the scroll bar, if requested
SetPos(int pos,int bRedraw) Sets the position of the thumb.
SetRange(int min,int max,int bRedraw) Sets the range of the scrollbar
ShowScrollBar(int bShow) Shows or hides the scroll bar.

Tab Control

int AdjustRect(int fLarger,RECT *lpRect) Calculates a tab control's display area given a window rectangle, or calculates the window rectangle that would correspond to a specified display area.
fLarger
Operation to perform. If this parameter is TRUE, lpRect specifies a display rectangle and receives the corresponding window rectangle. If this parameter is FALSE, lpRect specifies a window rectangle and receives the corresponding display area.
Returns TRUE if sucessfull, zero otherwise.
int DeleteAllItems(void) Removes all items from a tab control.
int DeleteItem(int item) Removes an item from a tab control. The item parameter is the index of the item to delete. Returns TRUE if sucessfull, zero otherwise.
GetCurFocus(void) Returns the index of the item that has the focus in a tab control.
GetCurSel(void) Returns the index the currently selected tab in a tab control.
HANDLE GetImageList(void) Retrieves the image list associated with a tab control.
int GetItem(int item,TC_ITEM *Itemdata) Retrieves information about a tab in a tab control.
item
Index of the tab.
itemdata
Pointer to a TCITEM structure that specifies the information to retrieve and receives information about the tab. When the message is sent, the mask member specifies which attributes to return. If the mask member specifies the TCIF_TEXT value, the pszText member must contain the address of the buffer that receives the item text, and the cchTextMax member must specify the size of the buffer.
Returns TRUE if successful, or FALSE otherwise.

If the TCIF_TEXT flag is set in the mask member of the TCITEM structure, the control may change the pszText member of the structure to point to the new text instead of filling the buffer with the requested text. The control may set the pszText member to NULL to indicate that no text is associated with the item.

int GetItemCount(void) Returns the number of items if successful, or zero otherwise.
int GetItemRect(int item, RECT *lpRect) Retrieves the bounding rectangle for a tab in a tab control.
int GetRowCount(void) Retrieves the current number of rows of tabs in a tab control
int GetToolTips(void) Retrieves the handle to the ToolTip control associated with a tab control
int HitTest(TCHTTESTINFO *info) Determines which tab, if any, is at a specified screen position. For information about the info parameter see TCHITTESTINFO.
int InsertItem(int item, TC_ITEM *itmeinfo) Inserts a new tab in a tab control.
int RemoveImage(int image) Removes an image from a tab control's image list
SetCurFocus(int item) Set current focus
SetCurSel(int item) Sets the current selection
SetImageList(HIMAGELIST imglist) Assigns an image list to a tab control
SetItem(inbt item,TC_ITEM *itemData) Modifies an item.
SetItemExtra(int nBytes) Sets the number of bytes per tab reserved for application-defined data in a tab control.
SetItemSize(int cx,int cy) Sets the width and height of tabs in a fixed-width or owner-drawn tab control
SetPadding(int cx,int cy) Sets the amount of space (padding) around each tab's icon and label in a tab control
SetToolTips(HWND hwndTT) Assigns a ToolTip control to a tab control

Tree control

CreateDragImage(HTREEITEM item) Creates a dragging bitmap for the specified item in a tree-view control. The message also creates an image list for the bitmap and adds the bitmap to the image list. An application can display the image when dragging the item by using the image list functions

Returns the handle to the image list to which the dragging bitmap was added if successful, or NULL otherwise.

int DeleteAllItems(void) Deletes all items in the tree control.
int DeleteItem(HTREEITEM item) Deletes an item.

Once an item is deleted, its handle is invalid and cannot be used. The parent window receives a TVN_DELETEITEM notification message when each item is removed.

If the item label is being edited, the edit operation is canceled and the parent window receives the TVN_ENDLABELEDIT notification message.

HWND EditLabel(HTREEITEM item) Begins in-place editing of the specified item's text, replacing the text of the item with a single-line edit control containing the text. This message implicitly selects and focuses the specified item.

Return Value: Returns the handle to the edit control used to edit the item text if successful, or NULL otherwise. 

This method sends a TVN_BEGINLABELEDIT notification message to the parent of the tree-view control. When the user completes or cancels editing, the edit control is destroyed and the handle is no longer valid. You can subclass the edit control, but do not destroy it. The control must have the focus before you send this message to the control. Focus can be set using the SetFocus function.

int EndEditLabelNow(int bCancel) Ends the editing of a tree-view item's label. 

bCancel is a variable that indicates whether the editing is canceled without being saved to the label. If this parameter is TRUE, the system cancels editing without saving the changes. Otherwise, the system saves the changes to the label.

Return Value

Returns TRUE if successful, or FALSE otherwise
int EnsureVisible(HTREEITEM item) Ensures that a tree-view item is visible, expanding the parent item or scrolling the tree-view control, if necessary.

Return Value:  nonzero if the system scrolled the items in the tree-view control and no items were expanded. Otherwise, the return value is zero.

int Expand(HTREEITEM item, int Action) Expands an item.
Action
Can be one or more of the following values:
TVE_COLLAPSE
Collapses the list.
TVE_COLLAPSERESET
Collapses the list and removes the child items. The TVIS_EXPANDEDONCE state flag is reset. This flag must be used with the TVE_COLLAPSE flag.
TVE_EXPAND
Expands the list.
TVE_EXPANDPARTIAL
Partially expands the list. In this state the child items are visible and the parent item's plus sign (+), indicating that it can be expanded, is displayed. This flag must be used in combination with the TVE_EXPAND flag.
TVE_TOGGLE
Collapses the list if it is expanded or expands it if it is collapsed.
item
Handle to the parent item to expand or collapse.
 
Returns nonzero if the operation was successful, or zero otherwise
HWND EditLabel(HTREEITEM item) Begins in-place editing of the specified item's text, replacing the text of the item with a single-line edit control containing the text. This message implicitly selects and focuses the specified item.

Returns the handle to the edit control used to edit the item text if successful, or NULL otherwise

HTREEITEM GetChild(HITEM item) Retrieves the tree-view item that is the child of the specified item or NULL if no such an item exists.

 

int GetCount(void) Retrieves a count of the items in a tree-view control.
HTREEITEM GetDropHilite(void) Retrieves the item that is the target of a drag-and-drop operation. Returns NULL if no such an item exists.
HWND GetEditControl(void) Retrieves the handle to the edit control being used to edit a tree-view item's text.

When label editing begins, an edit control is created, but not positioned or displayed. Before it is displayed, the tree-view control sends its parent window an TVN_BEGINLABELEDIT notification message.

To customize label editing, implement a handler for TVN_BEGINLABELEDIT and have it send a TVM_GETEDITCONTROL message to the tree-view control. If a label is being edited, the return value will be a handle to the edit control. Use this handle to customize the edit control by sending the usual EM_XXX messages

HTREEITEM GetFirstVisibleItem(void) Retrieves the first item that is visible in the tree-view window.
HIMAGELIST GetImageList(int type) Retrieves the handle to the normal or state image list associated with a tree-view control.
type
Type of image list to retrieve. This parameter can be one of the following values:
TVSIL_NORMAL
Indicates the normal image list, which contains selected, nonselected, and overlay images for the items of a tree-view control.
TVSIL_STATE
Indicates the state image list. You can use state images to indicate application-defined item states. A state image is displayed to the left of an item's selected or nonselected image.
int GetIndent(void) Returns the amount of indentation
int GetISearchString(char *outbuf) Retrieves the incremental search string for a tree-view control. The tree-view control uses the incremental search string to select an item based on characters typed by the user. The result will be stored in the given buffer. Returns the number of characters in the incremental search string.
int GetItem(TV_ITEM *pItem) Retrieves some or all of a tree-view item's attributes.
pitem
Pointer to a TVITEM structure that specifies the information to retrieve and receives information about the item. With version 4.71 and later, you can use a TVITEMEX structure instead.
Returns TRUE if successful, or FALSE otherwise.
int GetItemRect(HTREEITEM hItem, RECT *pRect, int bTextOnly) Retrieves the bounding rectangle for a tree-view item and indicates whether the item is visible.
bTextOnly
Value specifying the portion of the item for which to retrieve the bounding rectangle. If this parameter is TRUE, the bounding rectangle includes only the text of the item. Otherwise, it includes the entire line that the item occupies in the tree-view control.
pRect
Pointer to a RECT structure that, when sending the message, contains the handle of the item to retrieve the rectangle for.  The coordinates are relative to the upper-left corner of the tree-view control.

Return Value

If the item is visible and the bounding rectangle was successfully retrieved, the return value is TRUE. Otherwise, the message returns FALSE and does not retrieve the bounding rectangle.
int GetItemState(HTREEITEM hItem,int mask) Retrieves some or all of a tree-view item's state attributes.
hItem
Handle to the item.
mask
Mask used to specify the states to query for.
Array of flags that indicate which of the other structure members contain valid data. When this structure is used with the TVM_GETITEM message, the mask member indicates the item attributes to retrieve. This member can be one or more of the following values.
TVIF_CHILDREN
The cChildren member is valid.
TVIF_DI_SETITEM
The tree-view control will retain the supplied information and will not request it again. This flag is valid only when processing the TVN_GETDISPINFO notification.
TVIF_HANDLE
The hItem member is valid.
TVIF_IMAGE
The iImage member is valid.
TVIF_INTEGRAL
The iIntegral member is valid.
TVIF_PARAM
The lParam member is valid.
TVIF_SELECTEDIMAGE
The iSelectedImage member is valid.
TVIF_STATE
The state and stateMask members are valid.
TVIF_TEXT
The pszText and cchTextMax members are valid.

Return Value: returns a UINT value with the appropriate state bits set to TRUE. Only those bits that are are specified by stateMask and that are TRUE will be set. This value is equivalent to the state member of TVITEMEX

int GetItemText(HTREEITEM hItem, char *outbuf, int nbChar) Retrieves the text associated with an item, storing the data in outbuf. The maximum number of characters that outbuf can hold is given in the nbChar parameter.
HTREEITEM GetNextItem(HTREEITEM hItem, int flag) Retrieves the next sibling item of the given item. Returns a handle to it or NULL if there isn't any. 

Flag is a parameter specifying the item to retrieve. This parameter can be one of the following values:

TVGN_CARET
Retrieves the currently selected item. You can use the TreeView_GetSelection macro to send this message.
TVGN_CHILD
Retrieves the first child item of the item specified by the hitem parameter. You can use the TreeView_GetChild macro to send this message.
TVGN_DROPHILITE
Retrieves the item that is the target of a drag-and-drop operation. You can use the TreeView_GetDropHilight macro to send this message.
TVGN_FIRSTVISIBLE
Retrieves the first item that is visible in the tree-view window. You can use the TreeView_GetFirstVisible macro to send this message.
TVGN_LASTVISIBLE
Version 4.71 . Retrieves the last expanded item in the tree. This does not retrieve the last item visible in the tree-view window. You can use the TreeView_GetLastVisible macro to send this message.
TVGN_NEXT
Retrieves the next sibling item. You can use the TreeView_GetNextSibling macro to send this message.
TVGN_NEXTVISIBLE
Retrieves the next visible item that follows the specified item. The specified item must be visible. Use the TVM_GETITEMRECT message to determine whether an item is visible. You can use the TreeView_GetNextVisible macro to send this message.
TVGN_PARENT
Retrieves the parent of the specified item. You can use the TreeView_GetParent macro to send this message.
TVGN_PREVIOUS
Retrieves the previous sibling item. You can use the TreeView_GetPrevSibling macro to send this message.
TVGN_PREVIOUSVISIBLE
Retrieves the first visible item that precedes the specified item. The specified item must be visible. Use the TVM_GETITEMRECT message to determine whether an item is visible. You can use the TreeView_GetPrevVisible macro to send this message.
TVGN_ROOT
Retrieves the topmost or very first item of the tree-view control. You can use the TreeView_GetRoot macro to send this message.
HTREEITEM GetNextSibling(HTREEITEM item) Retrieves the next sibling of the given item. Returns its handle or NULL if none exists.
HTREEITEM GetNextVisible(HTREEITEM item) Retrieves the next visible item.
HTREEITEM GetParent(HTREEITEM item) Retrieves the parent item.
HTREEITEM GetPrevSibling(HTREEITEM item) Retrieves the previous sibling
HTREEITEM GetPrevVisible(HTREEITEM item) Retrieves the previous visible item.
HTREEITEM GetRoot(void) Retrieves the root item.
HTREEITEM GetSelected(void) Retrieves the currently selected item
int GetVisibleCount(void) Retrieves the number of visible items.
int HasChildren(HTREEITEM hItem) Returns TRUE if the given item has children, zero otherwise.
HTREEITEM HitTest(TV_HITTESTINFO *pInfo) Determines the location of the specified point relative to the client area of a tree-view control. See TVHITTESTINFO for info about this structure.
HTREEITEM InsertItem( TV_INSERTSTRUCT *pInsItem) Inserts a new item in a tree-view control. Returns the handle to the new item if successful, or NULL otherwise. For a description of the argument see the TV_INSERTSTRUCT description.
int Select(HTREEITEM hItem,int flag)
Selects the specified tree-view item, scrolls the item into view, or redraws the item in the style used to indicate the target of a drag-and-drop operation.
flag
This parameter can be one of the following values:
TVGN_CARET
Sets the selection to the specified item. The tree-view control's parent window receives the TVN_SELCHANGING and TVN_SELCHANGED notification messages.
TVGN_DROPHILITE
Redraws the specified item in the style used to indicate the target of a drag-and-drop operation.
TVGN_FIRSTVISIBLE
Ensures that the specified item is visible, and, if possible, displays it at the top of the control's window. Tree-view controls display as many items as will fit in the window. If the specified item is near the bottom of the control's hierarchy of items, it might not become the first visible item, depending on how many items fit in the window.
hitem
Handle to an item. If hitem is NULL, the control is set to have no selected item.
Returns TRUE if successful, or FALSE otherwise.
int SelectDropTarget(HTREEITEM hItem) Redraws the specified item in the style used to indicate the target of a drag-and-drop operation.

Returns TRUE if successful, or FALSE otherwise.

int SelectItem(HTREEITEM hItem) Sets the selection to the specified item. The tree-view control's parent window receives the TVN_SELCHANGING and TVN_SELCHANGED notification messages.

Returns TRUE if successful, or FALSE otherwise.

int SelectFirstVisible(HTREEITEM hItem) Ensures that the specified item is visible, and, if possible, displays it at the top of the control's window. Tree-view controls display as many items as will fit in the window. If the specified item is near the bottom of the control's hierarchy of items, it might not become the first visible item, depending on how many items fit in the window.

Returns TRUE if successful, or FALSE otherwise.

void SetImageList(HIMAGELIST Image, int Type) Sets the normal or state image list for a tree-view control and redraws the control using the new images.
Type
Type of image list to set. This parameter can be one of the following values:
TVSIL_NORMAL
Indicates the normal image list, which contains selected, nonselected, and overlay images for the items of a tree-view control.
TVSIL_STATE
Indicates the state image list. You can use state images to indicate application-defined item states. A state image is displayed to the left of an item's selected or nonselected image.
Image
Handle to the image list. If it is NULL, the message removes the specified image list from the tree-view control
int SetItem(TV_ITEM *pItem) Sets some or all of a tree-view item's attributes. Returns TRUE if successful, or FALSE otherwise.
int SetItemState(HTREEITEM hItem, int state, int mask) Sets the state of an item. The mask argument is described here. The state argument can have the following values:
TVIS_BOLD The item is bold
TVIS_CUT The item is selected as part of a cut-and-paste operation.
TVIS_DROPHILITED The item is selected as a drag-and-drop target.
TVIS_EXPANDED The item's list of child items is currently expanded; that is, the child items are visible. This value applies only to parent items.
TVIS_EXPANDEDONCE The item's list of child items has been expanded at least once. The TVN_ITEMEXPANDING and TVN_ITEMEXPANDED notification messages are not generated for parent items that have this state set in response to a TVM_EXPAND message. Using TVE_COLLAPSE and TVE_COLLAPSERESET with TVM_EXPAND will cause this state to be reset. This value applies only to parent items.
TVIS_EXPANDPARTIAL A partially expanded tree-view item. In this state, some, but not all, of the child items are visible and the parent item's plus symbol is displayed.
TVIS_SELECTED The item is selected. Its appearance depends on whether it has the focus. The item will be drawn using the system colors for selection.
Note: 
When you set or retrieve an item's overlay image index or state image index, you must specify the following masks in the stateMask member of the TVITEM structure. These values can also be used to mask off the state bits that are not of interest.
TVIS_OVERLAYMASK 
Mask for the bits used to specify the item's overlay image index.
TVIS_STATEIMAGEMASK 
Mask for the bits used to specify the item's state image index.
int SetItemText(HTREEITEM hItem, char *text) Sets the text of an item. Returns TRUE if successful, zero otherwise.

 


Button states

Value Meaning
0x0003 Specifies the check state (radio buttons and check boxes only). A value of BST_UNCHECKED indicates the button is cleared; a value of BST_CHECKED indicates the button is checked. A radio button is checked when it contains a dot; a check box is checked when it contains an X. A value of BST_INDETERMINATE indicates the check state is indeterminate (applies only if the button has the BS_3STATE or BS_AUTO3STATE style). A three-state check box is grayed when its state is indeterminate.
BST_CHECKED Indicates the button is checked.
BST_FOCUS Specifies the focus state. A nonzero value indicates that the button has the keyboard focus.
BST_INDETERMINATE Indicates the button is grayed because the state of the button is indeterminate. This value applies only if the button has the BS_3STATE or BS_AUTO3STATE style.
BST_PUSHED Specifies the highlight state. A nonzero value indicates that the button is highlighted. A button is automatically highlighted when the user positions the cursor over it and presses and holds the left mouse button. The highlighting is removed when the user releases the mouse button.
BST_UNCHECKED Indicates the button is cleared. Same as a return value of zero.

 

TVINSERTSTRUCT Structure

Contains information used to add a new item to a tree-view control. This structure is used with the TVM_INSERTITEM message. The structure is identical to the TV_INSERTSTRUCT structure, but it has been renamed to follow current naming conventions.

Syntax

typedef struct tagTVINSERTSTRUCT {
    HTREEITEM hParent;
    HTREEITEM hInsertAfter;
    union
    {
        TVITEMEX itemex;
        TVITEM item;
    } ;
} TVINSERTSTRUCT, *LPTVINSERTSTRUCT;

Members

hParent
Handle to the parent item. If this member is the TVI_ROOT value or NULL, the item is inserted at the root of the tree-view control.
hInsertAfter
Handle to the item after which the new item is to be inserted, or one of the following values:
TVI_FIRST
Inserts the item at the beginning of the list.
TVI_LAST
Inserts the item at the end of the list.
TVI_ROOT
Add the item as a root item.
TVI_SORT
Inserts the item into the list in alphabetical order.
itemex
TVITEMEX structure that contains information about the item to add.
item
TVITEM structure that contains information about the item to add

TCHITTESTINFO Structure

Contains information about a hit test.

typedef struct tagTCHITTESTINFO {
    POINT pt;
    UINT flags;
} TCHITTESTINFO, *LPTCHITTESTINFO;

Members

pt
Position to hit test, in client coordinates.
flags
Variable that receives the results of a hit test. The tab control sets this member to one of the following values:
TCHT_NOWHERE
The position is not over a tab.
TCHT_ONITEM
The position is over a tab but not over its icon or its text. For owner-drawn tab controls, this value is specified if the position is anywhere over a tab.
TCHT_ONITEMICON
The position is over a tab's icon.
TCHT_ONITEMLABEL
The position is over a tab's text.
 
TCHT_ONITEM is a bitwise-OR operation on TCHT_ONITEMICON and TCHT_ONITEMLABEL.

TVHITTESTINFO Structure

Contains information used to determine the location of a point relative to a tree-view control. This structure is used with the TVM_HITTEST message. The structure is identical to the TV_HITTESTINFO structure, but it has been renamed to follow current naming conventions.

typedef struct tagTVHITTESTINFO {
    POINT pt;
    UINT flags;
    HTREEITEM hItem;
} TVHITTESTINFO, *LPTVHITTESTINFO;

Members

pt
Client coordinates of the point to test.
flags
Variable that receives information about the results of a hit test. This member can be one or more of the following values:
TVHT_ABOVE
Above the client area.
TVHT_BELOW
Below the client area.
TVHT_NOWHERE
In the client area, but below the last item.
TVHT_ONITEM
On the bitmap or label associated with an item.
TVHT_ONITEMBUTTON
On the button associated with an item.
TVHT_ONITEMICON
On the bitmap associated with an item.
TVHT_ONITEMINDENT
In the indentation associated with an item.
TVHT_ONITEMLABEL
On the label (string) associated with an item.
TVHT_ONITEMRIGHT
In the area to the right of an item.
TVHT_ONITEMSTATEICON
On the state icon for a tree-view item that is in a user-defined state.
TVHT_TOLEFT
To the left of the client area.
TVHT_TORIGHT
To the right of the client area.
hItem
Handle to the item that occupies the point.