<<

Clasa CComboBox

Combo box-ul (CB) contine un control de editare single linie si un control . Combo box- urile pot avea stilurile simple ( CBS_SIMPLE ), drop-down ( CBS_DROPDOWN ) si drop-down list ( CBS_DROPDOWNLIST ).

Un CB simplu afiseaza in permanenta lista articolelor pe care le contine. Cind articolul este selectat din lista acesta este copiat in CE. Utilizatorul poate tasta text direct in CE al CB. Daca textul din CE al CB se potriveste cu un articol din list box (LB), articolul este afisat automat pe video invers iar asupra LB se fac operatii de navigare verticala (scroll). CE al CB este de fapt un obiect CEdit.

Un CB drop-down, difera de un CB simplu prin aceea ca LB asociat este afisat numai la cerere.

Un CB drop-down list lucreaza la fel ca un CB drop-down cu diferenta ca nu se permite editarea in CE al CB.

Stilul CB se completeaza ca un parametru in functia Create sau CreateEx . Alte stiluri care pot fi date controleaza aspectul CB si comportarea acestuia (CBS_AUTOHSCROLL, WS_VSCROLL, WS_BORDER, etc.).

Daca m_wndComboBox este un obiect CComboBox , instructiunea m_wndComboBox.Create (WS_CHILD ¦ WS_VISIBLE ¦ WS_BORDER ¦ WS_VSCROLL ¦ CBS_DROPDOWNLIST ¦ CBS_SORT, rect, this, IDC_COMBOBOX);

creaza un CB drop-down list, a carei lista verticala contine bara de derulare (navigare, scroll) care va deveni vizibila cind numarul articolelor care pot fi afisate depaseste zona de afisare si de asemenea articolele din lista vor fi sortate. Dreptunghiul controlului trebuie pe care il specificam in CComboBox::Create trebuie sa fie destul de mare pentru a cuprinde si CE asociat si articolele din lista.

Stilurile pentru Combo Box Style Description CBS_AUTOHSCROLL Enables horizontal scrolling in the edit control portion of a combo box. CBS_DISABLENOSCROLL Disables the combo box list box's scroll bar when it isn't needed. Without this style, an unneeded scroll bar is hidden rather than disabled. CBS_DROPDOWN Creates a drop-down combo box. CBS_DROPDOWNLIST Creates a drop-down list combo box. CBS_HASSTRINGS Creates a combo box that "remembers" the strings added to it. Conventional combo boxes have this style by default; owner-draw combo boxes don't. CBS_LOWERCASE Forces all text in the combo box to lowercase. CBS_NOINTEGRALHEIGHT Prevents the combo box's list box height from having to be an exact multiple of the item height. CBS_OEMCONVERT A combo box whose edit control performs an ANSI- to-OEM-to-ANSI conversion on all characters so that the application won't get unexpected results if it performs an ANSI-to-OEM conversion of its own. Obsolete. CBS_OWNERDRAWFIXED Creates an owner-draw combo box whose items are all the same height. CBS_OWNERDRAWVARIABLE Creates an owner-draw combo box whose items can vary in height. CBS_SIMPLE Creates a simple combo box. CBS_SORT Automatically sorts items as they are added. CBS_UPPERCASE Forces all text in the combo box to uppercase.

Functiile membre din CComboBox sunt asemanatoare cu cele din CEdit si CListBox .

Constructie CComboBox Constructs a CComboBox object.

Initializare Creates the combo box and attaches it to the CComboBox Create object. Preallocates blocks of memory for items and strings in the InitStorage list-box portion of the combo box.

Operatii Generale Retrieves the number of items in the list box of a combo GetCount box. Retrieves the index of the currently selected item, if any, in GetCurSel the list box of a combo box. SetCurSel Selects a string in the list box of a combo box. Gets the starting and ending character positions of the GetEditSel current selection in the edit control of a combo box. SetEditSel Selects characters in the edit control of a combo box. Sets the 32-bit value associated with the specified item in a SetItemData combo box. Sets the 32-bit value associated with the specified item in a SetItemDataPtr combo box to the specified pointer ( void* ). Retrieves the application-supplied 32-bit value associated GetItemData with the specified combo-box item. Retrieves the application-supplied 32-bit value associated GetItemDataPtr with the specified combo-box item as a pointer ( void* ). Returns the index of the first visible item in the list-box GetTopIndex portion of the combo box. Tells the list-box portion of the combo box to display the SetTopIndex item with the specified index at the top. Sets the width in pixels that the list-box portion of the SetHorizontalExtent combo box can be scrolled horizontally. Returns the width in pixels that the list-box portion of the GetHorizontalExtent combo box can be scrolled horizontally. SetDroppedWidth Sets the minimum allowable width for the drop-down list- box portion of a combo box. Retrieves the minimum allowable width for the drop-down GetDroppedWidth list-box portion of a combo box. Deletes (clears) the current selection (if any) in the edit Clear control. Copies the current selection (if any) onto the Clipboard in Copy CF_TEXT format. Deletes (cuts) the current selection, if any, in the edit Cut control and copies the deleted text onto the Clipboard in CF_TEXT format. Inserts the data from the Clipboard into the edit control at Paste the current cursor position. Data is inserted only if the Clipboard contains data in CF_TEXT format. Limits the length of the text that the user can enter into the LimitText edit control of a combo box. Sets the height of list items in a combo box or the height of SetItemHeight the edit-control (or static-text) portion of a combo box. GetItemHeight Retrieves the height of list items in a combo box. GetLBText Gets a string from the list box of a combo box. GetLBTextLen Gets the length of a string in the list box of a combo box. Shows or hides the list box of a combo box that has the ShowDropDown CBS_DROPDOWN or CBS_DROPDOWNLIST style. Retrieves the screen coordinates of the visible (dropped- GetDroppedControlRect down) list box of a drop-down combo box. Determines whether the list box of a drop-down combo box GetDroppedState is visible (dropped down). Selects either the default or the extended user SetExtendedUI interface for a combo box that has the CBS_DROPDOWN or CBS_DROPDOWNLIST style. Determines whether a combo box has the default user GetExtendedUI interface or the extended user interface. GetLocale Retrieves the locale identifier for a combo box. SetLocale Sets the locale identifier for a combo box.

Operatii asupra continutului unui combo box Adds a string to the end of the list in the list box of a AddString combo box or at the sorted position for list boxes with the CBS_SORT style. DeleteString Deletes a string from the list box of a combo box. InsertString Inserts a string into the list box of a combo box. Removes all items from the list box and edit control of a ResetContent combo box. Dir Adds a list of filenames to the list box of a combo box. Finds the first string that contains the specified prefix in the FindString list box of a combo box. Finds the first list-box string (in a combo box) that matches FindStringExact the specified string. Searches for a string in the list box of a combo box and, if SelectString the string is found, selects the string in the list box and copies the string to the edit control.

Notificari Combo Box

Combo box-urile trimit notificari parintilor lor in acelasi mod cum o face un control de editare sau un list box.

Notificari Combo Box Notification Message-Macro Map Sim Drop- Drop-Down ple Down List CBN_DROPDOWN ON_CBN_DROPDOWN √ √ Sent when the drop-down list is displayed. CBN_CLOSEUP ON_CBN_CLOSEUP √ √ Sent when the drop-down list is closed. CBN_DBLCLK ON_CBN_DBLCLK √ Sent when an item is double- clicked. CBN_SELCHANGE ON_CBN_SELCHANGE √ √ √ Sent when the selection changes. CBN_SELENDOK ON_CBN_SELENDOK √ √ √ Sent when a selection is made. CBN_SELENDCANCEL ON_CBN_SELENDCANCEL √ √ Sent when a selection is canceled. CBN_EDITUPDATE N_CBN_EDITUPDATE √ √ Sent when the text in the edit control is about to change. CBN_EDITCHANGE ON_CBN_EDITCHANGE √ √ Sent when the text in the edit control has changed. CBN_KILLFOCUS ON_CBN_KILLFOCUS √ √ √ Sent when the combo box loses the input focus. CBN_SETFOCUS ON_CBN_SETFOCUS √ √ √ Sent when the combo box receives the input focus. CBN_ERRSPACE ON_CBN_ERRSPACE √ √ √ Sent when an operation fails because of insufficient memory.

Din acest tabel observam ca nu toate notificarile se aplica tuturor tipurilor CB.

Clasa CScrollBar

Clasa CScrollBar din MFC incapsuleaza controalele scroll bar create din "" WNDCLASS. Controalele scroll bar sunt identice in mare parte cu barele de scroll ale unei ferestre. Controalele scroll bar pot fi plasate oriunde in cadrul unei ferestre si se poate seta latimea si inaltimea acestora. Aceste controale se creaza cu functia CScrollBar::Create . Stilurile SBS_VERT si SBS_HORZ definesc un control scroll bar vertical, respectiv orizontal. Daca m_wndVScrollBar si m_wndHScrollBar sunt obiecte CScrollBar , atunci instructiunile m_wndVScrollBar.Create (WS_CHILD ¦ WS_VISIBLE ¦ WS_BORDER ¦ SBS_VERT, rectVert, this, IDC_VSCROLLBAR); m_wndHScrollBar.Create (WS_CHILD ¦ WS_VISIBLE ¦ WS_BORDER ¦ SBS_HORZ, rectHorz, this, IDC_HSCROLLBAR); creaza doua controale scroll bar, unul vertical si unul orizontal.

Determinarea latimii si inaltimii standard a acestor controale se face cu functia API ::GetSystemMetrics . In exemplul urmator, variabilele nWidth si nHight vor contine latimea si inaltimea standard a unui asemenea control: int nWidth = ::GetSystemMetrics (SM_CXVSCROLL); int nHeight = ::GetSystemMetrics (SM_CYHSCROLL);

O alta metoda pentru a crea scroll bar cu inaltime si latime standard este de a folosi stilurile SBS_TOPALIGN, SBS_BOTTOMALIGN, SBS_LEFTALIGN, sau SBS_RIGHTALIGN cind il cream.

Controalele scroll bar nu trimit mesajul WM_COMMAND; acestea trimit mesajele WM_VSCROLL si WM_HSCROLL. Aplicatiile MFC proceseaza aceste mesaje cu handler-ii OnVScroll si OnHScroll. Cele mai utilizate functii sunt: CScrollBar::GetScrollPos si CScrollBar::SetScrollPos, CScrollBar::GetScrollRange si CScrollBar::SetScrollRange. Se poate folosi CScrollBar::SetScrollInfo pentru a seta intervalul, pozitia si marimea “marcatorului” intr-un singur pas.

Functii membru CScrollBar Constructie CScrollBar Constructs a CScrollBar object.

Initializare Create Creates the Windows scroll bar and attaches it to the CScrollBar object.

Operatii GetScrollPos Retrieves the current position of a scroll box. SetScrollPos Sets the current position of a scroll box. Retrieves the current minimum and maximum scroll-bar positions for the GetScrollRange given scroll bar. SetScrollRange Sets minimum and maximum position values for the given scroll bar. ShowScrollBar Shows or hides a scroll bar. EnableScrollBar Enables or disables one or both arrows of a scroll bar. SetScrollInfo Sets information about the scroll bar. GetScrollInfo Retrieves information about the scroll bar. GetScrollLimit Retrieves the limit of the scroll bar

Clasa CListBox

Clasa CListBox din MFC incapsuleaza controalele list box, care afiseaza o lista de stringuri numite articole. Un list box poate sorta articolele pe care le contine si are implementata navigarea verticala, optional si cea orizontala. Cind pe un item (articol) facem clic sau dublu clic , list box-urile (care au stilul LBS_NOTIFY) notifica parintilor lor printr-un mesaj WM_COMMAND. MFC simplifica procesarea acestor mesaje furnizind macro-ul ON_LBN in harta de mesaje, care ruteaza notificarile list box-ului la functii din clasa fereastra parinte..

Un list box standard afiseaza stringuri intr-o coloana verticala si permite ca un singur articol sa fie selectat la un moment dat. Articolul curent selectat este afisat in video invers cu culoarea sistem COLOR_HIGHLIGHT. Windows suporta un numar de variatii de la standardul initial, variatii ce permit selectii multiple, afisarea pe mai multe coloane, list box-uri desenate de proprietar, afisare de imagini in locul textului. Crearea unui List Box

Urmatoarea instructiune creaza un list box din obiectul CListBox numit m_wndListBox : m_wndListBox.Create (WS_CHILD ¦ WS_VISIBLE ¦ LBS_STANDARD, rect, this, IDC_LISTBOX);

LBS_STANDARD combina stilurile WS_BORDER , WS_VSCROLL , LBS_NOTIFY , si LBS_SORT pentru a crea un list box care are margini, o bara de scroll verticala, care notifica parintilor sai cind selectia s-a schimbat sau s-a facut dublu clic pe un articol, si ca articolele vor fi sortate in ordine alfabetica. Implicit bara de scroll este vizibila numai cind articolele nu pot fi afisate in intregime in fereastra controlului. Pentru a face ca bara de scroll sa fie afisata tot timpul va trebui sa includem stilul LBS_DISABLENOSCROLL.

Putem crea list box-uri care cuprind toata zona client. List box-urile au incapsulata interfata cu tastatura - tastele sageti, page up, down, apasarea unui caracter muta selectia pe articolul care incepe cu acel caracter. Apasarea barei de spatiu face sa avem selectie multipla sau nu (on/off).

Putem programa interfata cu tastatura prin includerea stilului LBS_WANTKEYBOARDINPUT si procesarea mesajelor WM_VKEYTOITEM si WM_CHARTOITEM . O aplicatie MFC poate mapa aceste mesaje cu fct. OnVKeyToItem si OnCharToItem folosind macro-urile ON_WM_VKEYTOITEM si ON_WM_CHARTOITEM . O clasa listbox derivata poate manipula aceste mesaje singura prin suprascrierea functiilor virtuale CListBox::VKeyToItem si CListBox::CharToItem.

List Box Styles Style Description LBS_STANDARD Creates a "standard" list box that has a border and a vertical scroll bar, notifies its parent when the selection changes or an item is double-clicked, and sorts items alphabetically. LBS_SORT Sorts items that are added to the list box. LBS_NOSEL Creates a list box whose items can be viewed but not selected. LBS_NOTIFY Creates a list box that notifies its parent when the selection changes or an item is double-clicked. LBS_DISABLENOSC ROLL Disables the list box's scroll bar when it isn't needed. Without this style, an unneeded scroll bar is hidden rather than disabled. LBS_MULTIPLESEL Creates a multiple-selection list box. LBS_EXTENDEDSEL Adds extended selection support to a multiple- selection list box. LBS_MULTICOLUMN Creates a multicolumn list box. LBS_OWNERDRAWVARIABLE Creates an owner-draw list box whose items can vary in height. LBS_OWNERDRAWFIXED Creates an owner-draw list box whose items are the same height. LBS_USETABSTOPS Configures the list box to expand characters in item text. LBS_NOREDRAW Creates a list box that doesn't automatically redraw itself when an item is added or removed. LBS_HASSTRINGS Creates a list box that "remembers" the strings added to it. Conventional list boxes have this style by default; owner-draw list boxes don't. LBS_WANTKEYBOARDINPUT Creates a list box that sends its parent a WM_VKEYTOITEM or WM_CHARTOITEM message when a key is pressed. This style is used to customize the list box's response to keyboard input. LBS_NOINTEGRALHEIGHT Allows a list box to assume any height. By default, Windows sets a list box's height to a multiple of the item height to prevent items from being partially clipped.

Pentru ca fontul implicit pe care W il foloseste pt list box-uri este proportional spatiat, virtual este imposibil de a alinia coloanele prin spatii. O modalitate de a crea liste ce contin informatii pe mai multe coloane este sa folosim SetFont pt a aplica un font fixed-pitch la un list box. O solutie mai buna este de a asigna list box-urilor stilul LBS_USETABSTOPS si de a separa coloanele de informatii cu tab. Un list box cu stilul LBS_USETABSTOPS trateaza caracterele tab ca un procesor de texte. Implicit tab este de marimea a 8 caractere pentru latime. Putem schimba acest lucru cu fct. CListBox::SetTabStops. SetTabStops masoara distanta in unitati de dialog = o patrime din latimea unui caracter in fontul sistem .

Instructiunea: m_wndListBox.SetTabStops (64); pune spatiul dintre tab-uri la 64 unitati de dialog , si int nTabStops[] = { 32, 48, 64, 128 }; m_wndListBox.SetTabStops (4, nTabStops); plaseaza stop tab-uri la 32, 48, 64, si 128 unitati de dialog fata de marginea din stinga. Implicit un list box se redeseneaza singur cind este adaugat/sters un articol. Pentru a impiedica acest lucru putem seta stilul LBS_NOREDRAW. O asemenea lista va fi redesenata cind zona ei client va fi invalidata. O alta alternativa este de a inhiba procesul de actualizare cu LBS_NOREDRAW si a-l reactiva dupa ce ultimul articol din list box a fost adaugat. Putem face redesenarea enable/disable prin trimiterea mesajului si nu mai este necesar Invalidate() m_wndListBox.SendMessage (WM_SETREDRAW, FALSE, 0); // Disable redraws. m_wndListBox.SendMessage (WM_SETREDRAW, TRUE, 0); // Enable redraws.

Stilul LBS_MULTIPLESEL este folosit pentru selectii multiple. Cele mai multe list box-uri sunt create cu stilul LBS_EXTENDEDSEL, care permite selectii extinse. Cu un asemenea stil se fac selectii cu ajutorul mouse-ului si a tastei Ctrl (pe sarite) sau Shift (selectie contigua) (se poate combina Ctrl si Shift). Stilul LBS_MULTICOLUMN creaza un list box cu mai multe coloane (implicit 16 car per art.), care in mod normal au si stilul WS_HSCROLL pentru defilare orizontala. List Box-urile multicoloana nu pot avea bara verticala pentru scroll. Latimea coloanei se ajusteaza cu functia CListBox::SetColumnWidth. Adaugarea si Stergerea articolelor

Articolele sunt adaugate cu fct. CListBox::AddString si CListBox::InsertString . Instructiunea: m_wndListBox.AddString (string); adauga un ob. CString la list box. Daca stilul include LBS_SORT , at. art. e pozitionat corespunzator ordinii de sortare alfabetice, altfel este adaugat la sfirsitul listei. InsertString adauga art. la o pozitie indicata de primul parametru al fct. (zero-based index): m_wndListBox.InsertString (3, string);

LBS_SORT nu are efect asupra stringurilor adaugate cu InsertString .

Ambele functii AddString si InsertString intorc pozitia stringului din list box. In caz de esec se returneaza LB_ERRSPACE pentru a indica ca un list box este plin sau LB_ERR pt. a indica ca s- a intimplat altceva din diverse motive. Capacitatea unui list box este limitata numai de memoria disponibila. Functia CListBox::GetCount returneaza numarul art. dintr-un list box. Fct. CListBox::DeleteString elimina un articol dintr-un list box, articol identificat prin indexul sau. Intoarce numarul articolelor ramase in list box. Pentru a sterge toate art. fol. fct. CListBox::ResetContent .

Daca dorim sa asociem un pointer pe 32 biti sau o valoare DWORD cu un articol din list box putem folosi fct. CListBox::SetItemDataPtr sau CListBox::SetItemData .

Un pointer sau un DWORD asociat cu un art. poate fi regasit cu fct. CListBox::GetItemDataPtr sau CListBox::GetItemData . O folosire a acestei trasaturi este de ex. de a asocia o structura de date –ce contine nr. de telefon – pentru persoanele dintr-un list box. Din cauza ca GetItemDataPtr intoarce un pointer la void trebuie facuta conversia.

O alta tehnica este de a asocia extra date – in particular text – cu art. dintr-un list box , sa cream un list box cu stilul LBS_USETABSTOPS , sa setam primul tab stop la o pozitie din afara marginii drepte a list box-ului si din a adauga stringuri ce contin car tab urmate de extra data (text). Textul de la dreapta tab-ului va fi invizibil, dar CListBox::GetText va returna intregul text, deci si cel extra. Cautarea si regasirea articolelor

CListBox::GetCurSel intoarce indexul (0-based) al articolului care este selectat. Daca valoarea returnata este LB_ERR inseamna ca nu s-a selectat nimic. GetCurSel este adesea apelata ca urmare a unei notificari ce semnifica ca selectia s-a schimbat sau a fost facut dublu clic pe un articol. Un program poate seta selectia curenta cu SetCurSel . Pasind valoarea –1 pt. SetCurSel vom deselecta toate articolele . Pentru a gasi daca un art particular este selectat folosim CListBox::GetSel . SetCurSel identifica un articol prin indexul sau, dar art. pot fi selectate si dupa continut cu fct. CListBox::SelectString care realizeaza o singura selectie pentru un articol ce incepe cu textul specificat si selecteaza art. daca se gaseste unul care satisface conditia. Instructiunea m_wndListBox.SelectString (-1, _T ("Times")); incepe cautarea cu primul art din list box si va selecta primul art care incepe cu Times. Cautarea nu este case senzitive. Primul parametru indica indexul de unde incepe cautarea; -1 inseamna de la inceput. Indiferent de unde incepe cautarea aceasta poate sa parcurga circular intreaga lista asociata list box-ului daca este necesar. Pentru a cauta pentru un art. particular fara a schimba selectia vom folosi CListBox::FindString sau CListBox::FindStringExact . FindString face cautare numai pe primele caractere din art. Daca se intoarce LB_ERR inseamna ca nu s-a gasit acel art, altfel se intoarce indexul art. FindStringExact adauga in plus cautarea exacta. Cu indexul obtinut anterior putem aobtine textul art. cu CListBox::GetText . Se copie textul art. in var. string.

CString string; int nIndex = m_wndListBox.GetCurSel (); if (nIndex != LB_ERR) m_wndListBox.GetText (nIndex, string);

Al doilea parametru este un pointer la char. Putem folosi CListBox::GetTextLen pentru a determina marimea zonei necesare pentru a primi textul art. inainte de a apela GetText. Selectiile multiple sunt tratate diferit. GetCurSel , SetCurSel , si SelectString nu pot fi folosite in acest caz. Art. sunt selectate (deselectate) cu fct. SetSel si SelItemRange. In continuare se selecteaza art. cu indecsii 0, 5, 6, 7, 8, si 9 si deselecteaza art. 3: m_wndListBox.SetSel (0); m_wndListBox.SelItemRange (TRUE, 5, 9); m_wndListBox.SetSel (3, FALSE);

Alte functii: GetSelCount pt. determinarea nr. art. selectate, GetSelItems pentru regasirea indecsilor art. selectate. Intr-un list box cu selectie multipla, dreptunghiul ce reprezinta art. cu focus-ul asupra lui, poate fi mutat fara a schimba selectia curenta. Dreptunghiul care are focusul poate fi mutat sau obtinut cu fct. SetCaretIndex si GetCaretIndex . Multe din fct. ce lucreaza cu o singura selectie sunt disponibile si pentru list box-urile cu sele. multipla: GetText , GetTextLength , FindString , si FindStringExact.

Notificarile List Box

Notificarile sunt trimise via mesajul WM_COMMAND. In app. MFC, notificarile list box-urilor sunt mapate la functiile din clasa cu macro-ul ON_LBN….Vezi tabelul de mai jos. Notific ările LBN_DBLCLK, LBN_SELCHANGE, si LBN_SELCANCEL sunt trimise numai daca list box-ul a fost creat cu stilul LBS_NOTIFY sau LBS_STANDARD.

List Box Notifications Notification Sent When Message-Map Macro LBS_NO TIFY Required ? LBN_SETFOCUS The list box gains ON_LBN_SETFOCUS No the input focus. LBN_KILLFOCUS The list box loses ON_LBN_KILLFOCUS No the input focus. LBN_ERRSPACE An operation ON_LBN_ERRSPACE No failed because of insufficient memory. LBN_DBLCLK An item is ON_LBN_DBLCLK Yes double-clicked. LBN_SELCHANGE The selection ON_LBN_SELCHANGE Yes changes. LBN_SELCANCEL The selection is ON_LBN_SELCANCEL Yes canceled.

Notificarile cele mai folosite sunt: LBN_DBLCLK si LBN_SELCHANGE. Pentru a determina indexul articolului pe care s-a facut dublu clic intr-un list box cu o singura selectie folosim CListBox::GetCurSel . Vezi ex.

// In CMainWindow's message map

ON_LBN_DBLCLK (IDC_LISTBOX, OnItemDoubleClicked) void CMainWindow::OnItemDoubleClicked () { CString string; int nIndex = m_wndListBox.GetCurSel (); m_wndListBox.GetText (nIndex, string); MessageBox (string); }

Pentru un LB cu selectie multipla folosim GetCaretIndex in locul fct. GetCurSel pentru a determina articolul pe care s-a facut dublu clic. Notificarea LBN_SELCHANGE este trimisa cind utilizatorul schimba selectia, dar nu si in cazul cind selectia este schimbata automat prin program. Un LB cu selectie simpla trimite notificarea LBN_SELCHANGE cind selectia se muta din cauza unui clic sau a apasarii unei taste. Intr-un LB cu sel. multipla notificarea LBN_SELCHANGE este trimisa cind se face clic pe un art., cind starea selectiei art. este modificata (on/off) si cind dreptunghiul care are focus-ul este mutat.

Construction CListBox Constructs a CListBox object.

Initialization Create Creates the Windows list box and attaches it to the CListBox object.

InitStorage Preallocates blocks of memory for list box items and strings.

General Operations GetCount Returns the number of strings in a list box.

GetHorizontalExtent Returns the width in pixels that a list box can be scrolled horizontally.

SetHorizontalExtent Sets the width in pixels that a list box can be scrolled horizontally.

GetTopIndex Returns the index of the first visible string in a list box.

SetTopIndex Sets the zero-based index of the first visible string in a list box.

GetItemData Returns the 32-bit value associated with the list-box item.

GetItemDataPtr Returns a pointer to a list-box item.

SetItemData Sets the 32-bit value associated with the list-box item.

SetItemDataPtr Sets a pointer to the list-box item.

GetItemRect Returns the bounding rectangle of the list-box item as it is currently displayed.

ItemFromPoint Returns the index of the list-box item nearest a point.

SetItemHeight Sets the height of items in a list box.

GetItemHeight Determines the height of items in a list box.

GetSel Returns the selection state of a list-box item.

GetText Copies a list-box item into a buffer.

GetTextLen Returns the length in bytes of a list-box item.

SetColumnWidth Sets the column width of a multicolumn list box.

SetTabStops Sets the tab-stop positions in a list box.

GetLocale Retrieves the locale identifier for a list box.

SetLocale Sets the locale identifier for a list box.

Single-Selection Operations GetCurSel Returns the zero-based index of the currently selected string in a list box.

SetCurSel Selects a list-box string.

Multiple-Selection Operations SetSel Selects or deselects a list-box item in a multiple-selection list box.

GetCaretIndex Determines the index of the item that has the focus rectangle in a multiple-selection list box.

SetCaretIndex Sets the focus rectangle to the item at the specified index in a multiple-selection list box.

GetSelCount Returns the number of strings currently selected in a multiple- selection list box.

GetSelItems Returns the indices of the strings currently selected in a list box.

SelItemRange Selects or deselects a range of strings in a multiple-selection list box.

SetAnchorIndex Sets the anchor in a multiple-selection list box to begin an extended selection.

GetAnchorIndex Retrieves the zero-based index of the current anchor item in a list box.

String Operations AddString Adds a string to a list box.

DeleteString Deletes a string from a list box.

InsertString Inserts a string at a specific location in a list box.

ResetContent Clears all the entries from a list box.

Dir Adds filenames from the current directory to a list box.

FindString Searches for a string in a list box.

FindStringExact Finds the first list-box string that matches a specified string.

SelectString Searches for and selects a string in a single-selection list box.

Overridables DrawItem Called by the framework when a visual aspect of an owner-draw list box changes.

MeasureItem Called by the framework when an owner-draw list box is created to determine list-box dimensions.

CompareItem Called by the framework to determine the position of a new item in a sorted owner-draw list box. DeleteItem Called by the framework when the user deletes an item from an owner-draw list box.

VKeyToItem Override to provide custom WM_KEYDOWN handling for list boxes with the LBS_WANTKEYBOARDINPUT style set.

CharToItem Override to provide custom WM_CHAR handling for owner-draw list boxes which don't have strings.