ListBox in BoxesUp
Keywords:
;This works. Only a couple user interface issues;
;would like Esc to Cancel, Enter to OK, and double click
;on List item to OK. Still, not bad as is.
; Define standard window style constants
nWSxCHILD = 16384 << 16
nWSxGROUP = 2 << 16
nWSxTABSTOP = 1 << 16
nWSxVISIBLE = 4096 << 16
nWSxVSCROLL = 32 << 16
; Define ListBox window style constants
nLBSxUSETABSTOPS = 128
; Define extended window style constants
nWSxEXxCLIENTEDGE = 512
; Define Win32 message constants
nLBxADDSTRING = 384
AddExtender("WWCTL34I.DLL")
; Create parent box
BoxesUp("200,200,800,800", @NORMAL)
BoxButtonDraw(1, 1, "OK", "550,950,450,900")
BoxButtonDraw(1, 2, "Cancel", "750,950,650,900")
; Set up API call arguments
dwExStyle = nWSxEXxCLIENTEDGE
lpClassName = "ListBox"
lpWindowName = 0
dwStyle = nWSxCHILD | nWSxTABSTOP | nWSxVISIBLE | nWSxVSCROLL
dwStyle = dwStyle | nLBSxUSETABSTOPS |nWSxGROUP
x = 10 ; pixels from left of parent window
y = 10 ; pixesl from top of parent window
; My display resolution is 1600x1200;
; GetClientRect can be used to relate pixesl to BoxesUp units
nWidth = 400 ; pixels
nHeight = 200 ; pixels
hWndParent = DLLhWnd("")
hMenu = 3
hInstance = DLLhInst("")
lParam = 0
; Create the ListBox
sDLLName = StrCat(DirWindows(1), "User32.DLL")
sEntry = StrCat("long:", '"CreateWindowExA"')
sArgs = "long:dwExStyle"
sArgs = StrCat(sArgs, ", lpstr:lpClassName")
sArgs = StrCat(sArgs, ", long:lpWindowName")
sArgs = StrCat(sArgs, ", long:dwStyle")
sArgs = StrCat(sArgs, ", long:x")
sArgs = StrCat(sArgs, ", long:y")
sArgs = StrCat(sArgs, ", long:nWidth")
sArgs = StrCat(sArgs, ", long:nHeight")
sArgs = StrCat(sArgs, ", long:hWndParent")
sArgs = StrCat(sArgs, ", long:hMenu")
sArgs = StrCat(sArgs, ", long:hInstance")
sArgs = StrCat(sArgs, ", long:lParam")
hWndList = DLLCall(sDLLName, %sEntry%, %sArgs%)
; Add items to ListBox
sText = "Marty"
IntControl(22, hWndList, nLBxADDSTRING, 0, sText)
sText = "Don"
IntControl(22, hWndList, nLBxADDSTRING, 0, sText)
sText = "Bill"
IntControl(22, hWndList, nLBxADDSTRING, 0, sText)
sText = "Linus"
IntControl(22, hWndList, nLBxADDSTRING, 0, sText)
; Highlight one of the items
cSetLBItemEx(hWndList, 1)
; Wait for the user to hit a button
While @TRUE
If BoxButtonStat(1, 1) Then Break
If BoxButtonStat(1, 2) Then Break
EndWhile
; See what the user chose
sChosen = cGetLBSelText(hWndList)
BoxDestroy(1)
Message("Here is the choice:", sChosen)
Article ID: W14576
Filename: ListBox in BoxesUp - Cool!.txt