Solved

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

Posted on 2004-09-13
9
393 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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
 

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

724 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