?
Solved

Coverting twips into pixels by getting the screen resolution

Posted on 1998-10-14
11
Medium Priority
?
434 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
[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
  • 8
  • 3
11 Comments
 
LVL 6

Accepted Solution

by:
clifABB earned 40 total points
ID: 1439853
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
ID: 1439854
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
ID: 1439855
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:lesa
ID: 1439856
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
ID: 1439857
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
 

Author Comment

by:lesa
ID: 1439858
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
ID: 1439859
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
ID: 1439860
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
ID: 1439861
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
ID: 1439862
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
ID: 1439863
sorry for the delay and lot of thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…
Suggested Courses
Course of the Month14 days, 22 hours left to enroll

770 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