listicon gadget speed (with large images, 2000+ items)

Just starting out? Need help? Post your questions and find answers here.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Mistrel, it is possible to alter the icons in column zero - no problem.

However, you do have to understand Window's and PB's way of handling column zero icons with ListIcon gadgets. Items in column zero are automatically assigned image index zero (all other subitems receive image index -1) meaning that as soon as an image list is added to the listicon, items in column zero automatically receive the first image in the list. Now, in PB's case, rather than reset all image indexes in column zero to -1, it instead adds a dummy image to the image list consisting of a fully transparent 'blank' icon. Thus, items without an ImageID() included in their underlying AddGadgetItem() receive this transparent icon.

In the case of your custom image list, items in column zero are each thus automatically being assigned the first image in your list (having image index 0). So, you either need to reset all items in column zero to have their iImage values set to -1 before assigning the image list to the listicon, or do what PB does and add a fully transparent icon as the first image - which is actually the better choice.

So, you can either reset your code to use column zero as it should work out fine for your needs (as I understand them), or, if you wish to continue with blanking out column 0, I can post some code to prevent the cursor from changing when over the column 0 divider etc.

**EDIT : just had a look at Sparkie's code for using a virtual listicon - works fine here. Just add subitemimages and there's no problem. You can remove the SetGadgetItemText() and you want to put the line

Code: Select all

ImageList_Add_(imgList, img0, 0)
outside of the loop because you are adding 10000 copies of the same image! Just add one copy instead which has index 0 and keep this in mind in the callback.
There is a slight redrawing issue with subitem images on my machine, but that is the case also for non-virtual listicons! I would say that the virtual listicon is the way to go if speed is critical.
I may look like a mule, but I'm not a complete ass.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

I initially attempted to use a fully transparent icon for the ImageList index 0. The problem with this is that even though the icon is transparent the text is still indented by the width of the image.

I also tried to remove the images automatically assigned to column 0 by passing the image index of -1. This worked for all other columns but not for column 0.

If this is working for you would you please post a code example? Maybe I did something incorrectly or perhaps it works on Vista differently than Windows XP?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Unlikely that Vista is an issue, but let me check on XP first...
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Yes, in column 0; once an icon has been used in any row, Windows forever indents the text. For other columns just reset the items icon index to -1 and the items will no longer indent. I begin to see now why you blanked out column zero! :wink: I had to do the same with EsGRID, although for slightly different reasons because that control does not use image lists.

As for switching icons in column zero : (you'll need to add a second bitmap)

Code: Select all

#MainWindow=0 
#ListIconGadget1=1 
UsePNGImageDecoder() 

Var.LV_ITEM 
Var\mask=#LVIF_IMAGE 
Var\iItem=0 ; row number for change 
Var\iSubItem=0; column 

If OpenWindow(#MainWindow,0,0,320,240,"Icon List",#PB_Window_ScreenCentered|#PB_Window_SystemMenu) 
  CreateGadgetList(WindowID(#MainWindow)) 
  hListIcon = ListIconGadget(#ListIconGadget1,0,0,320,200,"Original",298/3, #PB_ListIcon_FullRowSelect) 
    SendMessage_(GadgetID(#ListIconGadget1),#LVM_SETEXTENDEDLISTVIEWSTYLE,#LVS_EX_SUBITEMIMAGES,#LVS_EX_SUBITEMIMAGES) 
    AddGadgetColumn(#ListIconGadget1,1,"Column 1",298/3) 
  ButtonGadget(2, 10,210, 60,20, "Toggle")
    
  CatchImage(1,?MyImage) 
  LoadImage(2,"bm1.bmp") ;Add your own bitmap.
  hImageList=ImageList_Create_(32,32,#ILC_MASK|#ILC_COLOR32,0,100) 
  ImageList_Add_(hImageList,ImageID(1),0) 
  ImageList_Add_(hImageList,ImageID(2),0) 
  SendMessage_(hListIcon,#LVM_SETIMAGELIST,#LVSIL_SMALL,hImageList) 
   
  For i=0 To 10 
    AddGadgetItem(#ListIconGadget1,i,"Item "+Str(i)) 
  Next i 

  Repeat 
    Select WaitWindowEvent() 
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 2
            toggle = 1 - toggle
            Var\iImage=toggle
            SendMessage_(GadgetID(#ListIconGadget1),#LVM_SETITEM,0,@Var) 
        EndSelect
      Case #PB_Event_CloseWindow 
         Quit=1 
    EndSelect 
  Until Quit 
  ImageList_Destroy_(hImageList) 
EndIf 

End 

DataSection 
   MyImage: 
   Data.b $89,$50,$4E,$47,$0D,$0A,$1A,$0A,$00,$00,$00,$0D,$49,$48,$44,$52,$00,$00,$00,$20 
   Data.b $00,$00,$00,$20,$08,$02,$00,$00,$00,$FC,$18,$ED,$A3,$00,$00,$00,$19,$74,$45,$58 
   Data.b $74,$53,$6F,$66,$74,$77,$61,$72,$65,$00,$41,$64,$6F,$62,$65,$20,$49,$6D,$61,$67 
   Data.b $65,$52,$65,$61,$64,$79,$71,$C9,$65,$3C,$00,$00,$0A,$42,$49,$44,$41,$54,$78,$DA 
   Data.b $3C,$96,$69,$8C,$DC,$65,$1D,$C7,$9F,$EB,$7F,$CF,$BD,$33,$BB,$33,$7B,$75,$EF,$ED 
   Data.b $F6,$58,$B6,$F6,$A2,$85,$16,$52,$6A,$A0,$05,$11,$0A,$22,$09,$8D,$45,$63,$D4,$F8 
   Data.b $42,$34,$51,$63,$E2,$1B,$49,$78,$E3,$2B,$13,$63,$D2,$17,$92,$18,$40,$31,$46,$42 
   Data.b $03,$8D,$10,$85,$0A,$2D,$2D,$F4,$DA,$A5,$ED,$DE,$67,$DB,$9D,$99,$EE,$EE,$CC,$EC 
   Data.b $DC,$F3,$BF,$9F,$E7,$F1,$99,$42,$7C,$F2,$64,$32,$93,$3C,$F3,$3C,$BF,$F3,$F3,$FD 
   Data.b $C1,$DF,$FE,$EE,$34,$80,$04,$00,$0E,$C4,$E2,$90,$03,$E4,$52,$AA,$06,$23,$D9,$D9 
   Data.b $89,$1B,$E7,$FE,$01,$10,$A1,$C0,$F6,$20,$85,$58,$82,$9C,$42,$CA,$90,$38,$C3,$39 
   Data.b $96,$14,$00,$30,$24,$CC,$F1,$6D,$85,$18,$1A,$94,$AA,$0E,$62,$18,$63,$BF,$1E,$6B 
   Data.b $ED,$1A,$79,$F0,$B1,$60,$24,$0E,$20,$E0,$CC,$25,$1C,$E1,$58,$4B,$07,$E3,$14,$50 
   Data.b $08,$31,$A2,$8C,$71,$62,$14,$B2,$4B,$4B,$17,$DF,$23,$66,$89,$6B,$01,$1B,$98,$12 
   Data.b $51,$3A,$62,$51,$E6,$D3,$5A,$B9,$62,$BA,$1E,$04,$0C,$B8,$35,$CB,$03,$94,$60,$99 
   Data.b $23,$8B,$6E,$52,$2D,$4C,$80,$E6,$9A,$55,$13,$1B,$2C,$9B,$AD,$E6,$F3,$1D,$7D,$23 
   Data.b $98,$48,$85,$8D,$55,$02,$9B,$C7,$A9,$D8,$00,$62,$C8,$A1,$4B,$A1,$5D,$B9,$37,$FD 
   Data.b $D1,$1B,$76,$F9,$9E,$62,$04,$5B,$12,$81,$64,$5B,$BB,$A4,$06,$6F,$CC,$64,$30,$86 
   Data.b $B1,$54,$C8,$A9,$D4,$1B,$96,$2D,$31,$42,$98,$6B,$D9,$9E,$05,$91,$C4,$A9,$5F,$2F 
   Data.b $21,$59,$83,$50,$C7,$AC,$5E,$75,$02,$F3,$E3,$97,$3A,$06,$06,$A3,$89,$0E,$08,$20 
   Data.b $12,$8E,$34,$B7,$88,$0E,$01,$0C,$13,$B7,$92,$CF,$5F,$7E,$CB,$DE,$98,$97,$64,$D5 
   Data.b $E1,$54,$22,$34,$16,$8D,$CE,$2D,$AF,$2E,$CD,$CE,$AF,$DD,$9E,$BB,$7D,$AF,$D0,$1E 
   Data.b $0E,$F9,$18,$6E,$BA,$B6,$09,$7D,$9D,$00,$8F,$B2,$2A,$47,$45,$CF,$A4,$CE,$86,$C9 
   Data.b $0D,$CF,$35,$55,$CD,$CF,$E5,$AB,$73,$D7,$3F,$83,$DC,$43,$50,$DC,$8A,$01,$40,$40 
   Data.b $78,$01,$98,$B0,$0A,$5A,$E9,$8B,$4B,$B7,$AE,$6C,$56,$3C,$2A,$29,$36,$F0,$59,$9E 
   Data.b $6C,$D4,$16,$47,$C2,$CE,$AF,$5E,$3B,$1A,$09,$46,$E6,$27,$F3,$A6,$2B,$DC,$08,$9F 
   Data.b $99,$9A,$A3,$D4,$41,$12,$09,$30,$BF,$E1,$03,$8A,$B5,$B2,$6F,$C7,$8D,$FA,$EE,$C1 
   Data.b $AD,$97,$57,$72,$44,$D1,$56,$A6,$A6,$07,$C6,$0E,$C8,$9A,$42,$9A,$B9,$45,$C2,$7E 
   Data.b $00,$25,$19,$D5,$32,$9B,$4B,$D7,$D6,$F3,$95,$BC,$47,$3A,$E2,$AC,$B7,$85,$EC,$1A 
   Data.b $EE,$38,$B1,$BF,$63,$F4,$C9,$3D,$38,$11,$14,$75,$B0,$6F,$7F,$E1,$F2,$07,$D3,$6F 
   Data.b $DF,$5A,$27,$18,$CB,$44,$F3,$19,$4B,$C4,$C2,$7E,$A5,$6A,$39,$A0,$E1,$B1,$EF,$6F 
   Data.b $93,$B7,$44,$D4,$F1,$34,$F1,$61,$DD,$B4,$61,$7A,$69,$66,$E0,$81,$DD,$F7,$3D,$C0 
   Data.b $00,$21,$E4,$51,$AE,$54,$97,$EB,$95,$6A,$C6,$65,$41,$89,$1F,$1A,$0A,$1C,$3D,$B4 
   Data.b $6B,$6F,$DC,$68,$EF,$4B,$31,$0A,$9C,$AA,$C3,$09,$92,$DA,$93,$0F,$7E,$47,$7E,$32 
   Data.b $B3,$F6,$E7,$F3,$35,$04,$65,$97,$7A,$25,$97,$CA,$9A,$5C,$B0,$1A,$03,$6D,$E1,$AD 
   Data.b $11,$6D,$7C,$71,$D1,$40,$4A,$D1,$2D,$77,$8D,$3C,$E4,$58,$8E,$6B,$D6,$88,$04,$81 
   Data.b $22,$DE,$80,$C8,$71,$DD,$84,$EA,$7A,$9E,$5F,$63,$A0,$2F,$1A,$3E,$72,$60,$7F,$E7 
   Data.b $50,$CA,$80,$0E,$85,$BA,$57,$54,$20,$D2,$A0,$E7,$7B,$BC,$86,$43,$F8,$E5,$53,$47 
   Data.b $4D,$86,$DE,$FB,$7C,$D9,$A2,$54,$14,$9F,$84,$20,$26,$B8,$3D,$AA,$65,$73,$25,$43 
   Data.b $02,$01,$02,$33,$75,$27,$1C,$0C,$76,$0F,$0C,$5B,$96,$25,$D2,$00,$10,$07,$9C,$D3 
   Data.b $90,$A6,$E8,$A9,$DE,$62,$CD,$12,$29,$2F,$79,$BE,$A2,$EB,$12,$64,$4C,$8F,$F9,$24 
   Data.b $0E,$81,$0C,$D6,$2D,$50,$31,$D5,$08,$02,$B2,$51,$47,$81,$44,$3C,$D4,$2D,$6E,$72 
   Data.b $1C,$CE,$A0,$08,$97,$2A,$CB,$73,$6B,$95,$D5,$9A,$13,$55,$B5,$56,$03,$F9,$90,$38 
   Data.b $8D,$62,$2C,$DE,$4A,$24,$89,$34,$13,$20,$6A,$88,$72,$88,$68,$23,$D8,$87,$43,$6D 
   Data.b $0A,$28,$94,$1B,$E6,$5C,$7A,$AD,$AF,$27,$A9,$27,$FA,$90,$E8,$0D,$DF,$F7,$2D,$53 
   Data.b $57,$CC,$CD,$05,$EB,$2F,$EF,$8E,$5F,$B8,$34,$AF,$02,$1A,$D0,$F4,$B8,$22,$DF,$B6 
   Data.b $EC,$B0,$1E,$D2,$55,$5E,$AF,$99,$E9,$9A,$9B,$D2,$14,$66,$89,$D6,$93,$D6,$36,$E6 
   Data.b $D3,$2B,$93,$89,$8E,$1E,$D4,$EC,$60,$91,$61,$D1,$9F,$D4,$77,$81,$12,$EF,$DB,$61 
   Data.b $00,$E0,$39,$74,$7E,$BD,$EA,$95,$4B,$CE,$FA,$0A,$0E,$71,$12,$95,$11,$B4,$2E,$5E 
   Data.b $99,$FC,$E1,$AF,$DF,$7C,$FB,$EC,$65,$5E,$B5,$2A,$65,$5B,$23,$78,$7B,$6F,$94,$88 
   Data.b $98,$7A,$BE,$2E,$23,$45,$42,$63,$3D,$49,$06,$99,$EB,$38,$B6,$EF,$7B,$76,$B5,$90 
   Data.b $BB,$83,$88,$48,$6E,$33,$CB,$90,$71,$CE,$28,$73,$7D,$D6,$3F,$BA,$2F,$28,$4B,$0A 
   Data.b $A7,$E9,$0D,$F3,$B6,$0B,$16,$33,$59,$93,$99,$5E,$08,$CE,$4C,$4D,$9D,$7E,$E3,$E3 
   Data.b $52,$D9,$6E,$EF,$6C,$BF,$87,$81,$A5,$4B,$8F,$EE,$1D,$DA,$33,$90,$92,$31,$B7,$3D 
   Data.b $1A,$24,$92,$80,$07,$C6,$A4,$2B,$16,$C9,$5B,$E2,$7A,$CB,$73,$3D,$86,$28,$51,$30 
   Data.b $51,$10,$11,$1E,$61,$0C,$64,$04,$08,$F6,$BB,$FB,$06,$FA,$86,$86,$D2,$2B,$B3,$B9 
   Data.b $62,$F5,$CC,$BF,$AE,$CA,$C0,$B5,$FE,$33,$B5,$7B,$6B,$C7,$A3,$21,$3E,$BC,$A5,$2D 
   Data.b $98,$AF,$9B,$8E,$D9,$3F,$10,$DF,$3B,$D8,$7D,$E2,$D8,$EE,$B3,$1F,$4E,$28,$80,$4B 
   Data.b $00,$48,$10,$07,$65,$F9,$9B,$0F,$6C,$B1,$AB,$B5,$D9,$C2,$CD,$96,$A8,$21,$61,$18 
   Data.b $0A,$27,$08,$56,$88,$AA,$81,$48,$10,$73,$06,$30,$02,$BA,$8A,$BC,$40,$A8,$A7,$BF 
   Data.b $B7,$96,$5E,$B0,$EB,$E6,$F4,$AA,$17,$8E,$C6,$E7,$67,$D7,$56,$16,$D6,$9E,$F9,$CD 
   Data.b $89,$EF,$BD,$D4,$3D,$35,$97,$D9,$91,$68,$51,$2C,$3B,$92,$8C,$94,$72,$F9,$3B,$CB 
   Data.b $F7,$22,$8A,$14,$56,$61,$22,$A0,$95,$6D,$3F,$5B,$AC,$7E,$31,$BD,$5A,$77,$E9,$C1 
   Data.b $E1,$6D,$E5,$C6,$E6,$F6,$91,$1D,$14,$30,$24,$5A,$4D,$91,$B8,$44,$38,$06,$5C,$C4 
   Data.b $53,$D3,$A4,$FE,$91,$01,$23,$18,$70,$1A,$76,$7A,$AD,$C6,$39,$3C,$B2,$B3,$77,$AC 
   Data.b $53,$A0,$51,$D1,$B9,$12,$47,$50,$85,$B8,$FD,$81,$ED,$BA,$AC,$67,$26,$D7,$1C,$DF 
   Data.b $E9,$0A,$2B,$61,$45,$D3,$08,$53,$98,$FF,$FA,$27,$33,$EF,$5E,$5B,$8E,$AB,$F2,$DD 
   Data.b $D5,$E5,$6D,$7B,$1F,$1B,$D9,$36,$26,$03,$0F,$11,$28,$1C,$04,$12,$02,$1A,$01,$2A 
   Data.b $E7,$BE,$47,$07,$76,$ED,$E9,$1A,$19,$94,$85,$6B,$B6,$3B,$18,$D5,$9E,$E8,$6F,$1B 
   Data.b $4B,$C6,$DA,$64,$B4,$39,$BB,$3C,$39,$B3,$CC,$82,$AA,$D9,$30,$33,$C5,$B2,$28,$A4 
   Data.b $E1,$64,$3C,$1E,$8D,$56,$28,$BF,$5B,$2C,$13,$40,$33,$9B,$A6,$A2,$1B,$D4,$77,$86 
   Data.b $76,$EE,$3A,$7E,$EC,$79,$BB,$51,$53,$24,$80,$9A,$11,$BC,$BF,$91,$68,$4D,$C1,$27 
   Data.b $DB,$8E,$26,$3A,$07,$47,$F7,$B5,$44,$34,$88,$F1,$DC,$F2,$BA,$C6,$59,$5C,$27,$AA 
   Data.b $AA,$24,$BB,$5B,$05,$FE,$2F,$5E,$9F,$7E,$FD,$AF,$1F,$94,$64,$B8,$E5,$50,$4F,$A8 
   Data.b $23,$60,$52,$2F,$DF,$28,$97,$6D,$D1,$D4,$BE,$C7,$44,$AD,$F3,$47,$8F,$3D,$F9,$D3 
   Data.b $1F,$BD,$42,$CD,$B2,$43,$DD,$26,$4D,$45,$0D,$49,$5C,$34,$12,$C0,$CC,$15,$D5,$A1 
   Data.b $00,$71,$92,$EF,$3E,$78,$38,$D1,$9A,$8A,$1A,$78,$72,$AD,$F8,$B7,$89,$A5,$06,$70 
   Data.b $6F,$5E,$9B,$3C,$73,$EE,$C6,$AD,$75,$F7,$EF,$67,$AE,$2E,$DE,$29,$F7,$0C,$0F,$46 
   Data.b $FA,$53,$23,$03,$2D,$C7,$C7,$BA,$DB,$C2,$3A,$E5,$C0,$E6,$3C,$AA,$72,$E0,$D8,$A9 
   Data.b $8E,$1E,$CB,$13,$5A,$E1,$A4,$82,$50,$93,$01,$7E,$E1,$D9,$13,$91,$50,$48,$14,$2A 
   Data.b $02,$4C,$68,$95,$F8,$04,$BE,$13,$0B,$06,$93,$3D,$43,$EB,$E9,$BB,$F9,$DC,$C6,$62 
   Data.b $B1,$96,$0C,$91,$72,$AD,$36,$BE,$9C,$73,$05,$D1,$83,$4A,$D7,$40,$D7,$B6,$78,$74 
   Data.b $7D,$2E,$B3,$B4,$51,$0B,$26,$E3,$14,$92,$42,$CD,$34,$54,$39,$15,$90,$25,$CE,$EF 
   Data.b $AE,$E5,$E7,$A6,$6E,$24,$C2,$DA,$C3,$63,$A3,$AE,$D5,$C0,$2F,$9E,$F8,$56,$2C,$A4 
   Data.b $23,$E6,$21,$21,$79,$02,$DF,$1C,$28,$A8,$99,$EE,$64,$32,$31,$3A,$D2,$21,$57,$32 
   Data.b $D9,$6C,$E5,$DA,$7C,$AE,$A7,$2B,$92,$48,$45,$2D,$D3,$6C,$6D,$89,$F9,$9C,$CF,$5D 
   Data.b $9B,$99,$99,$CB,$B6,$6C,$ED,$93,$E2,$C1,$7C,$A5,$86,$38,$97,$21,$76,$AA,$75,$99 
   Data.b $40,$3D,$64,$78,$5C,$D2,$02,$E1,$AE,$54,$62,$62,$7C,$02,$9F,$7C,$F6,$A9,$58,$C0 
   Data.b $60,$DC,$D7,$10,$14,$5D,$27,$E1,$FB,$5B,$BC,$41,$59,$4B,$24,$D0,$15,$B0,$1F,$D9 
   Data.b $F7,$8D,$42,$DD,$3F,$7F,$73,$AE,$3F,$15,$36,$5C,$AF,$51,$A8,$05,$90,$12,$8E,$05 
   Data.b $F6,$3E,$BC,$73,$DB,$9E,$FE,$85,$D5,$B5,$85,$BB,$9B,$98,$73,$B3,$58,$31,$AB,$0D 
   Data.b $59,$C6,$A1,$AE,$E1,$96,$A1,$5D,$B6,$65,$BD,$71,$FA,$F4,$D5,$2F,$6F,$E1,$93,$CF 
   Data.b $3C,$15,$09,$0A,$D6,$73,$D1,$07,$58,$80,$4F,$F0,$5B,$F0,$49,$00,$1C,$30,$4D,$57 
   Data.b $D4,$78,$B2,$A3,$33,$F5,$E2,$D3,$4F,$50,$3D,$F4,$CE,$D9,$4F,$93,$49,$7D,$68,$C7 
   Data.b $88,$4C,$68,$9D,$F8,$6A,$4B,$24,$5B,$35,$EF,$64,$8B,$E5,$8A,$E5,$E6,$8B,$84,$53 
   Data.b $84,$19,$53,$02,$46,$FF,$01,$28,$EB,$AB,$D3,$33,$0B,$93,$37,$45,$6E,$08,$66,$BE 
   Data.b $0C,$1D,$89,$08,$E6,$36,$A9,$2A,$E8,$07,$31,$C0,$58,$11,$02,$2D,$DC,$D2,$43,$11 
   Data.b $CF,$A7,$54,$56,$5F,$F9,$C9,$A9,$CE,$64,$CB,$E2,$EC,$6C,$81,$17,$CC,$46,$1E,$FB 
   Data.b $8C,$4B,$DB,$1A,$35,$AF,$5E,$B1,$DD,$5C,$51,$F4,$10,$D1,$75,$97,$B9,$E1,$DE,$9D 
   Data.b $24,$10,$28,$17,$37,$17,$E7,$26,$85,$C9,$84,$88,$2D,$71,$5D,$95,$A0,$A0,$1D,$16 
   Data.b $65,$29,$80,$D2,$54,$37,$C1,$77,$81,$28,$CF,$25,$D4,$67,$82,$57,$96,$47,$55,$CB 
   Data.b $1A,$D9,$36,$FA,$79,$1A,$14,$E7,$3F,$ED,$D1,$03,$C1,$96,$54,$7A,$AD,$14,$E4,$7E 
   Data.b $31,$93,$73,$AA,$A6,$DE,$16,$B0,$1A,$B5,$AD,$0F,$1D,$B1,$B5,$6E,$31,$79,$DC,$BC 
   Data.b $7C,$A1,$52,$CC,$AB,$04,$DB,$E2,$EF,$86,$22,$87,$0C,$24,$50,$87,$90,$4C,$64,$84 
   Data.b $65,$61,$0C,$47,$22,$6B,$6E,$B3,$7C,$B9,$D0,$04,$A1,$D6,$E2,$75,$02,$3F,$9B,$4E 
   Data.b $97,$37,$37,$CA,$25,$33,$6D,$84,$14,$66,$FB,$9B,$19,$C5,$B1,$1A,$0E,$8F,$18,$8A 
   Data.b $5F,$6F,$0C,$1E,$78,$68,$E0,$F0,$F3,$5F,$9C,$FB,$64,$EA,$C6,$C4,$9D,$85,$05,$21 
   Data.b $26,$B6,$4F,$35,$15,$20,$C3,$00,$9A,$CC,$C5,$37,$55,$E1,$44,$E1,$C0,$E0,$50,$FD 
   Data.b $0A,$60,$00,$AB,$80,$10,$AE,$29,$30,$A4,$C1,$FC,$7A,$7E,$7B,$5F,$E7,$E3,$8F,$EC 
   Data.b $6D,$ED,$4C,$69,$9D,$83,$72,$DB,$A0,$0D,$B4,$4C,$A1,$41,$9B,$47,$BC,$D1,$B1,$03 
   Data.b $3F,$FF,$FD,$9B,$99,$DB,$1B,$33,$B7,$6E,$5E,$BF,$3E,$91,$8C,$A8,$0C,$20,$21,$31 
   Data.b $C2,$6A,$24,$26,$36,$AC,$8B,$EB,$55,$AE,$21,$AE,$35,$47,$80,$E6,$84,$C1,$9B,$42 
   Data.b $2D,$DE,$50,$A2,$3A,$89,$05,$0B,$55,$F3,$E5,$5F,$BC,$FA,$C9,$7F,$CF,$BD,$74,$F2 
   Data.b $C5,$5F,$BE,$FA,$DA,$96,$A1,$61,$50,$AB,$B2,$5A,$59,$4C,$72,$40,$10,$62,$AD,$34 
   Data.b $5B,$AC,$7F,$36,$FE,$E5,$87,$67,$FF,$79,$67,$69,$76,$FF,$48,$BB,$68,$7B,$41,$7E 
   Data.b $A8,$48,$3F,$3E,$F5,$1C,$01,$B2,$0C,$34,$24,$06,$14,$70,$5F,$79,$BE,$1A,$21,$9B 
   Data.b $8B,$40,$85,$E0,$A5,$2B,$B7,$2E,$4D,$97,$8A,$9E,$4E,$51,$78,$E2,$CA,$B5,$F5,$EC 
   Data.b $C6,$48,$EF,$C0,$D5,$8E,$B6,$CC,$4D,$A6,$32,$DB,$45,$A0,$5C,$2E,$03,$A2,$BE,$FF 
   Data.b $E9,$E7,$6F,$7D,$F4,$78,$AF,$8E,$8E,$EC,$E9,$CF,$E5,$AA,$A5,$92,$25,$30,$F9,$B3 
   Data.b $EF,$1E,$FF,$C1,$A9,$E7,$05,$E1,$84,$EA,$F3,$AF,$0D,$47,$F7,$AF,$16,$BF,$28,$90 
   Data.b $24,$5C,$DD,$A8,$BC,$F3,$EF,$DB,$2B,$36,$8A,$C7,$60,$CF,$E0,$E0,$B9,$F7,$FF,$FE 
   Data.b $DC,$91,$43,$A3,$BD,$BD,$89,$47,$8E,$25,$BA,$BA,$5A,$36,$E7,$6C,$C7,$5F,$2B,$A3 
   Data.b $EE,$23,$2F,$78,$37,$A7,$2F,$5D,$B8,$10,$1C,$4E,$8C,$2F,$6C,$E4,$D2,$05,$88,$58 
   Data.b $38,$60,$3C,$7D,$FC,$31,$57,$E8,$C1,$D7,$24,$72,$EE,$C7,$E4,$FF,$0B,$43,$31,$C6 
   Data.b $2C,$AE,$D8,$76,$7B,$77,$17,$73,$78,$C3,$13,$68,$94,$65,$92,$DD,$2C,$15,$57,$73 
   Data.b $C3,$94,$8C,$1E,$3E,$5C,$82,$06,$B7,$D7,$FB,$F6,$1F,$85,$B1,$B6,$5C,$E1,$E3,$58 
   Data.b $4C,$B9,$5D,$F1,$55,$C6,$0D,$24,$A5,$29,$FD,$D3,$1F,$FF,$70,$F0,$F1,$6F,$4F,$CC 
   Data.b $CC,$10,$28,$71,$AC,$E1,$FB,$C2,$7F,$DF,$09,$5F,$CC,$DA,$44,$24,$C8,$CC,$36,$EE 
   Data.b $6E,$98,$12,$B6,$AD,$CD,$92,$EB,$A2,$CC,$CA,$9C,$28,$DF,$96,$60,$C0,$33,$D8,$FC 
   Data.b $AD,$F1,$52,$21,$A7,$A9,$4A,$BE,$88,$BB,$97,$B3,$EB,$5F,$5C,$35,$0B,$F9,$84,$2C 
   Data.b $02,$8D,$54,$00,$D2,$F5,$7A,$2C,$9E,$38,$78,$E8,$E1,$B5,$92,$AD,$1A,$51,$D2,$68 
   Data.b $98,$B3,$33,$19,$FE,$D5,$03,$CD,$39,$15,$F2,$52,$DD,$2E,$F1,$7C,$09,$98,$3E,$F0 
   Data.b $1B,$B5,$C2,$66,$A9,$DE,$70,$6D,$CF,$D1,$B4,$40,$53,$5B,$91,$60,$30,$09,$B6,$B5 
   Data.b $9E,$3C,$F9,$72,$3E,$73,$2F,$B3,$91,$9D,$9E,$BC,$91,$D0,$03,$42,$9A,$C4,$08,$64 
   Data.b $53,$EA,$EA,$46,$48,$D7,$2F,$9E,$3F,$FF,$E0,$E1,$87,$A1,$6B,$FD,$4F,$80,$01,$00 
   Data.b $EE,$11,$56,$24,$33,$0A,$3C,$CC,$00,$00,$00,$00,$49,$45,$4E,$44,$AE,$42,$60,$82 
EndDataSection
Right, bedtime for this idiot! :)
I may look like a mule, but I'm not a complete ass.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

Thank you for your advice, srod. Since blanking column 0 is the optimal method would you mind posting your work-around for catching the mouse cursor changing?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Here you are :

Code: Select all

;Prevent column zero being resized in a listicon with the appropriate cursor modifications.

#MainWindow=0 
#ListIconGadget1=1 

Global gOldHeaderProc

Procedure ExtendListCallback(hWnd, uMsg, wParam, lParam) 
  Result=#PB_ProcessPureBasicEvents 
  If uMsg=#WM_NOTIFY 
    *nmhdr.NMHEADER=lParam 
    If *nmhdr\hdr\code=#HDN_ITEMCHANGING And *nmhdr\iItem=0 
      *nmdata.HD_ITEM=*nmhdr\pitem 
      *nmdata\cxy=0 
    EndIf 
  EndIf 
  ProcedureReturn Result 
EndProcedure 

;Header proc.
Procedure.l headerProc(hwnd, uMsg, wParam, lParam) 
  Protected result
  Protected hdhittest.HD_HITTESTINFO, pt.point
  Select uMsg
    Case #WM_SETCURSOR
      hdhittest\iItem =1
      ;First we need to identify which divider item is being examined.
        GetCursorPos_(@pt)                                                                                                                                                           ;Screen co-ordinates.
        MapWindowPoints_(#Null, hwnd, @pt, 1)                                                                                                                                        ;Turn screen co-ordinates into ones relative to the left edge of the header control.
        hdhittest\pt\x = pt\x
        hdhittest\pt\y = pt\y
        SendMessage_(hwnd, #HDM_HITTEST, 0, @hdhittest)
        If hdhittest\iItem = 0 Or hdhittest\flags&#HHT_ONHEADER
          SetCursor_(LoadCursor_(0,#IDC_ARROW))
          result=#True
        Else
          result = CallWindowProc_(gOldHeaderProc, hwnd, uMsg, wParam, lParam) 
        EndIf
    Default
      result = CallWindowProc_(gOldHeaderProc, hwnd, uMsg, wParam, lParam) 
  EndSelect
  ProcedureReturn result
EndProcedure


If OpenWindow(#MainWindow,0,0,320,240,"Icon List",#PB_Window_ScreenCentered|#PB_Window_SystemMenu) 
   CreateGadgetList(WindowID(#MainWindow)) 
  ListIconGadget(#ListIconGadget1,0,0,320,200,"Column 0",0,#PB_ListIcon_FullRowSelect) 
  SetWindowCallback(@ExtendListCallback(),ParentWindowID) 
  
  ;Subclass the header in order to control the cursor. 
    headerWnd = SendMessage_(GadgetID(#ListIconGadget1),#LVM_GETHEADER,0,0)
    gOldHeaderProc = SetWindowLong_(headerWnd, #GWL_WNDPROC, @headerProc()) 
 
  AddGadgetColumn(#ListIconGadget1,1,"Column 1",298/3) 
  AddGadgetColumn(#ListIconGadget1,2,"Column 2",298/3) 
  AddGadgetColumn(#ListIconGadget1,3,"Column 3",298/3) 
  
  For i=0 To 4 
    AddGadgetItem(#ListIconGadget1,i,Chr(10)+"Row "+Str(i)) 
  Next i 
  
  Repeat 
    Select WaitWindowEvent() 
      Case #PB_Event_CloseWindow 
        Quit=1 
    EndSelect 
  Until Quit 
EndIf 
End 
I may look like a mule, but I'm not a complete ass.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

Ingenious. Thank you very much, srod. :)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

You're welcome. :)
I may look like a mule, but I'm not a complete ass.
Post Reply