Solved

Why does width and scalewidth properties return same value for a form?

Posted on 2004-09-13
9
388 Views
Last Modified: 2012-06-27
   w = frmResPro.ScaleWidth
    w2 = frmResPro.Width
returns same value. Values listed in the form's properties window shows that they are different.
thanks.
0
Comment
Question by:spoowiz
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 5

Expert Comment

by:KarcOrigin
ID: 12051915
Try this:

1. Just check the ScaleMode of the form. Set it to 1-TWIP.
2. Set ScaleWidth and Width of the form at the design time. Now run the form and check the values.

Thanks
0
 
LVL 3

Expert Comment

by:redfordb
ID: 12052441
What variable type is w and w2 defined as ?
0
 

Author Comment

by:spoowiz
ID: 12057222
karc - it is set to 1-twip. i'm check the form's width and scalewidth from another form.
redford - long
0
 
LVL 7

Expert Comment

by:Burbble
ID: 12057301
This is how it's supposed to work. The ".ScaleMode" property of the Screen object (although it doesn't actually have one) is Twips, and there's nothing really that can be done about it. So the .Width and .Height properties of a form will always be in Twips (pixels * 15).

If you want the .ScaleWidth and .ScaleHeight properties of a form to be in Pixels, set it's ScaleMode property to 3.

-Burbble
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:spoowiz
ID: 12057437
burbble - the "problem", if it is a problem, is that scalewidth and width both return the same values (value of scalewidth). i'm looking to obtain the form.width value.
0
 
LVL 7

Expert Comment

by:Burbble
ID: 12060084
OH, I understand. Sorry ;-)

Does this only happen on the one project?

If you start a new Standard EXE project, add the line:

    MsgBox Form1.Width & "," & Form1.ScaleWidth

and run it, are they the same value?

What does...

    MsgBox Screen.TwipsPerPixelX & "," & Screen.TwipsPerPixelY & vbNewLine & Screen.Width & "," & Screen.Height

...return?

-Burbble


0
 
LVL 32

Expert Comment

by:Erick37
ID: 12149067
There are only 2 conditions that I can think of where the ScaleWidth and Width of a form can be the same:

1. The borderstyle of the form is set to 0 - None
2. The ScaleWidth property is set (in runtime or design time) to equal the Width (forcing the ScaleMode to 0 - User)

0
 

Author Comment

by:spoowiz
ID: 12149232
burbble -
>MsgBox Screen.TwipsPerPixelX & "," & Screen.TwipsPerPixelY & vbNewLine & Screen.Width & "," & Screen.Height
it says:
15,15
15360,11520

erik-
borderstyle was 0. when i changed to borderstyle 1, scalewidth and width showed the "correct" numbers.
so what does the borderstyle have to do with it?
what is the difference between scalewidth and width?

increasing points to 150
0
 
LVL 32

Accepted Solution

by:
Erick37 earned 150 total points
ID: 12149884
The Width property of a form is the width in twips of the entire window, including the frame.  The ScaleWidth of a form represents the client area of the window (that part which the programmer can put controls on, draw to, etc.) The client area of a window does not include the title bar, frame, or menu bar.  Those areas are referred to as non-client areas.

The ScaleMode property sets up the coordinate system used in the client area of a form.  You can set it to any predefined system like vbPixels, or vbHiMetric, or you can define your own units by setting the ScaleWidth and ScaleHeight yourself.  When you do this, the ScaleMode becomes user defined.

Reference:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vb98/html/vbproscaleheight.asp

Hope it helps!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now