[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2004-09-13
9
Medium Priority
?
398 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 600 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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…
Suggested Courses

656 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