[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.vb.general.discussion

Controls on maximised form

scbs29

2/20/2012 2:46:00 PM

Hello all
I want to calculate sizes and positions of controls on a form when the
form is displayed maximised. The program will be run on 2 pcs with
different screen sizes and resolutions. I want to position the
controls in a 'pleasing' layout on either pc. I have found some
classes etc that resize and reposition controls when a form is resized
dynamically, but this is not what I want since the form will only ever
be displayed at fullscreen.
I gather that it is a relatively simple job to calculate what I want,
so I tried it. It did not work in any logical fashion, eg. to position
a button at the bottom of the maximised screen needed something like
button.top = me.height - button.height *3\1.25.
I then tried another approach.
I designed the form and when it was displayed I showed Me.Height,
which was 9585. I then reran the program with Me.Windowstate =
vbMaximized on form load, and Me.Height was still 9585, so of course
calculations did not work.
I know that there is something simple that I am overlooking, but at
the moment I cannot see what.
Can anyone advise me ?
TIA

remove fred before emailing
Registered Linux User 490858
9 Answers

Bob Butler

2/20/2012 3:13:00 PM

0


"scbs29" <scbs29@fred.talktalk.net> wrote in message
news:d0n4k717c6b7jpgiob6q88lu0gsguuq9ho@4ax.com...
> Hello all
> I want to calculate sizes and positions of controls on a form when the
> form is displayed maximised. The program will be run on 2 pcs with
> different screen sizes and resolutions. I want to position the
> controls in a 'pleasing' layout on either pc. I have found some
> classes etc that resize and reposition controls when a form is resized
> dynamically, but this is not what I want since the form will only ever
> be displayed at fullscreen.
> I gather that it is a relatively simple job to calculate what I want,
> so I tried it. It did not work in any logical fashion, eg. to position
> a button at the bottom of the maximised screen needed something like
> button.top = me.height - button.height *3\1.25.

The Height property includes the window borders. Try using ScaleHeight
instead since that reports just the client area and uses whatever ScaleMode
has been defined as the unit.

scbs29

2/20/2012 3:33:00 PM

0

On Mon, 20 Feb 2012 07:12:46 -0800, "Bob Butler"
<bob_butler@cox.invalid> wrote:

>
>"scbs29" <scbs29@fred.talktalk.net> wrote in message
>news:d0n4k717c6b7jpgiob6q88lu0gsguuq9ho@4ax.com...
>> Hello all
>> I want to calculate sizes and positions of controls on a form when the
>> form is displayed maximised. The program will be run on 2 pcs with
>> different screen sizes and resolutions. I want to position the
>> controls in a 'pleasing' layout on either pc. I have found some
>> classes etc that resize and reposition controls when a form is resized
>> dynamically, but this is not what I want since the form will only ever
>> be displayed at fullscreen.
>> I gather that it is a relatively simple job to calculate what I want,
>> so I tried it. It did not work in any logical fashion, eg. to position
>> a button at the bottom of the maximised screen needed something like
>> button.top = me.height - button.height *3\1.25.
>
>The Height property includes the window borders. Try using ScaleHeight
>instead since that reports just the client area and uses whatever ScaleMode
>has been defined as the unit.

Thanks, that seemed to do it for a button.
I assume that I can use ScaleWidth for horizontal positioning.
Now just need to sort out sizes of other controls.

remove fred before emailing
Registered Linux User 490858

Mike Williams

2/20/2012 5:39:00 PM

0

"scbs29" <scbs29@fred.talktalk.net> wrote in message
news:d0n4k717c6b7jpgiob6q88lu0gsguuq9ho@4ax.com...
> I gather that it is a relatively simple job to calculate what
> I want, so I tried it. It did not work in any logical fashion,
> eg. to position a button at the bottom of the maximised
> screen needed something like button.top = me.height -
> button.height *3\1.25. I then tried another approach.
> I designed the form and when it was displayed I showed
> Me.Height, which was 9585. I then reran the program
> with Me.Windowstate = vbMaximized on form load,
> and Me.Height was still 9585, so of course calculations
> did not work.

Bob has already answered one part of your question (ie use Me.ScaleHeight
and Me.ScaleWidth instead of Me.Height and Me.Width). The answer to the
other part of your question is that the Height and Width (and the
ScaleHeight and ScaleWidth) of a Form will be related to its design time
Height and Width until the Form has been shown, and that does not normally
occur until after the Load event has finished, regardless of whether you set
vbMaximized in the IDE properties window or whether you set it in code in
the Load event. There are other places to put your positioning code but if
you want to do it in the Load event (which is fine) then you should precede
the appropriate lines with a Me.Show, for example:

Private Sub Form_Load()
Me.WindowState = vbMaximized
Me.Show
Command1.Left = Me.ScaleWidth - Command1.Width
Command1.Top = Me.ScaleHeight - Command1.Height
End Sub

If you do not include the Me.Show then the Command Button will not be
positioned correctly.

Mike


scbs29

2/20/2012 6:16:00 PM

0

On Mon, 20 Feb 2012 17:39:05 -0000, "Mike Williams"
<Mike@WhiskyAndCoke.com> wrote:

>"scbs29" <scbs29@fred.talktalk.net> wrote in message
>news:d0n4k717c6b7jpgiob6q88lu0gsguuq9ho@4ax.com...
>> I gather that it is a relatively simple job to calculate what
>> I want, so I tried it. It did not work in any logical fashion,
>> eg. to position a button at the bottom of the maximised
>> screen needed something like button.top = me.height -
snip
>If you do not include the Me.Show then the Command Button will not be
>positioned correctly.
>
>Mike
>

Thanks for the advice.
I thought it was something simple that I was missing.
Hopefully will have chance to try it all out in the next few days.

remove fred before emailing
Registered Linux User 490858

mm

2/21/2012 6:01:00 AM

0


"scbs29" <scbs29@fred.talktalk.net> escribió en el mensaje
news:d0n4k717c6b7jpgiob6q88lu0gsguuq9ho@4ax.com...
> Hello all
> I want to calculate sizes and positions of controls on a form when the
> form is displayed maximised. The program will be run on 2 pcs with
> different screen sizes and resolutions. I want to position the
> controls in a 'pleasing' layout on either pc. I have found some
> classes etc that resize and reposition controls when a form is resized
> dynamically, but this is not what I want since the form will only ever
> be displayed at fullscreen.
> I gather that it is a relatively simple job to calculate what I want,
> so I tried it. It did not work in any logical fashion, eg. to position
> a button at the bottom of the maximised screen needed something like
> button.top = me.height - button.height *3\1.25.
> I then tried another approach.
> I designed the form and when it was displayed I showed Me.Height,
> which was 9585. I then reran the program with Me.Windowstate =
> vbMaximized on form load, and Me.Height was still 9585, so of course
> calculations did not work.
> I know that there is something simple that I am overlooking, but at
> the moment I cannot see what.
> Can anyone advise me ?
> TIA

Place the positioning code in the Form_Resize event procedure.


scbs29

2/22/2012 2:16:00 PM

0

On Tue, 21 Feb 2012 03:00:45 -0300, "Eduardo" <mm@mm.com> wrote:

>
>"scbs29" <scbs29@fred.talktalk.net> escribió en el mensaje
>news:d0n4k717c6b7jpgiob6q88lu0gsguuq9ho@4ax.com...
>> Hello all
>> I want to calculate sizes and positions of controls on a form when the
>> form is displayed maximised. The program will be run on 2 pcs with
snip
>> the moment I cannot see what.
>> Can anyone advise me ?
>> TIA
>
>Place the positioning code in the Form_Resize event procedure.
>

Thanks for all of the help and suggestions.
I have tried them out and it appears so far that I can lay out the
form as I want to.
The only thing I found was that if I put the control resize code into
the Resize event then when the form was first displayed the controls
were shown at their original positions and sizes. The controls then
disappeared and were redrawn at the new sizes and positions. This
looked rather 'bitty', so I changed the form load event to

Me.WindowState = vbMaximized
Me.Show
ResizeAll - sub for control resizing

This takes slightly longer to load the form, but on first display the
controls are positioned and sized correctly.


remove fred before emailing
Registered Linux User 490858

Dee Earley

2/23/2012 10:35:00 AM

0

On 20/02/2012 14:46, scbs29 wrote:
> Hello all
> I want to calculate sizes and positions of controls on a form when the
> form is displayed maximised. The program will be run on 2 pcs with
> different screen sizes and resolutions. I want to position the
> controls in a 'pleasing' layout on either pc. I have found some
> classes etc that resize and reposition controls when a form is resized
> dynamically, but this is not what I want since the form will only ever
> be displayed at fullscreen.

One point that's been overlooked is that larger screen and window sizes
are supposed to give more space rather than just making all controls
proportionally bigger.

If someone wants a QXGA, 25" screen, they don't really want several inch
size buttons (unless of course they adjust the DPI).
The common case is to have an obvious (maybe a set of) controls that
expand with the rest of the controls around the edge (Think about a word
processor or Explorer)

--
Deanna Earley (dee.earley@icode.co.uk)
i-Catcher Development Team
http://www.icode.co.uk...

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)

Mike Williams

2/23/2012 12:27:00 PM

0

"Deanna Earley" <dee.earley@icode.co.uk> wrote in message
news:ji54nv$k5c$1@speranza.aioe.org...

> One point that's been overlooked is that larger screen and
> window sizes are supposed to give more space rather than
> just making all controls proportionally bigger.

Agreed, in most cases. But I don't think it's been overlooked, rather just
taken for granted. My own code snippet in response to the OP simply
positioned the Command Button (or whatever) at the required position, it did
not resize it. The only time you should resize a control over its design
time size is when the target machine's dpi settings are greater than the
normal 96 pixels per logical inch, indicating that the user actually does
want the pixel size of things to be greater on his screen than they
otherwise would be (which of course is the purpose of dpi settings). In fact
a standard compiled VB6 exe already performs dpi resizing of controls
automatically for you, drawing a larger pixel size Control (a Command Button
for example) on a 144 dpi machine than it would on a 96 dpi machine.

The VB6 compiled exe also automatically repositions the Control accordingly,
expanding its Top and Left properties by the same ratio (144/96). It also
attempts to expand the size of the client area of the Form by the same
ratio, so that all the expanded Controls at their new expanded positions fit
the newly expanded Form in the same way as they did at design time. In other
words, VB attempts to draw the entire Form and all its Controls such that in
pixel terms the whole thing is a 'magnified copy' of the design time Form.
In fact if the pixel size of the Form is small relative to the pixel size of
the screen then VB is very successful at doing this, and as such a compiled
VB6 exe is dpi aware by default. The problems of course arise when VB is
forced to produce a smaller pixel size Form than it would have liked to do
because of the limitation of the size of the screen, resulting in Controls
disappearing off the right and bottom edges of the Form. So, a VB6 exe is by
default at least partially dpi aware, but it needs some help from the
programmer in order to make itself fully so.

Mike



scbs29

2/23/2012 8:18:00 PM

0

On Thu, 23 Feb 2012 12:26:51 -0000, "Mike Williams"
<Mike@WhiskyAndCoke.com> wrote:

>"Deanna Earley" <dee.earley@icode.co.uk> wrote in message
>news:ji54nv$k5c$1@speranza.aioe.org...
>
>> One point that's been overlooked is that larger screen and
>> window sizes are supposed to give more space rather than
>> just making all controls proportionally bigger.
>
>Agreed, in most cases. But I don't think it's been overlooked, rather just
>taken for granted. My own code snippet in response to the OP simply
>positioned the Command Button (or whatever) at the required position, it did
snip
>forced to produce a smaller pixel size Form than it would have liked to do
>because of the limitation of the size of the screen, resulting in Controls
>disappearing off the right and bottom edges of the Form. So, a VB6 exe is by
>default at least partially dpi aware, but it needs some help from the
>programmer in order to make itself fully so.
>
>Mike
>
>

Again interesting replies.
My app displays images in image boxes on the form. There could be 1,
2, 4, 6, 7, 8, 9, 10, 12 images. I just want to alter the sizes and
positions of the image boxes while moving the buttons to the bottom of
the form.
As I said, I think that I am nearly there, just some tweaking needed.

remove fred before emailing
Registered Linux User 490858