Re: Do we have such a container control?
- From: DanS <t.h.i.s.n.t.h.a.t@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 02 Feb 2006 18:57:25 -0600
DanS <t.h.i.s.n.t.h.a.t@xxxxxxxxxxxxxxxxxxxxxx> wrote in
news:Xns975EC8BA639BFidispcom@xxxxxxxxxxxxxx:
Forgot that the below code needs the LV Alignment propery set to 0...or
lvwNone.
Of, course, you could try sending the LVM_SETITEMSPACING message to the
LV first, but for some reason I ended up doing it like below.
(Possibly to guarantee the horizontal scrollbar would not show up ? It
_was_ over a year ago and I don't think I would have gone thru all that
trouble for nothing.)
Yes, and what you can do by yourself is put the listitem where you want34
in the listview. I'm suprised noone said this.
A listitem has a .Top and .Left property. Setting these will allow you
move the listitem whereever you want.
You said the Item's are 32 x 32. Divide the width of the Listview, by
pixels, or whatever type of padding you want between them.menu
(Note: All Air Code from Memory....)
Dim colWidth as Long
Dim colNum as Long
Dim rowHeight as Long
Dim rowNum as Long
colWidth = 34 * screen.twipsperpixelX
rowHeight = colWidth
'Assume square 'Cells'
colNum = Int((LV.Width/Screen.TwipsPerPixelX) / colWidth)
'I'll use 5 in the example below, meaning the width will be 5 Icons
Now after the Images are loaded into the Imagelist....
Dim x as Long
Dim li as Listitem
For X = 1 to IL.ListImages.Count
'Add the Images to the LV
Set li = LV1.Listitems.Add x,ImageKey,,,,ImageKey
If x <= colNum Then
'It's 1 - 5
li.left = (x-1) * colWidth
'3 -1 =2 * colWidth or the start of the third column
Else
'you need to find the column it should be in
li.left = ((x Mod colNum) -1) * colWidth
'the Mod gives you the leftover of x/colNum.
'If it's the 11th image, it should be in the
'first column.
'(11 Mod 5) = 1 - 1 = 0 * colWidth = 0
Endif
'Now do the Y...or .Top
If x <= 5 then
'The REALLY easy one.
li.top = 0
Else
If (X Mod colNum) = 0 Then
li.top = ((X / colNum)-1) * rowHeight
Else
li.top = (X / colNum) * rowHeight
End IF
End If
Next X
If the LV gets resized, you'd have to account for that as well.
That is exactly what I did here:
http://users.adelphia.net/~thisnthat/lvicons.jpg
And after looking at it, I think I need to add a little more padding as
the icons are a little too close together. This is a menu editor for my
shell program that allows you to select an alternative icon for the
item. When you click on a file for the target, it extracts all theicons
in the file and places them in this listview.
The selection box I draw/erase manually, since I don't add a
'SelectedImage' for each as well.
That's the jist of it. Not guaranteeing the above code works as planned
as it is aircode, but I hope I explained it well enough where you can
pick up on any errors if there is any.
Regards,
DanS
"DanS" wrote:
=?Utf-8?B?QW5kcmV3?= <Andrew@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
news:DB39CFA0-6CD4-4C1C-B585-256E33C6E0BE@xxxxxxxxxxxxx:
Hello, friends,
We need display user selected .jpg images (32x32) one line by one
line in a form. However, since the number of images could vary, it
is hard for us to decide the size of container control, say a
panel, in advance.
So, we want a control to display a vertical/horizontal scroll bar
automatically when the number of images is big. Do we have such
kind of container control?
Help please. Thanks a lot.
Off the top of my head, I would think the easiest way would be to use
a listview in Icon view. You would have to load the images into an
ImageList first.
What exactly does one line by one line mean ?
.
- References:
- Re: Do we have such a container control?
- From: DanS
- Re: Do we have such a container control?
- Prev by Date: Re: Do we have such a container control?
- Next by Date: Re: Variable too small? Overflow
- Previous by thread: Re: Do we have such a container control?
- Next by thread: Need help regarding the program... Please help me.. It's very Urgent
- Index(es):
Relevant Pages
|