Quick question... concerning the list of items inside a ComboBoxGadget().
I can make the ComboBox height any size I need, but I couldn't find a way to alter the default height of the items inside the list. (it's for a touch tablet, and the default is way too small for fingers. haha).
Any pointers?
It's for Windows machine but cross platform would be better.
Item Height in a ComboBoxGadget
Item Height in a ComboBoxGadget
- It was too lonely at the top.
System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
Re: Item Height in a ComboBoxGadget
Code: Select all
EnableExplicit
Define i.I
Define ItemHeight.I
OpenWindow(0, 0, 0, 390, 180, "",
#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ComboBoxGadget(0, 10, 10, 180, 21)
ComboBoxGadget(1, 200, 10, 180, 21)
For i = 1 To 5
AddGadgetItem(0, -1,"ComboBox item " + Str(i))
AddGadgetItem(1, -1,"ComboBox item " + Str(i))
Next
SetGadgetState(0, 0)
SetGadgetState(1, 0)
; ----- Get default item height in 1st ComboBox
ItemHeight = SendMessage_(GadgetID(0), #CB_GETITEMHEIGHT, -1 ,0)
SendMessage_(GadgetID(0), #CB_SETITEMHEIGHT, 0, ItemHeight)
; ----- Add 15 to item height in 2nd ComboBox
SendMessage_(GadgetID(1), #CB_SETITEMHEIGHT, 0, ItemHeight + 15)
; ----- Open 2nd ComboBox to show increased item height
SendMessage_(GadgetID(1), #CB_SHOWDROPDOWN, 1, 0)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindowRe: Item Height in a ComboBoxGadget
For Windows
Code: Select all
Global Text$,Brush,Brush_2
Text$ = Space(#MAX_PATH)
Brush = CreateSolidBrush_($FADC72)
Brush_2 = CreateSolidBrush_($99FEFA)
Procedure WndProc(hWnd, uMsg, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
Select uMsg
Case #WM_DRAWITEM
*DRAWITEM.DRAWITEMSTRUCT = lParam
If *DRAWITEM\CtlType = #ODT_COMBOBOX
SetBkMode_(*DRAWITEM\hDC, #TRANSPARENT)
If *DRAWITEM\ItemState & #ODS_FOCUS
FillRect_(*DRAWITEM\hDC,*DRAWITEM\rcItem,Brush)
Else
FillRect_(*DRAWITEM\hDC,*DRAWITEM\rcItem,Brush_2)
EndIf
SendMessage_(*DRAWITEM\hwndItem,#CB_GETLBTEXT,*DRAWITEM\itemID, @Text$)
SetTextColor_(*DRAWITEM\hDC, $0)
*DRAWITEM\rcItem\left = 8
DrawText_(*DRAWITEM\hDC,@Text$,Len(Text$),*DRAWITEM\rcItem, #DT_SINGLELINE | #DT_VCENTER )
EndIf
EndSelect
ProcedureReturn Result
EndProcedure
LoadFont(0,"Tahoma",12,#PB_Font_Bold)
If OpenWindow(0, 0, 0, 280, 180, "ComboBoxGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetWindowCallback(@WndProc())
ComboBoxGadget(0 ,10, 10, 260, 40,#CBS_OWNERDRAWFIXED|#CBS_HASSTRINGS)
SetGadgetFont(0,FontID(0))
SendMessage_(GadgetID(0), #CB_SETITEMHEIGHT, 0, 40)
For a = 0 To 10
AddGadgetItem(0, -1,"ComboBox Item " + Str(a))
Next
SetGadgetState(0, 2)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Egypt my love
Re: Item Height in a ComboBoxGadget
Thanks Shardik and Rashad.
I thought I'd have to dip into the Windows API... but they work great.
I've added both to my arsenal... funny the topic hasn't come up more often, especially with higher resolution screens (I have a 4k monitor).
Thanks again, very useful stuff.
I thought I'd have to dip into the Windows API... but they work great.
I've added both to my arsenal... funny the topic hasn't come up more often, especially with higher resolution screens (I have a 4k monitor).
Thanks again, very useful stuff.
- It was too lonely at the top.
System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem

