 |
 |

04-28-2002, 10:30 AM
|
|
Senior Contributor
|
|
Join Date: Oct 2001
Location: North Carolina of the U.S.A.
Posts: 1,008
|
|
Form_Resize() - Resizing all controls.
|
I'm about to pull my hair out over here. My subs
and functions usually work perfectly and and look
beautiful as far as layout and indention and that
type of thing. But anyways, I'm making some code
for my Form_Resize() sub and I don't like it
because I'm just about hardcoding every value into
it. I mean, look at this ugly code...
Code:
Private Sub Form_Resize()
' The tabbed menu...
With tabMenu
.Width = Me.Width - 170
' If the height of this form is
' greater than 900 than continue...
If (Me.Height >= 900) Then
.Height = Me.Height - 1500
End If
lstviewFiles.Width = .Width - 2000
lstviewFiles.Height = .Height - 2000
lstWindows.Width = .Width - 2000
lstWindows.Height = .Height - 1200
End With
If (tabMenu.TabCaption(tabMenu.Tab) = "Windows") Then
Dim intcmdWindows As Integer
' Loop through our cmdWindows array...
For intcmdWindows = cmdWindows.LBound To cmdWindows.UBound
cmdWindows(intcmdWindows).Left = lstWindows.Width + 600
Next intcmdWindows
lnHoriz1.X1 = cmdWindows(1).Left
lnHoriz1.X2 = lnHoriz1.X1 + cmdWindows(1).Width
End If
End Sub
It works fine, then next thing I know it
fails on me. The controls maybe would be a little shorter
or longer in height or width or something like that. I
need improvement type help on this. I mean, I think
I should use me.ScaleHeight instead of using me.Height. Maybe
I should use me.scaleWidth instead of me.Width.
Anyways, I just can't stand to look at it no longer.
Please help if you can.
|
|

04-28-2002, 02:32 PM
|
|
Senior Contributor
|
|
Join Date: Oct 2001
Location: North Carolina of the U.S.A.
Posts: 1,008
|
|
I just wanted to say this problem was resolved by yours truly.
Edit: NEVERMIND: The controls still come up short?
|
Last edited by Agent; 04-28-2002 at 02:58 PM.
|

04-28-2002, 05:56 PM
|
 |
Bit Flipper
|
|
Join Date: Feb 2002
Location: The Inner Loop
Posts: 5,550
|
|
|
Can you tell us what you tried, and if it fixed any part of your problem?
Let me give you my advice:
The code is really not that bad "looking", but there are a couple of improvemnts you could make to the functionality which may help with your problem.
The reason your controls are no longer the correct size is that you are explicitly changing their size (to a set size) in your code.
Yes you should be using the ScaleHeight and ScaleWidth properties of the form.
You do have the right idea about only changing the controls when the size of the form reaches a certain criteriea but I hope the 900 is in twips, not pixels.
I am attaching a project I just wrote specificly for this post, have a look and see if it helps you out, take special notice of the positioning of the text boxes in design view. I feel that if you are using the Resize event for adjusting controls then there is no need to line them up at all in design view.
HTH,
Orbity
|
Last edited by Orbity; 04-28-2002 at 06:10 PM.
|

04-28-2002, 07:18 PM
|
|
Senior Contributor
|
|
Join Date: Oct 2001
Location: North Carolina of the U.S.A.
Posts: 1,008
|
|
Quote:
|
The reason your controls are no longer the correct size is that you are explicitly changing their size (to a set size) in your code.
|
Well, you made a good example and thanks for it but see... I want/need to subtract maybe 300 pixels from the width, or something like that.
The truth is I really need to learn about scaleheight and scalewidth, pixels, twips and whatever about screen/form properties.
Thanks alot.
Anybody know any good tutorials about that???
|
|

04-28-2002, 07:40 PM
|
 |
Bit Flipper
|
|
Join Date: Feb 2002
Location: The Inner Loop
Posts: 5,550
|
|
It is really pretty straight forwrad:
Me.ScaleLeft 'Left of the client area
Me.ScaleTop 'Top of the client area
Me.ScaleWidth 'Width of the client area
Me.ScaleHeight 'Height of the client area
Screen.TwipsPerPixelX 'How many twips per pixel horizontally
Screen.TwipsPerPixelY 'How many twips per pixel vertically
This is how to find the number of pixels wide and tall your form's client area is when the form's scale mode is set to pixels:
Code:
Debug.Print Me.ScaleWidth / Screen.TwipsPerPixelX
Debug.Print Me.ScaleHeight / Screen.TwipsPerPixelY
Did this clear anything up, if not what is still confusing you?
Orbity
|
|

04-28-2002, 08:02 PM
|
|
Senior Contributor
|
|
Join Date: Oct 2001
Location: North Carolina of the U.S.A.
Posts: 1,008
|
|
Great! But I do have some questions about some definitions...- Client area
This may sound dumb but do you mean the form area? or do you mean the Client's (the user's) area of their screen?
- Twip
What in the world?
I guess when I learn what a Twip is, I could understand...
Quote:
Screen.TwipsPerPixelX 'How many twips per pixel horizontally
Screen.TwipsPerPixelY 'How many twips per pixel vertically
|
Also, what should I have my form's scale mode set to? I have it (default) on twips right now.
Thanks for clearing things up!
|
|

04-29-2002, 06:43 PM
|
 |
Bit Flipper
|
|
Join Date: Feb 2002
Location: The Inner Loop
Posts: 5,550
|
|
Quote:
Client area
This may sound dumb but do you mean the form area? or do you mean the Client's (the user's) area of their screen?
|
This is the area in which you place all your controls. This does NOT include the titlebar, menus, or borders of the form.
Quote:
From MSDN:
Twip
A screen-independent unit used to ensure that placement and proportion of screen elements in your screen application are the same on all display systems. A twip is a unit of screen measurement equal to 1/20 of a printer's point. There are approximately 1440 twips to a logical inch or 567 twips to a logical centimeter (the length of a screen item measuring one inch or one centimeter when printed).
|
It is simply a different unit of measurement similar to pixel, centimeter, inch, ect...
HTH,
Orbity
|
|

05-01-2002, 01:22 PM
|
|
Senior Contributor
|
|
Join Date: Oct 2001
Location: North Carolina of the U.S.A.
Posts: 1,008
|
|
|
Thanks a whole lot, Orbitiy.
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|