More that one CheckBox in Row

Just starting out? Need help? Post your questions and find answers here.
User avatar
4RESTER
User
User
Posts: 63
Joined: Thu Aug 19, 2010 11:03 pm
Location: Uman, Ukraine

More that one CheckBox in Row

Post by 4RESTER »

How to make ListIconGadget with the more that one CheckBox in Row?

Like this:
Image
See ya... Image
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: More that one CheckBox in Row

Post 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.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User avatar
em_uk
Enthusiast
Enthusiast
Posts: 366
Joined: Sun Aug 08, 2010 3:32 pm
Location: Manchester UK

Re: More that one CheckBox in Row

Post 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
----

R Tape loading error, 0:1
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: More that one CheckBox in Row

Post 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
Last edited by Shardik on Wed Sep 07, 2011 8:10 am, edited 1 time in total.
User avatar
4RESTER
User
User
Posts: 63
Joined: Thu Aug 19, 2010 11:03 pm
Location: Uman, Ukraine

Re: More that one CheckBox in Row

Post 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.
See ya... Image
User avatar
4RESTER
User
User
Posts: 63
Joined: Thu Aug 19, 2010 11:03 pm
Location: Uman, Ukraine

Re: More that one CheckBox in Row

Post 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
See ya... Image
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: More that one CheckBox in Row

Post 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

Egypt my love
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Re: More that one CheckBox in Row

Post by Foz »

Perhaps esGrid or exGrid will be apt for you: http://www.purecoder.net/grids/screenshots.htm
User avatar
4RESTER
User
User
Posts: 63
Joined: Thu Aug 19, 2010 11:03 pm
Location: Uman, Ukraine

Re: More that one CheckBox in Row

Post 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).
See ya... Image
Post Reply