Page 1 of 1

Control the dimensions of DropDown List of ComboBox [Windows]

Posted: Wed May 08, 2024 7:01 pm
by RASHAD
Hi

Code: Select all

Dim iconhandle(2)
iconhandle(0)=CreateImage(0,20,20,32,#Red)
iconhandle(1)=CreateImage(1,20,20,32,#Blue)
iconhandle(2)=CreateImage(2,20,20,32,#Green)

LoadFont(0,"Tahoma",16)

OpenWindow(0,0,0,320,100,"...",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ComboBoxGadget(0,10,10,300,30,#PB_ComboBox_Editable|#PB_ComboBox_Image)
SetGadgetFont(0,FontID(0))

#CBEM_GETEDITCONTROL = 1031
Global hEdit = SendMessage_(GadgetID(0), #CBEM_GETEDITCONTROL, 0, 0)
Debug hEdit

For i=0 To 20
  AddGadgetItem(0,-1,"TEST "+Str(i),iconhandle(i&1))
Next i

dLhwnd = FindWindow_("ComboLBox",0)

h = SendMessage_(GadgetID(0), #CB_GETITEMHEIGHT, 0, 0)

GetWindowRect_(dLhwnd,r.RECT)
MoveWindow_(dLhwnd,r\left,r\top,r\right-r\left,h*22,1)

ComboBoxGadget(1,10,50,300,30,#PB_ComboBox_Editable|#PB_ComboBox_Image)
SetGadgetFont(1,FontID(0))

For i=0 To 30
  AddGadgetItem(1,-1,"TEST "+Str(i),iconhandle(i&1))
Next i

dLhwnd2 = FindWindow_("ComboLBox",0)
h = SendMessage_(GadgetID(1), #CB_GETITEMHEIGHT, 0, 0)

GetWindowRect_(dLhwnd2,r2.RECT)
MoveWindow_(dLhwnd2,r2\left,r2\top,r2\right-r2\left,h*32,1)
;SetActiveGadget(0)


Repeat
  EventID.l = WaitWindowEvent()
  Select EventID
      
    Case #PB_Event_CloseWindow
      End      
      
    Case #PB_Event_Gadget      
      Select EventGadget()
        Case 0
          
      EndSelect      
  EndSelect
ForEver


Re: Control the dimensions of DropDown List of ComboBox [Windows]

Posted: Thu May 09, 2024 9:38 am
by hoangdiemtinh
Thank man.
I will apply your code to my upcoming program.

Re: Control the dimensions of DropDown List of ComboBox [Windows]

Posted: Thu May 09, 2024 7:28 pm
by boddhi
Hi RASHAD,

I don't see any difference... normal?
(Win 10 x64 - PB 6.10 x64 - DPI 125%)

ImageImage

Re: Control the dimensions of DropDown List of ComboBox [Windows]

Posted: Thu May 09, 2024 8:07 pm
by RASHAD
Hi boddhi
Just checked it with :
1- Windows 11 x64 - PB 6.10 x64 125% DPI
2- Windows 10 x64 (VM) - PB 6.10 x64 125% DPI
Both works as expected
Make sure that the handle of the DropDown list is OK and report
Thanks for reporting

And thanks for hoangdiemtinh too

Re: Control the dimensions of DropDown List of ComboBox [Windows]

Posted: Thu May 09, 2024 10:11 pm
by boddhi
No modification of the source except Debugs added:
DebuggerOutput wrote: hEdit : 2823766
dLhwnd : 35526464
h : 36
dLhwnd2 : 35526464
h : 36
It seems that the two combo get the same handle...

Re: Control the dimensions of DropDown List of ComboBox [Windows]

Posted: Thu May 09, 2024 11:06 pm
by RASHAD
That is strange
See if the next snippet do it right

Code: Select all

Dim iconhandle(2)
iconhandle(0)=CreateImage(0,20,20,32,#Red)
iconhandle(1)=CreateImage(1,20,20,32,#Blue)
iconhandle(2)=CreateImage(2,20,20,32,#Green)

LoadFont(0,"Tahoma",16)

OpenWindow(0,0,0,320,100,"...",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ComboBoxGadget(0,10,10,300,30,#PB_ComboBox_Editable|#PB_ComboBox_Image)
SetGadgetFont(0,FontID(0))

For i=0 To 20
  AddGadgetItem(0,-1,"TEST "+Str(i),iconhandle(i&1))
Next i

ComboBoxGadget(1,10,50,300,30,#PB_ComboBox_Editable|#PB_ComboBox_Image)
SetGadgetFont(1,FontID(0))

For i=0 To 30
  AddGadgetItem(1,-1,"TEST "+Str(i),iconhandle(i&1))
Next i

Repeat
  EventID.l = WaitWindowEvent()
  Select EventID
      
    Case #PB_Event_CloseWindow
      End      
      
    Case #PB_Event_Gadget      
      Select EventGadget()
        Case 0
          dLhwnd = FindWindow_(@"ComboLBox",0)
          Debug dlhwnd          
          h = SendMessage_(GadgetID(0), #CB_GETITEMHEIGHT, 0, 0)          
          GetWindowRect_(dLhwnd,r.RECT)
          MoveWindow_(dLhwnd,r\left,r\top,r\right-r\left,h*(CountGadgetItems(0)+1),1)
          
        Case 1
          dLhwnd = FindWindow_(@"ComboLBox",0)
          h = SendMessage_(GadgetID(1), #CB_GETITEMHEIGHT, 0, 0)          
          GetWindowRect_(dLhwnd,r.RECT)
          MoveWindow_(dLhwnd,r\left,0,r\right-r\left,h*(CountGadgetItems(1)+1),1)
          
      EndSelect      
  EndSelect
ForEver



Re: Control the dimensions of DropDown List of ComboBox [Windows]

Posted: Fri May 10, 2024 12:24 am
by boddhi
Hi,
RASHAD wrote: See if the next snippet do it right
It seems to be the expected behaviour but...
Image
as you can see, the first combo's dropdownlist (and probably for the second too if it had fewer items) is not always positioned at the same position, depending on whether it is the first click, the second click or whether the second combox was clicked before...

Re: Control the dimensions of DropDown List of ComboBox [Windows]

Posted: Fri May 10, 2024 1:33 am
by RASHAD
ComboBox with Image is a special class by PB
Next is my last run
Wish me luck :D

Code: Select all

Dim cblist(1,1)
Dim iconhandle(2)

iconhandle(0)=CreateImage(0,20,20,32,#Red)
iconhandle(1)=CreateImage(1,20,20,32,#Blue)
iconhandle(2)=CreateImage(2,20,20,32,#Green)

LoadFont(0,"Tahoma",16)

OpenWindow(0,0,0,320,100,"...",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ComboBoxGadget(0,10,10,300,30,#PB_ComboBox_Editable|#PB_ComboBox_Image)
SetGadgetFont(0,FontID(0))
dLhwnd = FindWindow_("ComboLBox",0)
h = SendMessage_(GadgetID(0), #CB_GETITEMHEIGHT, 0, 0)
cblist(0,0) = dLhwnd
cblist(0,1) = h

For i=0 To 20
  AddGadgetItem(0,-1,"TEST "+Str(i),iconhandle(i&1))
Next i

ComboBoxGadget(1,10,50,300,30,#PB_ComboBox_Editable|#PB_ComboBox_Image)
SetGadgetFont(1,FontID(0))
dLhwnd2 = FindWindow_("ComboLBox",0)
h = SendMessage_(GadgetID(1), #CB_GETITEMHEIGHT, 0, 0)
cblist(1,0) = dLhwnd2
cblist(1,1) = h

For i=0 To 30
  AddGadgetItem(1,-1,"TEST "+Str(i),iconhandle(i&1))
Next i

Repeat
  EventID.l = WaitWindowEvent()
  Select EventID
      
    Case #PB_Event_CloseWindow
      End      
      
    Case #PB_Event_Gadget      
      Select EventGadget()
        Case 0
          GetWindowRect_(cblist(0,0),r.RECT)
          MoveWindow_(cblist(0,0),r\left,r\top,r\right-r\left,cblist(0,1)*22,1)
          
        Case 1
          GetWindowRect_(cblist(1,0),r.RECT)
          MoveWindow_(cblist(1,0),r\left,0,r\right-r\left,cblist(1,1)*32,1)
          
      EndSelect      
  EndSelect
ForEver



Re: Control the dimensions of DropDown List of ComboBox [Windows]

Posted: Fri May 10, 2024 2:20 am
by boddhi
Unfortunately, same result as your first code! :(
Thanks for your tries. :wink:

It was to move the schmilblick! :mrgreen: