Solved

Coverting twips into pixels by getting the screen resolution

Posted on 1998-10-14
11
416 Views
Last Modified: 2010-04-30
I want to make the window size independent of the monitor. So I need to get the screen resolution in twips and pixels. Can anybody help me out.
0
Comment
Question by:lesa
  • 8
  • 3
11 Comments
 
LVL 6

Accepted Solution

by:
clifABB earned 10 total points
Comment Utility
In twips:
Width = Screen.Width
Height = Screen.Height

In pixels:
Width = Screen.Width / Screen.TwipsPerPixelX
Height = Screen.Height / Screen.TwipsPerPixelY
0
 

Author Comment

by:lesa
Comment Utility
Lot of thanks for your quick response. Let me make my problem clear.

I have a situaution in which I have to show the window always with a width of 11175twips what ever may be the resolution and width of  the screen.

Can I do this with your solution or should I do anything more.
0
 

Author Comment

by:lesa
Comment Utility
Lot of thanks for your quick response. Let me make my problem clear.

I have a situaution in which I have to show the window always with a width of 11175twips what ever may be the resolution and width of  the screen.

Can I do this with your solution or should I do anything more.
0
 

Author Comment

by:lesa
Comment Utility
Lot of thanks for your quick response. Let me make my problem clear.

I have a situaution in which I have to show the window always with a width of 11175twips what ever may be the resolution and width of  the screen.

Can I do this with your solution or should I do anything more.
0
 
LVL 6

Expert Comment

by:clifABB
Comment Utility
I don't think you are asking the question correctly.

If you want a form to be 11175 twips wide, then you set the width to that value.  However, at 640x480, the form will be bigger than the screen.

I think you want something else, but I'm not sure what.  Could you explain further?

VB defines twips as:
"By default, all Visual Basic movement, sizing, and graphical-drawing statements use a unit of one twip. A twip is 1/20 of a printer’s point (1,440 twips equal one inch, and 567 twips equal one centimeter). These measurements designate the size an object will be when printed. Actual physical distances on the screen vary according to the monitor size."
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:lesa
Comment Utility
Lot of thanks for your quick response. Let me make my problem clear.

I have a situaution in which I have to show the window always with a width of 11175twips what ever may be the resolution and width of  the screen.

Can I do this with your solution or should I do anything more.
0
 

Author Comment

by:lesa
Comment Utility
I have a function for whihc I have to pass the size of the width in pixels. For that I have to change the 11175 twips into number of pixels for the monitor resolution ans size as each monitor will have different resolution and size which will effect the no of twips for pixel. So I need to know how can I get number of pixels per 11175 twips.
0
 

Author Comment

by:lesa
Comment Utility
I have a function for whihc I have to pass the size of the width in pixels. For that I have to change the 11175 twips into number of pixels for the monitor resolution ans size as each monitor will have different resolution and size which will effect the no of twips for pixel. So I need to know how can I get number of pixels per 11175 twips.
0
 
LVL 6

Expert Comment

by:clifABB
Comment Utility
You can get the number of pixels per 11175 twips by this calculation:
  Number = 11175 / Screen.TwipsPerPixelX

The value of 'Number' will change depending only on resolution but not physical size of the monitor.
0
 

Author Comment

by:lesa
Comment Utility
I have a function for whihc I have to pass the size of the width in pixels. For that I have to change the 11175 twips into number of pixels for the monitor resolution ans size as each monitor will have different resolution and size which will effect the no of twips for pixel. So I need to know how can I get number of pixels per 11175 twips.
0
 

Author Comment

by:lesa
Comment Utility
sorry for the delay and lot of thanks
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…
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…

763 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

10 Experts available now in Live!

Get 1:1 Help Now