Jump to content
LarsJ

Checkboxes, overlay icons and state images in ListViews

Recommended Posts

Bowmore

Many thanks LarsJ. I've often struggled often getting it to work and never managed to get overlay icons to work. Your concise expanations and demos will be a big help the next time I need to use these. The sccreen shots are a great help with a topic such as this so we can see what the output should look like.


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites
Skysnake

Brilliant!

Many thanks! :)

 


Skysnake

Why is the snake in the sky?

Share this post


Link to post
Share on other sites
LarsJ
kklee69

I have a question. I don’t know if I can ask questions here.

I see two checkboxes in your example

Assuming I have three ICOs, I hope they can be side by side

Is there a way to do it?

like THIS 

180319160172b63fbd915c1adc.png.909690f05905befa35b18d36f911de85.png

Share this post


Link to post
Share on other sites
LarsJ

You cannot add 3 icons in a single listview cell with the techniques used here. But I'm pretty sure it's possible. One way is to use custom draw in the post paint stage and add the icons with GDI/GDI+ functions. Another way is to create an owner drawn listview and again add the icons with GDI/GDI+ functions. But none of the techniques are completely trivial. If you also want to click the icons one at a time, you'll need pretty much code.
 

A small advertisement: My next project will be published in this forum the first coming weekend (in four days). Don't miss the Examples forum this weekend.

Share this post


Link to post
Share on other sites
kklee69
5 hours ago, LarsJ said:

You cannot add 3 icons in a single listview cell with the techniques used here. But I'm pretty sure it's possible. One way is to use custom draw in the post paint stage and add the icons with GDI/GDI+ functions. Another way is to create an owner drawn listview and again add the icons with GDI/GDI+ functions. But none of the techniques are completely trivial. If you also want to click the icons one at a time, you'll need pretty much code.
 

A small advertisement: My next project will be published in this forum the first coming weekend (in four days). Don't miss the Examples forum this weekend.

as I know, ICO is a square  Like 16*16

Is this possible,Put three ICOs into one ICO

Then put this ICO into a single listview cell

Like a rectangular ICO

Share this post


Link to post
Share on other sites
LarsJ

Creating an image from 3 icons and displaying the image in a listview cell is certainly possible, and it should not be too hard.

Share this post


Link to post
Share on other sites
kklee69

But I can only make the icon 16*16 or 24*24

I cannot change the icon to 48*16

I tried to turn three icons into one icon

Then put this ICO into a single listview cell

It still displays an icon with a size of 16*16

Is there any sample of ListView with long icons?

Share this post


Link to post
Share on other sites
LarsJ

It's much easier than you think:

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>

Example()

Func Example()
  Local $hImage, $idListview

  GUICreate("ListView Create Solid BitMap", 400, 300)
  $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
  GUISetState(@SW_SHOW)

  ; Load images
  $hImage = _GUIImageList_Create( 48, 16 )
  _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0xFF0000, 48, 16))
  _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x00FF00, 48, 16))
  _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x0000FF, 48, 16))
  _GUICtrlListView_SetImageList($idListview, $hImage, 1)

  ; Add columns
  _GUICtrlListView_AddColumn($idListview, "Items", 100)

  ; Add items
  _GUICtrlListView_AddItem($idListview, "Item 1", 0)
  _GUICtrlListView_AddItem($idListview, "Item 2", 1)
  _GUICtrlListView_AddItem($idListview, "Item 3", 2)

  ; Loop until the user exits.
  Do
  Until GUIGetMsg() = $GUI_EVENT_CLOSE
  GUIDelete()
EndFunc   ;==>Example

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×