Click to See Complete Forum and Search --> : Display
LG
Dec 30th, 1999, 04:18 AM
How to get actual size of the monitor?
HeSaidJoe
Dec 30th, 1999, 04:20 AM
'You can use the following small piece of code to
'detect the current screen resolution and
'then act on the information -
'for instance; resizing form objects to suit the user's resolution.
'
''Wayne
'
Option Explicit
'
'form event code
'==============================
Dim x, y As Integer
x = Screen.Width / Screen.TwipsPerPixelX
y = Screen.Height / Screen.TwipsPerPixelY
'whatever you want to do goes here
'message user
Dim msg
msg = "Screen Width = " & x & " TwipsPerPixel" & vbCrLf
msg = msg & "Screen Height = " & y & " TwipsPerPixel"
MsgBox msg
LG
Dec 30th, 1999, 04:33 AM
Thanks, but I need a size of the monitor in inches (actual size of the monitor as a hardware)
Gimpster
Dec 30th, 1999, 04:44 AM
I don't think that's possible. Because what you would need then is a unit (such as a twip or pixel), but whose physical size does not change with respect to resolution. And I've never heard of one. But if you know of one, then just find out what it's physical size is, and then find out how many you have on the screen and go from there. But I really don't think that's possible. Besides, the "size" of a monitor (such as 14", 15", 17", 19", etc.) is not the actual size of the screen. The screen is smaller than what is advertised as the monitor size. And the difference between the monitor size and the screen size varies from monitor to monitor. So it really is an impossible task. Besides, what would you need that for?
------------------
Ryan
[This message has been edited by Gimpster (edited 12-30-1999).]
A 14" has about 12.3" of Viewing screen. 15 is around 13" and 17 is around 16.7" etc etc... The point I am making is that those Viewing sizes are standurd and you would have to find what the defaults are and hard code it in. It is possible, but some footwork is required.
LG
Dec 30th, 1999, 04:58 AM
What I need to know is:
if the monitor is 14 inch or 15 inch or 17 inch or ....
Bob Baddeley
Dec 30th, 1999, 05:26 AM
Look at the manual. That should tell you. Also look at the back of the monitor for the specs. That should also tell you. If it doesn't, do a little research on the brand and model number and you'll find out that way. The last way to find out is to take a ruler and measure from one corner diagonally to the opposite corner.
Clunietp
Dec 30th, 1999, 06:34 AM
Great thinkin Bob! Why didn't the rest of you guys think of that? DUH!
:)
LG
Dec 30th, 1999, 12:12 PM
To Ryan.
Situation is quite simple.
I am making a programm for the client and I know nothing about the configuration of his computer. To look good I have to make everything resolution independent which is not a big deal. But if you may know that default size of fonts in Window is 8 regadless of the monitor size or resolution. What I am trying to do is to set in my programm font size like 8 for 14 inch monitor, 9 for 17, 10.25 for 20 etc. My programm contains of real time graphics on each form and it is very iprotant to make fontsize of forms and controls resolution independent, but correlated to a monitor size withuot asking a user " please enter size of your monitor". as simple as that.
RogerH
Dec 30th, 1999, 01:57 PM
I'd suggest to forget it and let the user enter the type of monitor.
Roger
Gimpster
Dec 30th, 1999, 10:11 PM
LG, here's just a tip, because I think you're in for a lot of headaches if you try to make your program determine the physical size of the user's monitor. I know that as programmers, we are all supposed to try to make our programs accomodate the users, instead of the other way around. But in this case, I think you're justified. What you could do, is simply put a disclaimer at the beginning of your program. Just a simple message box that says "This program runs best in 800x600 mode. If you would like to change your settings now, please click 'Cancel'. Otherwise, please continue." Because your program should look the same as long as it's in the same resolution, the actual size of the monitor shouldn't make a difference. Hope this helps.
------------------
Ryan
LG
Dec 31st, 1999, 12:17 AM
I still beleive it can be done and it should be easy enough. Here is my point:
1. Somehow Screen.TwipsPerPixelX is gifferent based not on resolution but on something else, maybe on size. For example it 15 for 17 inch monitors, 12 for 15 inch monitors. I think it maybe correlated to size of the monitor, but I cannot find hard prinded proof of that.
2. If you run max resolution for the monitor then formula:
MonitorSize= (Screen.Height^2 + Screen.Width^2)^0.5/1440
returns correct size of the monitor, but only when you run a max resolution. In a registry there are couple entries like "Max:1200,1024", but on which of them I can use being sure it exists in any computer's registry. And as a matter of fact there can be to max resolutions - video card and monitor by itself.
Those two things keep myself trying to find the way to get a monitor size. It cannot be too hard, just require some kinde of exect knowleadge.
[This message has been edited by LG (edited 12-31-1999).]
[This message has been edited by LG (edited 12-31-1999).]
mwdelta
Dec 31st, 1999, 01:26 AM
TwipsPerPixel is actually not related to screen size. It's a very important property that gives you information about the current Windows font size. Like you were saying that the default font size of Windows is 8? Well, you can change that by going into Display Properties > Settings > Advanced, then look on the General Tab under Display. Most computers use "Small Fonts," which is size 8. But users can set their computers to large fonts, which makes it 10 or 12 or something else. Try switching and see how your application looks. It will probably look messed up. Before you release it, make sure it looks fine in both small and large fonts. Anyway, back to your question:
There is no way to detect the physical size of a monitor, because the computer doesn't know the actual size, only the resolution. The only things you can find out are the resolution, and the twips per pixel. But from reading what you want, I don't see why the resolution won't work. I don't understand what you mean by "resolution independent." If you do nothing, the program's forms will get smaller when higher resolutions are used. Do you want them to stay the same size? The actual monitor size won't do anything for you, because you can set a 21" monitor to 640x480 or 1280x1024. Making the font size bigger for a 21" wouldn't work if it was set to 640x480. Is this making sense? :)
Happy New Year!
------------------
Mike Wellems
PowerQuery
LG
Dec 31st, 1999, 01:47 AM
Cannot agree with you Mike!
That is why:
if you take 15 inch monitor and 17 inch monitor and leave a default font size as 8
then you will get Screen.TwipsPerPixelX 12 for 15-inch and 15 for 17-inch no matter what resolution you have at a time. if you change the resolution, screen.TwipsPerPixelX will stay the same and different for different sizes of monitors.
And second of all in the fomular if you use not current size of the screen, but max allowed for the monitor, you will get correct size of the monitor.
All that means there is a connection between TwipsPerPixel, size of the monitor and max allowed resolution.
The means there is a way, it just must be.
[This message has been edited by LG (edited 12-31-1999).]
[This message has been edited by LG (edited 12-31-1999).]
Gimpster
Dec 31st, 1999, 02:17 AM
Look, LG, the number of twips per pixel is a constant! It cannot be changed. I'm sure whatever you need to accomplish in your program can be accomplished more easily, and better with knowing just the screen resolution, than the actual monitor size. What Mike said is true, and you need to listen to him, because he's right, just like all the other people who've tried to answer your question. When you post a question you need to be open to what the other people tell you, because they generally know what they're talking about. If you're not going to listen to the answers, then don't bother to post the question. It is very simple at this point.
IT IS NOT POSSIBLE TO FIND THE MONITOR SIZE THROUGH CODE IN YOUR PROGRAM!
Now, please, this question is done with, let's move on.
------------------
Ryan
[This message has been edited by Gimpster (edited 12-31-1999).]
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.