Home All Groups Group Topic Archive Search About
Author
31 May 2005 9:53 PM
Jack
Hello,
             Form has only 1 object: ListView, which fills the whole form.
ListView has 4 columns, which I want to resize proportionally with the
form's size.
My code looks like that:
Private Sub Form_Resize()
    lvOutLog.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
    lvOutLog.ColumnHeaders(1).Width = 1880 * (Me.ScaleWidth) / 8120
    lvOutLog.ColumnHeaders(2).Width = 1800 * (Me.ScaleWidth) / 8120
    lvOutLog.ColumnHeaders(3).Width = 1560 * (Me.ScaleWidth) / 8120
    lvOutLog.ColumnHeaders(4).Width = 1100 * (Me.ScaleWidth) / 8120
End Sub

The first value is the column width at design stage.
The last value (8120) is the form's ScaleWidth at design stage.

I am doing something wrong, because columns are NOT resizing proportionally
with the form.
What is wrong with that?

Author
31 May 2005 10:01 PM
Saga
I would multiply the % of the width that I would like the
column to be with respect to the form's wodth (or lists,
since you are setting them to be the same width).

Maybe something like this (air code)

>    lvOutLog.ColumnHeaders(1).Width = .18 * (Me.ScaleWidth)

Where .18 means that that you want the col width to occupy 18%
of the list's width.

I hope that sort of gets you going <g>

Good luck!
Saga

Show quoteHide quote
"Jack" <replyto@newsgroup> wrote in message
news:OO0iwsiZFHA.2756@tk2msftngp13.phx.gbl...
> Hello,
>             Form has only 1 object: ListView, which fills the whole
> form.
> ListView has 4 columns, which I want to resize proportionally with the
> form's size.
> My code looks like that:
> Private Sub Form_Resize()
>    lvOutLog.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
>    lvOutLog.ColumnHeaders(1).Width = 1880 * (Me.ScaleWidth) / 8120
>    lvOutLog.ColumnHeaders(2).Width = 1800 * (Me.ScaleWidth) / 8120
>    lvOutLog.ColumnHeaders(3).Width = 1560 * (Me.ScaleWidth) / 8120
>    lvOutLog.ColumnHeaders(4).Width = 1100 * (Me.ScaleWidth) / 8120
> End Sub
>
> The first value is the column width at design stage.
> The last value (8120) is the form's ScaleWidth at design stage.
>
> I am doing something wrong, because columns are NOT resizing
> proportionally with the form.
> What is wrong with that?
>
>
>
Author
31 May 2005 11:59 PM
Jack
I am looking for the correct calculation.
There must be something I omitted.
Anyone else?
Show quoteHide quote
"Saga" <antiSpam@somewhere.com> wrote in message
news:Ox0pAxiZFHA.2788@TK2MSFTNGP12.phx.gbl...
>
> I would multiply the % of the width that I would like the
> column to be with respect to the form's wodth (or lists,
> since you are setting them to be the same width).
>
> Maybe something like this (air code)
>
>>    lvOutLog.ColumnHeaders(1).Width = .18 * (Me.ScaleWidth)
>
> Where .18 means that that you want the col width to occupy 18%
> of the list's width.
>
> I hope that sort of gets you going <g>
>
> Good luck!
> Saga
>
> "Jack" <replyto@newsgroup> wrote in message
> news:OO0iwsiZFHA.2756@tk2msftngp13.phx.gbl...
>> Hello,
>>             Form has only 1 object: ListView, which fills the whole form.
>> ListView has 4 columns, which I want to resize proportionally with the
>> form's size.
>> My code looks like that:
>> Private Sub Form_Resize()
>>    lvOutLog.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
>>    lvOutLog.ColumnHeaders(1).Width = 1880 * (Me.ScaleWidth) / 8120
>>    lvOutLog.ColumnHeaders(2).Width = 1800 * (Me.ScaleWidth) / 8120
>>    lvOutLog.ColumnHeaders(3).Width = 1560 * (Me.ScaleWidth) / 8120
>>    lvOutLog.ColumnHeaders(4).Width = 1100 * (Me.ScaleWidth) / 8120
>> End Sub
>>
>> The first value is the column width at design stage.
>> The last value (8120) is the form's ScaleWidth at design stage.
>>
>> I am doing something wrong, because columns are NOT resizing
>> proportionally with the form.
>> What is wrong with that?
>>
>>
>>
>
>
Author
1 Jun 2005 12:23 AM
Peter Aitken
Show quote Hide quote
"Jack" <replyto@newsgroup> wrote in message
news:OO0iwsiZFHA.2756@tk2msftngp13.phx.gbl...
> Hello,
>             Form has only 1 object: ListView, which fills the whole form.
> ListView has 4 columns, which I want to resize proportionally with the
> form's size.
> My code looks like that:
> Private Sub Form_Resize()
>    lvOutLog.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
>    lvOutLog.ColumnHeaders(1).Width = 1880 * (Me.ScaleWidth) / 8120
>    lvOutLog.ColumnHeaders(2).Width = 1800 * (Me.ScaleWidth) / 8120
>    lvOutLog.ColumnHeaders(3).Width = 1560 * (Me.ScaleWidth) / 8120
>    lvOutLog.ColumnHeaders(4).Width = 1100 * (Me.ScaleWidth) / 8120
> End Sub
>
> The first value is the column width at design stage.
> The last value (8120) is the form's ScaleWidth at design stage.
>
> I am doing something wrong, because columns are NOT resizing
> proportionally with the form.
> What is wrong with that?
>
>

Try this:

>    lvOutLog.ColumnHeaders(1).Width = A * (Me.ScaleWidth)
> lvOutLog.ColumnHeaders(2).Width = B * (Me.ScaleWidth)
> lvOutLog.ColumnHeaders(3).Width = C * (Me.ScaleWidth)
>    lvOutLog.ColumnHeaders(4).Width = D * (Me.ScaleWidth)

A thru D are values < 1 that add up to 1. Each is proportional to the
desired column width.

Peter Aitken
Author
1 Jun 2005 1:17 AM
Jack
I tried.
Those numbers never add to 1.
That is very confusing.
At initial state the values calculated by vbasic were:
A 0.23
B 0.22
C 0.24
D 0.12
With those values there is not shown horizontal scrolling bar and all 4
columns occupy full space.
As soon as I start resizing (shrinking) window there is HSB shown at the
bottom which is normal, but as soon as I start increasing width the next
column (?) start showing up and increases in size. What is that anyway?
Show quoteHide quote
"Peter Aitken" <pait***@CRAPnc.rr.com> wrote in message
news:es%23kXAkZFHA.580@TK2MSFTNGP15.phx.gbl...
> "Jack" <replyto@newsgroup> wrote in message
> news:OO0iwsiZFHA.2756@tk2msftngp13.phx.gbl...
>> Hello,
>>             Form has only 1 object: ListView, which fills the whole form.
>> ListView has 4 columns, which I want to resize proportionally with the
>> form's size.
>> My code looks like that:
>> Private Sub Form_Resize()
>>    lvOutLog.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
>>    lvOutLog.ColumnHeaders(1).Width = 1880 * (Me.ScaleWidth) / 8120
>>    lvOutLog.ColumnHeaders(2).Width = 1800 * (Me.ScaleWidth) / 8120
>>    lvOutLog.ColumnHeaders(3).Width = 1560 * (Me.ScaleWidth) / 8120
>>    lvOutLog.ColumnHeaders(4).Width = 1100 * (Me.ScaleWidth) / 8120
>> End Sub
>>
>> The first value is the column width at design stage.
>> The last value (8120) is the form's ScaleWidth at design stage.
>>
>> I am doing something wrong, because columns are NOT resizing
>> proportionally with the form.
>> What is wrong with that?
>>
>>
>
> Try this:
>
>>    lvOutLog.ColumnHeaders(1).Width = A * (Me.ScaleWidth)
>> lvOutLog.ColumnHeaders(2).Width = B * (Me.ScaleWidth)
>> lvOutLog.ColumnHeaders(3).Width = C * (Me.ScaleWidth)
>>    lvOutLog.ColumnHeaders(4).Width = D * (Me.ScaleWidth)
>
> A thru D are values < 1 that add up to 1. Each is proportional to the
> desired column width.
>
> Peter Aitken
>
>
Author
1 Jun 2005 2:51 PM
Saga
Ok, round two ;-)

You have 4 colums in your list, so lets do this:


Private Sub Form_Resize()

lvOutLog.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
lvOutLog.ColumnHeaders(1).Width = 0.25 * (Me.ScaleWidth)
lvOutLog.ColumnHeaders(2).Width = 0.25 * (Me.ScaleWidth)
lvOutLog.ColumnHeaders(3).Width = 0.25 * (Me.ScaleWidth)
lvOutLog.ColumnHeaders(4).Width = 0.25 * (Me.ScaleWidth)

End Sub

This is not air code... I tested it and it works fine, assuming that
we have understood what you need. The .25 indicates that each
column takes up 1/4 of the form width. As you resize the form,
the widt of the columns changes so that the column width will
always be 1/4 of the form width. Notice how these .25s add up
to 1, which means that  the width of the 4 columns will span 100%
of the width of the form.

If you want your first column to be bigger (for example), then
you and change the .25 to .35 or .4 or .5 or whatever you need,
but you must also adjust the other values so that the sum of the four
constants do not go over 1, ie do not take more than 100% of the
width of the form (or list, since you set both to the same width). If
you have problems with the vertical scrollbar not showing, then you
need more space, so you reduce the 100% reference, which is the
Me.ScaleWidth value, so now you would do somethign like this:

lvOutLog.ColumnHeaders(4).Width = 0.25 * (Me.ScaleWidth-200)

200 is -usually- the width of the scroll bar (or was it 240?), anyways,
you just tweak that according to your needs.

Good luck!
Saga


Show quoteHide quote
"Jack" <replyto@newsgroup> wrote in message
news:e3alpekZFHA.4064@TK2MSFTNGP10.phx.gbl...
>I tried.
> Those numbers never add to 1.
> That is very confusing.
> At initial state the values calculated by vbasic were:
> A 0.23
> B 0.22
> C 0.24
> D 0.12
> With those values there is not shown horizontal scrolling bar and all
> 4 columns occupy full space.
> As soon as I start resizing (shrinking) window there is HSB shown at
> the bottom which is normal, but as soon as I start increasing width
> the next column (?) start showing up and increases in size. What is
> that anyway?
> "Peter Aitken" <pait***@CRAPnc.rr.com> wrote in message
> news:es%23kXAkZFHA.580@TK2MSFTNGP15.phx.gbl...
>> "Jack" <replyto@newsgroup> wrote in message
>> news:OO0iwsiZFHA.2756@tk2msftngp13.phx.gbl...
>>> Hello,
>>>             Form has only 1 object: ListView, which fills the whole
>>> form.
>>> ListView has 4 columns, which I want to resize proportionally with
>>> the form's size.
>>> My code looks like that:
>>> Private Sub Form_Resize()
>>>    lvOutLog.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
>>>    lvOutLog.ColumnHeaders(1).Width = 1880 * (Me.ScaleWidth) / 8120
>>>    lvOutLog.ColumnHeaders(2).Width = 1800 * (Me.ScaleWidth) / 8120
>>>    lvOutLog.ColumnHeaders(3).Width = 1560 * (Me.ScaleWidth) / 8120
>>>    lvOutLog.ColumnHeaders(4).Width = 1100 * (Me.ScaleWidth) / 8120
>>> End Sub
>>>
>>> The first value is the column width at design stage.
>>> The last value (8120) is the form's ScaleWidth at design stage.
>>>
>>> I am doing something wrong, because columns are NOT resizing
>>> proportionally with the form.
>>> What is wrong with that?
>>>
>>>
>>
>> Try this:
>>
>>>    lvOutLog.ColumnHeaders(1).Width = A * (Me.ScaleWidth)
>>> lvOutLog.ColumnHeaders(2).Width = B * (Me.ScaleWidth)
>>> lvOutLog.ColumnHeaders(3).Width = C * (Me.ScaleWidth)
>>>    lvOutLog.ColumnHeaders(4).Width = D * (Me.ScaleWidth)
>>
>> A thru D are values < 1 that add up to 1. Each is proportional to the
>> desired column width.
>>
>> Peter Aitken
>>
>>
>
>
Author
1 Jun 2005 3:45 PM
Larry Serflaten
"Saga" <antiSpam@somewhere.com> wrote

> This is not air code... I tested it and it works fine,

It did not work for me, it seems the columns use a different
scale in the listview I see.  (VB5 on W2K).

I put tick marks on the form above the listview:

Private Sub Form_Resize()
Dim sw As Single
    sw = ScaleWidth * 0.8
    Cls
    With ListView1
    .Move 0, 180, Me.ScaleWidth, Me.ScaleHeight - 180
    .ColumnHeaders(1).Width = 0.25 * sw
    Line (0.25 * sw, 0)-Step(0, 180)
    .ColumnHeaders(2).Width = 0.25 * sw
    Line (0.5 * sw, 0)-Step(0, 180)
    .ColumnHeaders(3).Width = 0.25 * sw
    Line (0.75 * sw, 0)-Step(0, 180)
    .ColumnHeaders(4).Width = 0.25 * sw
    Line (sw, 0)-Step(0, 180)
    End With
End Sub


And with that, I could resize the form small enough so that the
tick mark for the last column was above the tail end of the
second column.  Expanding to full width of the screen puts that
same tick mark at about 3/4 of the forth column.

What I ended up having to do was to subtract out an offset
value, as if they forgot to include the borders in their calculations:


Private Sub Form_Resize()
Dim sw As Single
Dim ofs As Long
    ofs = 300
    sw = ScaleWidth - 90  ' Avoids HSB
    Cls
    With ListView1
    .Move 0, 180, Me.ScaleWidth, Me.ScaleHeight - 180
    .ColumnHeaders(1).Width = 0.25 * sw - ofs
    Line (0.25 * sw, 0)-Step(0, 180)
    .ColumnHeaders(2).Width = 0.25 * sw - ofs
    Line (0.5 * sw, 0)-Step(0, 180)
    .ColumnHeaders(3).Width = 0.25 * sw - ofs
    Line (0.75 * sw, 0)-Step(0, 180)
    .ColumnHeaders(4).Width = 0.25 * sw - ofs
    Line (sw, 0)-Step(0, 180)
    End With
End Sub


HTH
LFS
Author
2 Jun 2005 2:56 AM
Jack
You are right Larry.
I found out that substracting 1440 from Me.ScaleWidth do the job.
I am using vbasic5 too :)
Thanks,
              Jack
Show quoteHide quote
"Larry Serflaten" <serfla***@usinternet.com> wrote in message
news:%23SYPjBsZFHA.3620@TK2MSFTNGP09.phx.gbl...
>
> "Saga" <antiSpam@somewhere.com> wrote
>
>> This is not air code... I tested it and it works fine,
>
> It did not work for me, it seems the columns use a different
> scale in the listview I see.  (VB5 on W2K).
>
> I put tick marks on the form above the listview:
>
> Private Sub Form_Resize()
> Dim sw As Single
>    sw = ScaleWidth * 0.8
>    Cls
>    With ListView1
>    .Move 0, 180, Me.ScaleWidth, Me.ScaleHeight - 180
>    .ColumnHeaders(1).Width = 0.25 * sw
>    Line (0.25 * sw, 0)-Step(0, 180)
>    .ColumnHeaders(2).Width = 0.25 * sw
>    Line (0.5 * sw, 0)-Step(0, 180)
>    .ColumnHeaders(3).Width = 0.25 * sw
>    Line (0.75 * sw, 0)-Step(0, 180)
>    .ColumnHeaders(4).Width = 0.25 * sw
>    Line (sw, 0)-Step(0, 180)
>    End With
> End Sub
>
>
> And with that, I could resize the form small enough so that the
> tick mark for the last column was above the tail end of the
> second column.  Expanding to full width of the screen puts that
> same tick mark at about 3/4 of the forth column.
>
> What I ended up having to do was to subtract out an offset
> value, as if they forgot to include the borders in their calculations:
>
>
> Private Sub Form_Resize()
> Dim sw As Single
> Dim ofs As Long
>    ofs = 300
>    sw = ScaleWidth - 90  ' Avoids HSB
>    Cls
>    With ListView1
>    .Move 0, 180, Me.ScaleWidth, Me.ScaleHeight - 180
>    .ColumnHeaders(1).Width = 0.25 * sw - ofs
>    Line (0.25 * sw, 0)-Step(0, 180)
>    .ColumnHeaders(2).Width = 0.25 * sw - ofs
>    Line (0.5 * sw, 0)-Step(0, 180)
>    .ColumnHeaders(3).Width = 0.25 * sw - ofs
>    Line (0.75 * sw, 0)-Step(0, 180)
>    .ColumnHeaders(4).Width = 0.25 * sw - ofs
>    Line (sw, 0)-Step(0, 180)
>    End With
> End Sub
>
>
> HTH
> LFS
>
>
Author
2 Jun 2005 2:54 AM
Jack
It does not work for me and thats why I started this thread.
Larry, below mentioned about vbasic version relation.
It is quite likely.
I am still using vbasic 5 and I do not want any other version.
Do you know vbasic5 loads ListView items 20 times faster then vbasic6?
Anyway I have found solution to my problem.
I need to substract 1440 from Me.ScaleWidth and then use fraction of it.
It works fine now.
Thanks,
Jack
Show quoteHide quote
"Saga" <antiSpam@somewhere.com> wrote in message
news:edOTilrZFHA.1448@TK2MSFTNGP09.phx.gbl...
>
> Ok, round two ;-)
>
> You have 4 colums in your list, so lets do this:
>
>
> Private Sub Form_Resize()
>
> lvOutLog.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
> lvOutLog.ColumnHeaders(1).Width = 0.25 * (Me.ScaleWidth)
> lvOutLog.ColumnHeaders(2).Width = 0.25 * (Me.ScaleWidth)
> lvOutLog.ColumnHeaders(3).Width = 0.25 * (Me.ScaleWidth)
> lvOutLog.ColumnHeaders(4).Width = 0.25 * (Me.ScaleWidth)
>
> End Sub
>
> This is not air code... I tested it and it works fine, assuming that
> we have understood what you need. The .25 indicates that each
> column takes up 1/4 of the form width. As you resize the form,
> the widt of the columns changes so that the column width will
> always be 1/4 of the form width. Notice how these .25s add up
> to 1, which means that  the width of the 4 columns will span 100%
> of the width of the form.
>
> If you want your first column to be bigger (for example), then
> you and change the .25 to .35 or .4 or .5 or whatever you need,
> but you must also adjust the other values so that the sum of the four
> constants do not go over 1, ie do not take more than 100% of the
> width of the form (or list, since you set both to the same width). If
> you have problems with the vertical scrollbar not showing, then you
> need more space, so you reduce the 100% reference, which is the
> Me.ScaleWidth value, so now you would do somethign like this:
>
> lvOutLog.ColumnHeaders(4).Width = 0.25 * (Me.ScaleWidth-200)
>
> 200 is -usually- the width of the scroll bar (or was it 240?), anyways,
> you just tweak that according to your needs.
>
> Good luck!
> Saga
>
>
> "Jack" <replyto@newsgroup> wrote in message
> news:e3alpekZFHA.4064@TK2MSFTNGP10.phx.gbl...
>>I tried.
>> Those numbers never add to 1.
>> That is very confusing.
>> At initial state the values calculated by vbasic were:
>> A 0.23
>> B 0.22
>> C 0.24
>> D 0.12
>> With those values there is not shown horizontal scrolling bar and all 4
>> columns occupy full space.
>> As soon as I start resizing (shrinking) window there is HSB shown at the
>> bottom which is normal, but as soon as I start increasing width the next
>> column (?) start showing up and increases in size. What is that anyway?
>> "Peter Aitken" <pait***@CRAPnc.rr.com> wrote in message
>> news:es%23kXAkZFHA.580@TK2MSFTNGP15.phx.gbl...
>>> "Jack" <replyto@newsgroup> wrote in message
>>> news:OO0iwsiZFHA.2756@tk2msftngp13.phx.gbl...
>>>> Hello,
>>>>             Form has only 1 object: ListView, which fills the whole
>>>> form.
>>>> ListView has 4 columns, which I want to resize proportionally with the
>>>> form's size.
>>>> My code looks like that:
>>>> Private Sub Form_Resize()
>>>>    lvOutLog.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
>>>>    lvOutLog.ColumnHeaders(1).Width = 1880 * (Me.ScaleWidth) / 8120
>>>>    lvOutLog.ColumnHeaders(2).Width = 1800 * (Me.ScaleWidth) / 8120
>>>>    lvOutLog.ColumnHeaders(3).Width = 1560 * (Me.ScaleWidth) / 8120
>>>>    lvOutLog.ColumnHeaders(4).Width = 1100 * (Me.ScaleWidth) / 8120
>>>> End Sub
>>>>
>>>> The first value is the column width at design stage.
>>>> The last value (8120) is the form's ScaleWidth at design stage.
>>>>
>>>> I am doing something wrong, because columns are NOT resizing
>>>> proportionally with the form.
>>>> What is wrong with that?
>>>>
>>>>
>>>
>>> Try this:
>>>
>>>>    lvOutLog.ColumnHeaders(1).Width = A * (Me.ScaleWidth)
>>>> lvOutLog.ColumnHeaders(2).Width = B * (Me.ScaleWidth)
>>>> lvOutLog.ColumnHeaders(3).Width = C * (Me.ScaleWidth)
>>>>    lvOutLog.ColumnHeaders(4).Width = D * (Me.ScaleWidth)
>>>
>>> A thru D are values < 1 that add up to 1. Each is proportional to the
>>> desired column width.
>>>
>>> Peter Aitken
>>>
>>>
>>
>>
>
>