ComboBoxGadget() DropDown height

Share your advanced PureBasic knowledge/code with the community.
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

ComboBoxGadget() DropDown height

Post by nco2k »

since 4.30 the behavior of the ComboBoxGadget() height param has changed. with this trick you can set the height of the dropdown:

Code: Select all

If OpenWindow(0, 0, 0, 200, 110, "ComboBox Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ComboBoxGadget(0, 5, 5, 190, #PB_Ignore, #CBS_NOINTEGRALHEIGHT)
  For i = 1 To 10
    AddGadgetItem(0, -1, "ComboBox item " + Str(i))
  Next
  SetGadgetState(0, 0)
  MoveWindow_(GadgetID(0), GadgetX(0), GadgetY(0), GadgetWidth(0), 100, #True)
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf : End
if you know a better solution, feel free to share it.

c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: ComboBoxGadget() DropDown height

Post by PB »

Thanks for that. Don't know why it was changed anyway. The old way was far
better and more useful. Who wants to change the height when the text won't
fill to that height anyway? (See image). I'd prefer it to go back to the old way.

Image
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

It wasn't the only one gadget where the heieght wasn't the height. When you don't know it, the droplix just doesn't show, it wasn't acceptable. About the stringbox, it's like the StringGadget..
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post by Rescator »

A larger font will fill that extra height :)

I like the new behavior, it seems "correct" and I can finaly make the combo box match the height of my string gadgets and buttons and not the other way around :)
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> I can finaly make the combo box match the height of my string gadgets

True, I forgot about that. I suppose it's a good change then. :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Re: ComboBoxGadget() DropDown height

Post by nco2k »

it doesnt work with 4.50 anymore.. fred any chance, to restore this? :/

c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
breeze4me
Enthusiast
Enthusiast
Posts: 633
Joined: Thu Mar 09, 2006 9:24 am
Location: S. Kor

Re: ComboBoxGadget() DropDown height

Post by breeze4me »

Try this one. It seems to work. (x86 XP SP3)

Code: Select all

If OpenWindow(0, 0, 0, 200, 110, "ComboBox Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ComboBoxGadget(0, 5, 5, 190, 20)
  
  For i = 1 To 10
    AddGadgetItem(0, -1, "ComboBox item " + Str(i))
  Next
  SetGadgetState(0, 0)
  ;MoveWindow_(FindWindowEx_(GadgetID(0), 0, 0, 0), 0, 0, GadgetWidth(0), 100, #True)
  ;or
  MoveWindow_(GetWindow_(GadgetID(0), #GW_CHILD), 0, 0, GadgetWidth(0), 100, #True)
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf : End
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Re: ComboBoxGadget() DropDown height

Post by nco2k »

very nice, thx. :)

c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: ComboBoxGadget() DropDown height

Post by Michael Vogel »

Does anyone know a solution for comboboxes with images?

The top two gadgets do work (enlarged dropdown box height, the two gadgets at the bottom stay with their default height)

Code: Select all

Global Dim flag(3)

flag(1)=#PB_ComboBox_Editable
flag(2)=#PB_ComboBox_Image

OpenWindow(0,10,10,200,170,"ComboBox Example",#PB_Window_SystemMenu)

For g=0 To 3
	flag=flag(g&1)|flag(g&2)|flag(g&4)
	ComboBoxGadget(g,10,10+g*40,180,30,flag|#CBS_NOINTEGRALHEIGHT)
	MoveWindow_(GadgetID(g),GadgetX(g),GadgetY(g),GadgetWidth(g),1000,#True)

	For i = 1 To 40
		AddGadgetItem(g, -1, "ComboBox item"+Str(i))
	Next
	SetGadgetText(g,"$"+Hex(flag))
Next g

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
breeze4me
Enthusiast
Enthusiast
Posts: 633
Joined: Thu Mar 09, 2006 9:24 am
Location: S. Kor

Re: ComboBoxGadget() DropDown height

Post by breeze4me »

Michael Vogel wrote: Wed May 08, 2024 4:33 pm Does anyone know a solution for comboboxes with images?

Code: Select all

Global Dim flag(3)

flag(1)=#PB_ComboBox_Editable
flag(2)=#PB_ComboBox_Image

OpenWindow(0,10,10,200,170,"ComboBox Example",#PB_Window_SystemMenu)

Define sBuffer.s{32}

For g=0 To 3
  flag=flag(g&1)|flag(g&2)|flag(g&4)
  ComboBoxGadget(g,10,10+g*40,180,30,flag | #CBS_NOINTEGRALHEIGHT)
  
  GetClassName_(GadgetID(g), @sBuffer, 30)
  
  If sBuffer = "ComboBox"
    MoveWindow_(GadgetID(g),GadgetX(g),GadgetY(g),GadgetWidth(g),1000,#True)
    
    ; The height of the gadget will change to the default value, so it should be adjusted.
    ResizeGadget(g, #PB_Ignore, #PB_Ignore, #PB_Ignore, 30)
    
  ElseIf sBuffer = "ComboBoxEx32"
    MoveWindow_(GetWindow_(GadgetID(g), #GW_CHILD), 0, 0, GadgetWidth(g), 1000, #True)
  EndIf
  
  For i = 1 To 40
    AddGadgetItem(g, -1, "ComboBox item"+Str(i))
  Next
  SetGadgetText(g,"$"+Hex(flag))
Next g

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: ComboBoxGadget() DropDown height

Post by Michael Vogel »

Works fine, thanks.

Just an observation - which has nothing to do with resizing the gadget but with the combobox itself: the dialog needs quite a while here until the initialization is done (tested with PB5.73 and PB6.04).

When replacing the ComboBoxGadget by any other gadget type, e.g. with ListViewGadget(g,10,10+g*40,180,30), the dialog is ready with no delay.

So, is the ComboBoxGadget a lame duck?
Post Reply