Solved

Coverting twips into pixels by getting the screen resolution

Posted on 1998-10-14
11
420 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
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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
bit defender blocks good applications 2 93
Copy a row 12 61
How to set the sa password in a vb6 code for sql connection 9 51
VB 6 error 5 in windows 10 but not in XP 7 55
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 …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

816 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

11 Experts available now in Live!

Get 1:1 Help Now