Home All Groups Group Topic Archive Search About

Do we have such a container control?

Author
1 Feb 2006 8:17 PM
Andrew
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.

Author
1 Feb 2006 9:03 PM
Ken Halter
Show quote Hide quote
"Andrew" <And***@discussions.microsoft.com> wrote in message
news:DB39CFA0-6CD4-4C1C-B585-256E33C6E0BE@microsoft.com...
> 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.

Since you mentioned "panel", I have to assume .Net.... if not .Net, search
the MSKB for "Scrollable Viewport"

You'll want to post that question in a .Net group.
They all contain "dotnet" or "vsnet" in their names.
This and all other groups on the MS server that start with
"microsoft.public.vb"
are for VB Classic (mostly VB5/6) and were in existance long before any .Net
products were released. While some of the code looks the same, they are very
different products and require a different set of groups.

Try one of these:
news://news.microsoft.com/microsoft.public.dotnet.general
news://news.microsoft.com/microsoft.public.dotnet.languages.vb
news://news.microsoft.com/microsoft.public.dotnet.languages.vb.controls
news://news.microsoft.com/microsoft.public.dotnet.framework.interop


--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Freeware 4 color Gradient Frame? http://www.vbsight.com/GradFrameCTL.htm
Author
1 Feb 2006 9:27 PM
Andrew
It is VB6.0, not .net

Show quoteHide quote
"Ken Halter" wrote:

> "Andrew" <And***@discussions.microsoft.com> wrote in message
> news:DB39CFA0-6CD4-4C1C-B585-256E33C6E0BE@microsoft.com...
> > 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.
>
> Since you mentioned "panel", I have to assume .Net.... if not .Net, search
> the MSKB for "Scrollable Viewport"
>
> You'll want to post that question in a .Net group.
> They all contain "dotnet" or "vsnet" in their names.
> This and all other groups on the MS server that start with
> "microsoft.public.vb"
> are for VB Classic (mostly VB5/6) and were in existance long before any .Net
> products were released. While some of the code looks the same, they are very
> different products and require a different set of groups.
>
> Try one of these:
> news://news.microsoft.com/microsoft.public.dotnet.general
> news://news.microsoft.com/microsoft.public.dotnet.languages.vb
> news://news.microsoft.com/microsoft.public.dotnet.languages.vb.controls
> news://news.microsoft.com/microsoft.public.dotnet.framework.interop
>
>
> --
> Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
> DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
> Freeware 4 color Gradient Frame? http://www.vbsight.com/GradFrameCTL.htm
>
>
>
Author
1 Feb 2006 9:42 PM
Karl E. Peterson
Andrew wrote:
> It is VB6.0, not .net

Ken clearly wasn't sure.  Did you *try* his advice?

http://www.google.com/search?q=%22scrollable+viewport%22+site%3Asupport.microsoft.com
--
Working without a .NET?
http://classicvb.org/
Author
2 Feb 2006 3:28 PM
Andrew
both help. thanks.

Show quoteHide quote
"Karl E. Peterson" wrote:

> Andrew wrote:
> > It is VB6.0, not .net
>
> Ken clearly wasn't sure.  Did you *try* his advice?
>
> http://www.google.com/search?q=%22scrollable+viewport%22+site%3Asupport.microsoft.com
> --
> Working without a .NET?
> http://classicvb.org/
>
>
>
Author
2 Feb 2006 12:18 PM
DanS
=?Utf-8?B?QW5kcmV3?= <And***@discussions.microsoft.com> wrote in
Show quoteHide quote
news:DB39CFA0-6CD4-4C1C-B585-256E33C6E0BE@microsoft.com:

> 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 ?
Author
2 Feb 2006 3:31 PM
Andrew
"one line by one line" should be "one row by one row"

A user may select 30 or 40 .jpg images, we will have to display them in that
container control in multiple rows (lines),

Listview is good, but all images are not close enough.
Ken and Karl's suggestion is good, but a picture box can only load one image
at a time.

So, we may have to do something by our own.

Show quoteHide quote
"DanS" wrote:

> =?Utf-8?B?QW5kcmV3?= <And***@discussions.microsoft.com> wrote in
> news:DB39CFA0-6CD4-4C1C-B585-256E33C6E0BE@microsoft.com:
>
> > 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 ?
>
Author
2 Feb 2006 3:59 PM
J French
On Thu, 2 Feb 2006 07:31:52 -0800, =?Utf-8?B?QW5kcmV3?=
<And***@discussions.microsoft.com> wrote:

>"one line by one line" should be "one row by one row"
>
>A user may select 30 or 40 .jpg images, we will have to display them in that
>container control in multiple rows (lines),
>
>Listview is good, but all images are not close enough.
>Ken and Karl's suggestion is good, but a picture box can only load one image
>at a time.

A Picturebox can only load one image, but you can Pic1.PaintPicture
any number of images onto that one image

.... which is what Karl was really suggesting

For neatness I would wrap the whole lot in a (non OCXed) Usercontrol
Author
2 Feb 2006 6:15 PM
Karl E. Peterson
J French wrote:
Show quoteHide quote
> On Thu, 2 Feb 2006 07:31:52 -0800, =?Utf-8?B?QW5kcmV3?=
> <And***@discussions.microsoft.com> wrote:
>
>> "one line by one line" should be "one row by one row"
>>
>> A user may select 30 or 40 .jpg images, we will have to display them
>> in that container control in multiple rows (lines),
>>
>> Listview is good, but all images are not close enough.
>> Ken and Karl's suggestion is good, but a picture box can only load
>> one image at a time.
>
> A Picturebox can only load one image, but you can Pic1.PaintPicture
> any number of images onto that one image
>
> ... which is what Karl was really suggesting

Yep, that'd be the efficient way.  And, it can also act as a container, for
an array of little Image controls that's built up as needed.

> For neatness I would wrap the whole lot in a (non OCXed) Usercontrol

Definitely.  In fact, I know I've run across exactly such things, over the
years.  I bet I even did it myself, at one point.
--
Working without a .NET?
http://classicvb.org/
Author
2 Feb 2006 7:48 PM
J French
On Thu, 2 Feb 2006 10:15:59 -0800, "Karl E. Peterson" <k***@mvps.org>
wrote:

<snip>

>> ... which is what Karl was really suggesting
>
>Yep, that'd be the efficient way.  And, it can also act as a container, for
>an array of little Image controls that's built up as needed.
>
>> For neatness I would wrap the whole lot in a (non OCXed) Usercontrol
>
>Definitely.  In fact, I know I've run across exactly such things, over the
>years.  I bet I even did it myself, at one point.

With a nice little array of Vectors encapsulated in UDTs
- so that one can detect which 'image' was clicked
(or is under the rodent)

Heh, my little opus even does 3D with a 'push' effect when the mouse
runs over it with a button down

It is quite amusing re-writing Windows in VB <g>
Author
2 Feb 2006 8:38 PM
Karl E. Peterson
J French wrote:
Show quoteHide quote
> On Thu, 2 Feb 2006 10:15:59 -0800, "Karl E. Peterson" <k***@mvps.org>
> wrote:
>
> <snip>
>
>>> ... which is what Karl was really suggesting
>>
>> Yep, that'd be the efficient way.  And, it can also act as a
>> container, for an array of little Image controls that's built up as
>> needed.
>>
>>> For neatness I would wrap the whole lot in a (non OCXed) Usercontrol
>>
>> Definitely.  In fact, I know I've run across exactly such things,
>> over the years.  I bet I even did it myself, at one point.
>
> With a nice little array of Vectors encapsulated in UDTs
> - so that one can detect which 'image' was clicked
>  (or is under the rodent)
>
> Heh, my little opus even does 3D with a 'push' effect when the mouse
> runs over it with a button down
>
> It is quite amusing re-writing Windows in VB <g>

<chuckle!>
--
Working without a .NET?
http://classicvb.org/
Author
3 Feb 2006 12:43 AM
DanS
=?Utf-8?B?QW5kcmV3?= <And***@discussions.microsoft.com> wrote in
news:B42663F0-D6A2-44AF-B5AA-3A26BD50932F@microsoft.com:

> "one line by one line" should be "one row by one row"
>
> A user may select 30 or 40 .jpg images, we will have to display them
> in that container control in multiple rows (lines),
>
> Listview is good, but all images are not close enough.
> Ken and Karl's suggestion is good, but a picture box can only load one
> image at a time.
>
> So, we may have to do something by our own.
>

Yes, and what you can do by yourself is put the listitem where you want
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 34
pixels, or whatever type of padding you want between them.

(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 menu
item. When you click on a file for the target, it extracts all the icons
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



Show quoteHide quote
> "DanS" wrote:
>
>> =?Utf-8?B?QW5kcmV3?= <And***@discussions.microsoft.com> wrote in
>> news:DB39CFA0-6CD4-4C1C-B585-256E33C6E0BE@microsoft.com:
>>
>> > 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 ?
>>
Author
3 Feb 2006 12:57 AM
DanS
DanS <t.h.i.s.n.t.h.a.t@a.d.e.l.p.h.i.a..n.e.t> wrote in
news:Xns975EC8BA639BFidispcom@216.196.97.142:

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.)



Show quoteHide quote
> Yes, and what you can do by yourself is put the listitem where you want
> 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
34
> pixels, or whatever type of padding you want between them.
>
> (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
menu
> item. When you click on a file for the target, it extracts all the
icons
> 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?= <And***@discussions.microsoft.com> wrote in
>>> news:DB39CFA0-6CD4-4C1C-B585-256E33C6E0BE@microsoft.com:
>>>
>>> > 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 ?
>>>
>
>