Solved

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

Posted on 2004-09-13
9
387 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

747 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

11 Experts available now in Live!

Get 1:1 Help Now