Page 1 of 1

More that one CheckBox in Row

Posted: Tue Sep 06, 2011 9:54 am
by 4RESTER
How to make ListIconGadget with the more that one CheckBox in Row?

Like this:
Image

Re: More that one CheckBox in Row

Posted: Tue Sep 06, 2011 10:45 am
by c4s
I don't thank that's possible with PureBasic-only functions. However using some Windows API might work.

I'm also interested in that. Especially placing custom icons in other columns than the first one and simply being able to use multiple in one row.

Re: More that one CheckBox in Row

Posted: Wed Sep 07, 2011 1:18 am
by em_uk
There may be an easier way to do this, but this will start you off with icons in other columns.

Code: Select all

; English forum: http://www.purebasic.fr/english/viewtopic.php?t=7059&postdays=0&postorder=asc&start=15
; Author: Denis (updated for PB 4.00 by Andre)
; Date: 30. July 2003
; OS: Windows
; Demo: No


; ListIconGadget : adding icons to other columns than 1st


;constantes des Gadgets 

#MainWindow      = 0 
#ListIconGadget1 = 1 
#ButtonGadget    = 2 
#ButtonGadget2   = 3 
#ButtonGadget3   = 4 
#Font            = 5 
#FontHeader      = 6 

#LVM_SETEXTENDEDLISTVIEWSTYLE = 4150 
#LVS_EX_SUBITEMIMAGES         = 2 
;;======================================================================================== 
;;======================================================================================== 


If OpenWindow(#MainWindow,0,0,450,300, " Icon - Icon - Icon", #PB_Window_ScreenCentered |#PB_Window_SystemMenu) 

   Attention.l = CreateImage(300, 16,16)
   StartDrawing(ImageOutput(300))
     Box(4,4,8,8,RGB(255,30,30))
   StopDrawing()


    
   If CreateGadgetList(WindowID(#MainWindow)) And ListIconGadget(#ListIconGadget1,1,50,320,450,"Colonne 1", 298/3 ,#PB_ListIcon_MultiSelect|#PB_ListIcon_FullRowSelect) 
      AddGadgetColumn(#ListIconGadget1, 1, "Colonne 2",298/3) 
      AddGadgetColumn(#ListIconGadget1, 2, "Colonne 3",298/3) 
   EndIf 
   FontID = LoadFont(#Font, "ARIAL", 9) 
   SetGadgetFont(#ListIconGadget1, FontID) 

; set extended style to the listicongadget to set image for subitems 

   SendMessage_(GadgetID(#ListIconGadget1), #LVM_SETEXTENDEDLISTVIEWSTYLE , #LVS_EX_SUBITEMIMAGES, #LVS_EX_SUBITEMIMAGES) 

   For i.b = 0 To 5 
       AddGadgetItem(#ListIconGadget1, -1, "111"+Chr(10)+ "222"+Chr(10)+"333"+Chr(10)+ "444",Attention) 
   Next i 

; fill up var to set subitem icon and text 
   var.lv_item 
    
   Var\mask     = #LVIF_IMAGE | #LVIF_TEXT 
   Var\iItem    = 5  ; row number for change 
   Var\iSubItem = 2  ; 2nd subitem 
   Var\pszText  = @"Try"  ; text to change to 
   Var\iImage   = 1; index of icon in the list 

; set text + icon in the listicongadget 
   SendMessage_(GadgetID(#ListIconGadget1), #LVM_SETITEM, 0, @Var) 

EndIf 

  Repeat 
     Select WaitWindowEvent() 
  
         Case #PB_Event_CloseWindow 
         Quit = 1 

     EndSelect 

  Until Quit 

End

Re: More that one CheckBox in Row

Posted: Wed Sep 07, 2011 7:09 am
by Shardik
4RESTER wrote:How to make ListIconGadget with the more that one CheckBox in Row?
On Windows that would be very difficult using the Microsoft ListView control (which is
the underlying basis of the ListIconGadget) even if using API functions. But RASHAD
has found a kind of "cheat" by using two ListIconGadgets appearing as a single one:
http://www.purebasic.fr/english/viewtop ... 12&t=47455

For Linux I posted an example in the German forum:
http://www.purebasic.fr/german/viewtopi ... 0&start=19

Re: More that one CheckBox in Row

Posted: Wed Sep 07, 2011 8:10 am
by 4RESTER
em_uk wrote:There may be an easier way to do this, but this will start you off with icons in other columns.

Code: Select all

; English forum: http://www.purebasic.fr/english/viewtopic.php?t=7059&postdays=0&postorder=asc&start=15
; Author: Denis (updated for PB 4.00 by Andre)
; Date: 30. July 2003
; OS: Windows
; Demo: No


; ListIconGadget : adding icons to other columns than 1st

[/quote]

That's not what I asked.
I asked about the [u]standard[/u] CheckBoxes, not about Icones as CheckBoxes.

Re: More that one CheckBox in Row

Posted: Wed Sep 07, 2011 8:14 am
by 4RESTER
Shardik wrote:
4RESTER wrote:How to make ListIconGadget with the more that one CheckBox in Row?
On Windows that would be very difficult using the Microsoft ListView control (which is
the underlying basis of the ListIconGadget) even if using API functions. But RASHAD
has found a kind of "cheat" by using two ListIconGadgets appearing as a single one:
http://www.purebasic.fr/english/viewtop ... 12&t=47455

For Linux I posted an example in the German forum:
http://www.purebasic.fr/german/viewtopi ... 0&start=19
This also with the malfunctions when column resizing: http://www.purebasic.fr/english/viewtop ... 12&t=47455

Image

Re: More that one CheckBox in Row

Posted: Wed Sep 07, 2011 8:58 am
by RASHAD
Hi 4RESTER
The rest is yours mate you have to subclass the 2 ListIcons to manage the 1- Resizing
2- Vertical & horizontal Scroll 3- Events

Beside Using Windows CallBack and so on
Next with Fixed Column 0

Code: Select all


Procedure WndProc(hwnd, uMsg, wParam, lParam)

result = #PB_ProcessPureBasicEvents 

Select uMsg
   
   Case #WM_NOTIFY,#WM_SETREDRAW
    *NMHDR.NMHDR = lParam  
      ; Fixed Column Width
       If IsGadget(1) And *NMHDR\hWndFrom = GetWindow_(GadgetID(1),#GW_CHILD) And *NMHDR\code = #HDN_FIRST
          *phdn.NMHEADER = lParam                  
              If *phdn\Iitem = 0
                    ProcedureReturn 1              
              EndIf   
       EndIf
         
       EndSelect

  ProcedureReturn result 
EndProcedure
  
  
  If OpenWindow(0, 0, 0, 640, 300, "ListIconGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    ContainerGadget(0,10,25,620,260,#PB_Container_Flat)
    ListIconGadget(1,  0,  0, 140, 200, "Column 1", 139,#PB_ListIcon_GridLines|#PB_ListIcon_CheckBoxes)
    SetWindowLongPtr_(GadgetID(1),#GWL_EXSTYLE,0)
    SetGadgetColor(1,#PB_Gadget_BackColor,$EAFEFE)
    SetGadgetColor(1,#PB_Gadget_LineColor,$C5C5C5)
    ListIconGadget(2,  150,  0, 480, 200, "Column 2", 150,#PB_ListIcon_GridLines|#PB_ListIcon_CheckBoxes)
    SetWindowLongPtr_(GadgetID(2),#GWL_EXSTYLE,0)
    SetGadgetColor(2,#PB_Gadget_BackColor,$EAFEFE)
    SetGadgetColor(2,#PB_Gadget_LineColor,$C5C5C5)
      For i = 0 To 6
        AddGadgetItem(1, i, "Item 1")
      Next
      For i = 1 To 4
        AddGadgetColumn(2, i, "Column " + Str(i+2), 65)
      Next
      For i = 0 To 6
        AddGadgetItem(2, i, "Item 2"+Chr(10)+"Item 3"+Chr(10)+"Item 4"+Chr(10)+"Item 5"+Chr(10)+"Item 6")
      Next
      ResizeGadget(1,0,0,140,260)
      ResizeGadget(2,140,0,480,260)
      CloseGadgetList()
      
     SetWindowCallback(@WndProc())
    
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf


Re: More that one CheckBox in Row

Posted: Wed Sep 07, 2011 9:41 am
by Foz
Perhaps esGrid or exGrid will be apt for you: http://www.purecoder.net/grids/screenshots.htm

Re: More that one CheckBox in Row

Posted: Wed Sep 07, 2011 10:26 am
by 4RESTER
Foz wrote:Perhaps esGrid or exGrid will be apt for you: http://www.purecoder.net/grids/screenshots.htm
If exist the MoreListIconGadget UserLib for the PureBasic 4.5x/4.6x then also can help (for free).