Solved

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

Posted on 2004-09-13
9
389 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Pull multiple cvs files into one access table 28 68
Need VBS version of Excel date conversion 4 71
Hide vba in gp 7 96
Passing a Text Box name to a Sub 6 96
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

831 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