Funktionreferenz


_GUICtrlListBox_Create

Beschreibung anzeigen in

Erstellt ein Listbox-Control

#include <GuiListBox.au3>
_GUICtrlListBox_Create ( $hWnd, $sText, $iX, $iY [, $iWidth = 100 [, $iHeight = 200 [, $iStyle = 0x00B00002 [, $iExStyle = 0x00000200]]]] )

Parameter

$hWnd Control-ID / Handle des Controls
$sText String, welcher zur Combobox hinzugefügt werden soll
$iX Horizontale Position des Controls
$iY Vertikale Position des Controls
$iWidth [optional] Breite des Controls
$iHeight [optional] Höhe des Controls
$iStyle [optional] Stil des Controls:
    $LBS_COMBOBOX - Meldet einer ListBox, dass sie Teil einer ComboBox ist
    $LBS_DISABLENOSCROLL - Zeigt eine deaktivierte vertikale Scrollbar
    $LBS_EXTENDEDSEL - Erlaubt, dass mehrere Items ausgewählt werden können
    $LBS_HASSTRINGS - Bestimmt, dass eine ListBox Items aus Strings enthält
    $LBS_MULTICOLUMN - Erstellt eine ListBox mit mehreren Spalten, welche horizontal scrollbar ist
    $LBS_MULTIPLESEL - Stellt mit jedem Klick auf einen String die Stringauswahl an oder aus
    $LBS_NODATA - Erstellt eine ListBox ohne Daten
    $LBS_NOINTEGRALHEIGHT - Bestimmt, dass die Größe der ListBox exakt der Größe der Anwendung entspricht
    $LBS_NOREDRAW - Bestimmt, dass die ListBox nach Änderungen ihres Inhalts nicht automatisch vom Betriebssystem neu gezeichnet wird
    $LBS_NOSEL - Bestimmt, dass die ListBox Items enthält, welche angeschaut aber nicht selektiert werden können.
    $LBS_NOTIFY - Meldet immer, wenn ein Benutzer einen String normal oder doppelt anklickt
    $LBS_OWNERDRAWFIXED - Bestimmt, dass die ListBox nicht vom Betriebssystem neu gezeichnet wird, sondern vom Skript. Die Größe der ListBox kann nicht vom Benutzer verändert werden
    $LBS_OWNERDRAWVARIABLE - Bestimmt, dass die ListBox nicht vom Betriebssystem neu gezeichnet wird, sondern vom Skript. Die Höhe der ListBox kann vom Benutzer verändert werden
    $LBS_SORT - Sortiert die Strings in der ListBox alphabetisch
    $LBS_STANDARD - Standard-ListBox-Stil
    $LBS_USETABSTOPS - Aktiviert das Erkennen und Erweitern von Tabulatoren in der Listbox
    $LBS_WANTKEYBOARDINPUT - Bestimmt, dass der Besitzer WM_VKEYTOITEM-Nachrichten erhält
Standard: $LBS_SORT, $WS_HSCROLL, $WS_VSCROLL, $WS_BORDER
Erzwungen: $WS_CHILD, $WS_TABSTOP, $WS_VISIBLE, $LBS_NOTIFY
$iExStyle [optional] Erweiterte Stile des Controls. Diese entsprechen den Standard-$WS_EX_-Konstanten. Siehe Tabelle Erweiterte Stile.
Standard: $WS_EX_CLIENTEDGE

Rückgabewert

Erfolg: das Handle des Listbox-Controls
Fehler: 0

Bemerkungen

Diese Funktion ist für erfahrene Benutzer und zum Erlernen der Funktion von Controls.

- - - - - - - - Erklärung der Controls - - - - - - - -

Verwandte Funktionen

_GUICtrlListBox_Destroy

Beispiel

Example : Erstellt mit der UDF

#include "Extras\WM_NOTIFY.au3"

#include <DirConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>
#include <WindowsNotifsConstants.au3>

Global $g_hListBox

Example()

Func Example()
    ; Erstellt eine GUI
    Local $hGUI = GUICreate("ListBox: Erzeugen (v" & @AutoItVersion & ")", 400, 296)
    $g_hListBox = _GUICtrlListBox_Create($hGUI, "String bei Erzeugung", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Hinzufügen von Items")

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    ; Fügt Dateien hinzu
    _GUICtrlListBox_BeginUpdate($g_hListBox)
    _GUICtrlListBox_ResetContent($g_hListBox)
    _GUICtrlListBox_InitStorage($g_hListBox, 100, 4096)
    _GUICtrlListBox_Dir($g_hListBox, @WindowsDir & "\win*.exe")
    _GUICtrlListBox_AddFile($g_hListBox, @WindowsDir & "\notepad.exe")
    _GUICtrlListBox_Dir($g_hListBox, "", $DDL_DRIVES)
    _GUICtrlListBox_Dir($g_hListBox, "", $DDL_DRIVES, False)
    _GUICtrlListBox_EndUpdate($g_hListBox)

    ; Die Schleife wiederholt sich, bis der Benutzer die Beenden-Aktion der GUI auslöst.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg
    Local $hWndListBox = $g_hListBox
    If Not IsHWnd($g_hListBox) Then $hWndListBox = GUICtrlGetHandle($g_hListBox)
    Local $hWndFrom = $lParam
    Local $iIDFrom = BitAND($wParam, 0xFFFF)     ; Niederwertiges Wort (WORD)
    Local $iCode = BitShift($wParam, 16)     ; Höherwertiges Wort (WORD)

    Switch $hWndFrom
        Case $g_hListBox, $hWndListBox
            Switch $iCode
                Case $LBN_DBLCLK ; Wird gesendet, wenn der Benutzer einen Doppelklick auf einen String in einer ListBox ausführt
                    _WM_NOTIFY_DebugInfo("$LBN_DBLCLK", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                    ; Kein Rückgabewert
                Case $LBN_ERRSPACE ; Wird gesendet, wenn eine ListBox nicht genug Speicher zugeteilt bekommt, um eine Anfrage entgegenzunehmen
                    _WM_NOTIFY_DebugInfo("$LBN_ERRSPACE", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                    ; Kein Rückgabewert
                Case $LBN_KILLFOCUS ; Wird gesendet, wenn eine ListBox den Tastatur-Fokus verliert
                    _WM_NOTIFY_DebugInfo("$LBN_KILLFOCUS", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                    ; Kein Rückgabewert
                Case $LBN_SELCANCEL ; Wird gesendet, wenn der Benutzer die Auswahl in einer ListBox abbricht
                    _WM_NOTIFY_DebugInfo("$LBN_SELCANCEL", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                    ; Kein Rückgabewert
                Case $LBN_SELCHANGE ; Wird gesendet, wenn die Auswahl in einer ListBox geändert wurde
                    _WM_NOTIFY_DebugInfo("$LBN_SELCHANGE", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                    ; Kein Rückgabewert
                Case $LBN_SETFOCUS ; Wird gesendet, wenn eine Listbox den Tastatur-Fokus erhält
                    _WM_NOTIFY_DebugInfo("$LBN_SETFOCUS", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                    ; Kein Rückgabewert
            EndSwitch
    EndSwitch
    ; Die internen Standard Autoit3-Messages-Befehle werden fortgesetzt.
    ; Die ganze Zeile kann auch weggelassen werden.
    ; !!! Aber wird nur 'Return' (ohne Rückgabewert) verwendet, so
    ; Werden spätere Standard Autoit3-Messages-Befehle nicht mehr verarbeitet !!!
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND