ComboBoxGadget Bug

Just starting out? Need help? Post your questions and find answers here.
Lite
User
User
Posts: 17
Joined: Fri Dec 21, 2012 7:50 am

ComboBoxGadget Bug

Post by Lite »

Hello

On Windows XP and Windows 7 come a Error with ComboBox.
Maybe on more Windows, but not tested.
The PureBasic gadget created a large window if not items inside.
it is on "windows xp themes is off".
Winapi Combobox works fine.

Greetings

Lite

example:

Code: Select all


Enumeration
   #Window
EndEnumeration


; Note:
; compileroptions: deactive modern theme windows xp style

; [ ]  active modern theme Windows xp support


OpenWindow(#Window, 0, 0, 400, 300, "ComboBox Bug", #PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)

TextGadget(0, 10,  20, 250, 20, "Winapi Combobox")
CreateWindow_(#WC_COMBOBOX, @"", #CBS_AUTOHSCROLL|#CBS_DROPDOWN|#CBS_SIMPLE|#WS_CHILD|#WS_VISIBLE, 10, 40, 200, 20, WindowID(#Window), #Null, #NUL, #Null)

TextGadget(1, 10,  80, 250, 20, "PureBasic Combobox")
ComboBoxGadget(5,10,100,200,25,#CBS_AUTOHSCROLL|#CBS_DROPDOWN|#CBS_SIMPLE)

Repeat
   
   Select WaitWindowEvent()
         
      Case #PB_Event_CloseWindow
         End
         
   EndSelect
   
ForEver

User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: ComboBoxGadget Bug

Post by Shardik »

It seems that PB internally looses the GWL_STYLE values of its ComboBox if Windows XP theme support is disabled. As a workaround you may insert the two following lines behind the definition of the PureBasic ComboBox which will result in the same behaviour of PB's dropdown list and the API one (tested on Windows XP SP3 and Windows 7 x86 SP1):

Code: Select all

SetWindowLongPtr_(GadgetID(5), #GWL_STYLE, GetWindowLongPtr_(GadgetID(5), #GWL_STYLE))
ResizeGadget(5, #PB_Ignore, #PB_Ignore, #PB_Ignore, 25)
Lite
User
User
Posts: 17
Joined: Fri Dec 21, 2012 7:50 am

Re: ComboBoxGadget Bug

Post by Lite »

Thanks for your workarround.

interessting is. the winapi combobox can not create smaller than 22 pixel high.
PureBasic combobox can reduce size smaller than 22 pixel.
after this come the error and your workarround not work.
is highvalue equal and higher 22 pixel it works nicely.

Regards
Lite
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: ComboBoxGadget Bug

Post by RASHAD »

No need to use unneeded API flags with PB ComboBox()
Because it is already activated

Code: Select all

Enumeration
   #Window
EndEnumeration

; Note:
; compileroptions: deactive modern theme windows xp style

; [ ]  active modern theme Windows xp support


OpenWindow(#Window, 0, 0, 400, 300, "ComboBox Bug", #PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)

TextGadget(0, 10,  20, 250, 20, "Winapi Combobox")
CreateWindow_(#WC_COMBOBOX, @"", #CBS_AUTOHSCROLL|#CBS_DROPDOWN|#CBS_SIMPLE|#WS_CHILD|#WS_VISIBLE, 10, 40, 200, 20, WindowID(#Window), #Null, #NUL, #Null)

TextGadget(1, 10,  80, 250, 20, "PureBasic Combobox")
ComboBoxGadget(5,10,100,200,25)
AddGadgetItem(5,-1,"")

Repeat
   
   Select WaitWindowEvent()
         
      Case #PB_Event_CloseWindow
         End
         
   EndSelect
   
ForEver
Egypt my love
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: ComboBoxGadget Bug

Post by Shardik »

RASHAD,

while your example is indeed simpler than mine (without the need of an API function) it doesn't show the same behaviour than mine... :wink:

In your example the API and PB ComboBoxes show a different behaviour. While the API ComboBox displays a thin black bar as drop down list (signalling that the drop down list is empty), your PB ComboBox displays a drop down list with an empty entry (both with and without Windows XP theme support)...
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: ComboBoxGadget Bug

Post by RASHAD »

Hi Shardik
Yes I know :)
But it is the same as PB ComboBox with XP skin enabled
So you have to accept it for both cases or consider it as a bug and ask Fred to solve the problem

Happy new year mate
Still on time I think :mrgreen:


Edit :
Strange behavior
Try the next with XP skin disabled

Code: Select all

Enumeration
   #Window
EndEnumeration


; Note:
; compileroptions: deactive modern theme windows xp style

; [ ]  active modern theme Windows xp support


OpenWindow(#Window, 0, 0, 400, 300, "ComboBox Bug", #PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)

TextGadget(0, 10,  20, 250, 20, "Winapi Combobox")
CreateWindow_(#WC_COMBOBOX, @"", #CBS_AUTOHSCROLL|#CBS_DROPDOWN|#CBS_SIMPLE|#WS_CHILD|#WS_VISIBLE, 10, 40, 200, 20, WindowID(#Window), #Null, #NUL, #Null)

TextGadget(1, 10,  80, 250, 20, "PureBasic Combobox")
ComboBoxGadget(5,10,100,200,25,#CBS_AUTOHSCROLL|#CBS_DROPDOWN|#CBS_SIMPLE)
SetWindowLongPtr_(GadgetID(5), #GWL_STYLE, GetWindowLongPtr_(GadgetID(5), #GWL_STYLE))
ResizeGadget(5, #PB_Ignore, #PB_Ignore, #PB_Ignore, 25)

For x = 0 To 10
    AddGadgetItem(5,x,"Item # : "+Str(x))
Next

Repeat
   
   Select WaitWindowEvent()
         
      Case #PB_Event_CloseWindow
         End
         
   EndSelect
   
ForEver
Egypt my love
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: ComboBoxGadget Bug

Post by Fred »

Not a real bug, only a small difference between common controls. When empty, you should disable your combobox anyway.
Post Reply