[SOLVED] Multi-column ComboBoxGadget and use of separating delimiter

Just starting out? Need help? Post your questions and find answers here.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4991
Joined: Sun Apr 12, 2009 6:27 am

Re: Multi-column ComboBoxGadget and use of separating delimiter

Post by RASHAD »

1- Added ChrisR addition
2- Fixed zero order staff
3- Added hot track

Code: Select all

LoadFont(0,"Arial",10)

Global IsListIconVisible

Procedure winCB(hWnd,uMsg,wParam,lParam)
  Result = #PB_ProcessPureBasicEvents
  Select uMsg 
    Case #WM_SIZE,#WM_MOVE
      If IsWindow(100)
        ResizeWindow(100,GadgetX(1,#PB_Gadget_ScreenCoordinate),GadgetY(1,#PB_Gadget_ScreenCoordinate)+GadgetHeight(1),380,200)
        ResizeGadget(2,0,0,380,200)
        HideWindow(100,1)
        HideGadget(2,1)
        SetActiveGadget(-1)         
        IsListIconVisible = #False
      EndIf 
      
  EndSelect
  ProcedureReturn Result
EndProcedure

OpenWindow(0,0,0,600,400,"Window",#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
ComboBoxGadget(1,10,10,180,24)   
SetGadgetFont(1,FontID(0))
;**********************************************************************************
OpenWindow(100,GadgetX(1,#PB_Gadget_ScreenCoordinate),GadgetY(1,#PB_Gadget_ScreenCoordinate)+GadgetHeight(1),380,200,"",#PB_Window_BorderLess|#PB_Window_Invisible,WindowID(0))
UseGadgetList(WindowID(100))
ListIconGadget(2,0,0,380,200,"",70,#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#LVS_NOCOLUMNHEADER)
SendMessage_(GadgetID(2), #LVM_SETEXTENDEDLISTVIEWSTYLE,0,SendMessage_(GadgetID(2),#LVM_GETEXTENDEDLISTVIEWSTYLE,0,0)| #LVS_EX_TRACKSELECT)
SendMessage_(GadgetID(2), #LVM_SETHOVERTIME, 0, 10)
SetGadgetColor(2,#PB_Gadget_BackColor,$D5F3FE)
SetGadgetColor(2,#PB_Gadget_LineColor,$0)
AddGadgetColumn(2,1,"",100)
AddGadgetColumn(2,2,"",180)
For i = 0 To 10
  AddGadgetItem(1,i,"Item "+Str(i))
  AddGadgetItem(2,i,"Item "+Str(i)+#LF$+"Text "+Str(i)+#LF$+"another text "+Str(i))
Next
SendMessage_(GadgetID(1), #CB_SETMINVISIBLE, 1, 0)
;*************************************************************************************
UseGadgetList(WindowID(0))
ComboBoxGadget(3,10,40,180,24)
SetGadgetFont(3,FontID(0)) 
For i = 0 To 10
  AddGadgetItem(3,i,"Item "+Str(i))
Next
SetGadgetState(1,2)
SetGadgetState(3,4)
TextGadget(4,10,100,580,24,"Test for zero order",#SS_CENTER|#SS_CENTERIMAGE)
SetGadgetColor(4,#PB_Gadget_BackColor,0)
SetGadgetColor(4,#PB_Gadget_FrontColor,$FFFFFF)

SetWindowCallback(@winCB())
Repeat
  Select WaitWindowEvent()
      
    Case #PB_Event_CloseWindow
      Quit = 1       
      
    Case #WM_LBUTTONDOWN,#WM_LBUTTONDBLCLK
      act = GetActiveGadget()
      Select  act
        Case 1
          If IsListIconVisible
            SetActiveGadget(2)
            HideWindow(100,1)
            HideGadget(2,1)
            SetActiveGadget(-1)         
            IsListIconVisible = #False
          Else
            HideWindow(100,0) 
            HideGadget(2,0)  
            SetActiveGadget(2)
            IsListIconVisible = #True
          EndIf          
          
        Case 2
          text$ = GetGadgetItemText(1,GetGadgetState(2),0)
          SetGadgetText(1,text$) 
          HideWindow(100,1) 
          HideGadget(2,1)            
          IsListIconVisible = #False
          SetActiveGadget(-1)
          
      EndSelect
      
  EndSelect 
  
Until Quit = 1
End
Edit : Fixed Moving or Resizing Window
Last edited by RASHAD on Wed Nov 13, 2024 3:19 pm, edited 1 time in total.
Egypt my love
PBJim
Enthusiast
Enthusiast
Posts: 296
Joined: Fri Jan 19, 2024 11:56 pm

Re: Multi-column ComboBoxGadget and use of separating delimiter

Post by PBJim »

RASHAD wrote: Wed Nov 13, 2024 12:20 pm 1- Added ChrisR addition
2- Fixed zero order staff
3- Added hot track
Yes, I see what you've done there, with the gadget list. I noticed that if I move the window, the special combobox is drawn in the original place.

Image

Also, you can move the main window while the special combobox is open. These things are not easy to get right for sure.
Axolotl
Addict
Addict
Posts: 872
Joined: Wed Dec 31, 2008 3:36 pm

Re: Multi-column ComboBoxGadget and use of separating delimiter

Post by Axolotl »

PBJim wrote: Wed Nov 13, 2024 9:53 am .....it's been interesting to see other options.
Just out of curiosity. Did you read my last post?
BTW: I have decided for myself that I will not integrate any additional gadgets, as the effort required to master all situations is quite complicated
e.g. keyboard usage. But that's just my opinion.
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4991
Joined: Sun Apr 12, 2009 6:27 am

Re: Multi-column ComboBoxGadget and use of separating delimiter

Post by RASHAD »

Previous post updated :mrgreen:
Egypt my love
PBJim
Enthusiast
Enthusiast
Posts: 296
Joined: Fri Jan 19, 2024 11:56 pm

Re: Multi-column ComboBoxGadget and use of separating delimiter

Post by PBJim »

RASHAD wrote: Wed Nov 13, 2024 3:20 pm Previous post updated :mrgreen:
It's great Rashad, seems very solid. :) Thanks very much for refining it.
Post Reply