Joined: March 11th, 2008, 11:36 pm Posts: 291
|
Set of functions for ComboBox / DropDownList manipulation like built-in TV_*() and LV_*() functions (TreeView/ListView)
-Common Parameters
Control : ClassNN of Control (default=ComboBox1) Window : WinTitle of the window (default=ahk_class AutoHotkeyGUI) Pos : Position in the list, usually starts from 0 (-1 = currentsel by default) String : String to be added/inserted/modified -FunctionsCB_Get(Control="ComboBox1", Window="ahk_class AutoHotkeyGUI")
Return current selected position CB_Set(Pos=0, Control="ComboBox1", Window="ahk_class AutoHotkeyGUI")
Set selected position to %Position% CB_Add(String="", Control="ComboBox1", Window="ahk_class AutoHotkeyGUI") CB_Insert(String="", Pos=-1, Control="ComboBox1", Window="ahk_class AutoHotkeyGUI") Insert %String% at specified %Position% CB_Modify(String="", Pos=-1, Control="ComboBox1", Window="ahk_class AutoHotkeyGUI") Modify entry of specified %Position% to %String% CB_Delete(Pos=-1, Control="ComboBox1", Window="ahk_class AutoHotkeyGUI") Delete entry of specified %Position% CB_Reset(Control="ComboBox1", Window="ahk_class AutoHotkeyGUI") CB_Find(String, Control="ComboBox1", Window="ahk_class AutoHotkeyGUI") Find position of %String% CB_FindExact(String, Control="ComboBox1", Window="ahk_class AutoHotkeyGUI") Same as above but more accuracy CB_Select(String, Control="ComboBox1", Window="ahk_class AutoHotkeyGUI")
Find %String% and Select automatically equivalent to (GuiControl, ChooseString, ControlID, String) CB_Show(Flag=True, Control="ComboBox1", Window="ahk_class AutoHotkeyGUI")
Show DropDown or Hide(Flag=False) CB_GetCount(Control="ComboBox1", Window="ahk_class AutoHotkeyGUI")
Return total count of the entries CB_GetText(Pos=-1, Control="ComboBox1", Window="ahk_class AutoHotkeyGUI")
Return text of the specified %Position% CB_GetTexts(delimiter="`n", Control="ComboBox1", Window="ahk_class AutoHotkeyGUI")
Return text of all entries
Save as CB.ahk (stdlib compatible)
Example
Code: Gui, Add, GroupBox, x6 y7 w230 h380 , CB_*() Example Gui, Add, DropDownList, x16 y27 w210 h20 r15, % "Test||" Range("a","z",1,"|") . "|" . Range(1,50,1,"|") Gui, Add, Button, x16 y57 w100 h20 gGet, CB_Get() Gui, Add, Button, x126 y57 w100 h20 gSet, CB_Set() Gui, Add, Edit, x16 y87 w100 h20 vAdd, String to Add Gui, Add, Button, x126 y87 w100 h20 gAdd, CB_Add() Gui, Add, Edit, x16 y117 w100 h20 vInsert, String to Insert Gui, Add, Button, x126 y117 w100 h20 gInsert, CB_Insert() Gui, Add, Edit, x16 y147 w100 h20 vModify, String to be Modified Gui, Add, Button, x126 y147 w100 h20 gModify, CB_Modify() Gui, Add, Edit, x16 y177 w100 h20 vFind, String to Find Gui, Add, Button, x126 y177 w100 h20 gFind, CB_Find() Gui, Add, Edit, x16 y207 w100 h20 vSelect, String to Select Gui, Add, Button, x126 y207 w100 h20 gSelect, CB_Select() Gui, Add, Button, x16 y237 w210 h20 gGetCount, CB_GetCount() Gui, Add, Button, x16 y267 w210 h20 gGetText, CB_GetText() Gui, Add, Button, x16 y297 w210 h20 gGetTexts, CB_GetTexts() Gui, Add, Button, x16 y327 w100 h20 gShow, CB_Show() Gui, Add, DropDownList, x126 y327 w100 h20 r2 vShow, True||False Gui, Add, Button, x16 y357 w210 h20 gReset, CB_Reset() Gui, Show, w246 h397 Return
GuiClose: ExitApp
Get: MsgBox % CB_Get() Return
Set: InputBox, OutputVar,44, Type Position to be set,, 150, 120,,,,,0 CB_Set(OutputVar) Return
Add: Gui, Submit, NoHide CB_Add(Add) Return
Insert: Gui, Submit, NoHide CB_Insert(Insert) Return
Modify: Gui, Submit, NoHide CB_Modify(Modify) Return
Find: Gui, Submit, NoHide MsgBox % CB_Find(Find) ;CB_FindExact() is available too Return
Select: Gui, Submit, NoHide CB_Select(Select) ;equivalent to (GuiControl, ChooseString, ControlID, String) Return
GetCount: MsgBox % CB_GetCount() Return
GetText: MsgBox % CB_GetText() Return
GetTexts: MsgBox % CB_GetTexts("|") ;custom delimiter Return
Show: Gui, Submit, NoHide Flag := (Show=="True") ? 1 : 0 CB_Show(Flag) Return
Reset: CB_Reset() Return
;http://www.autohotkey.com/forum/viewtopic.php?t=33958#209490 ;function by Titan range(x, y = "", c = 1, d = ",") { If (!a := x | 1) x := Asc(x), y := Asc(y) Loop, % (y == (a ? "" : 0) ? (y := x) - x := x > 96 ? 97 : x > 64 ? 65 : 1 : y - x) // c + 1 r .= d . (a ? x : Chr(x)), x += c Return, SubStr(r, 1 + StrLen(d)) }
_________________ Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com
Last edited by heresy on July 26th, 2008, 10:10 pm, edited 1 time in total.
|
|