Click to See Complete Forum and Search --> : How can i get the monitor screen size ?
Sickboy
October 18th, 2004, 06:03 PM
hi,
is it possible to get the visible screen size of a monitor ?
I need the height and width in inch or centimeter.
thx
daSickboy
kirants
October 18th, 2004, 06:22 PM
Off the top of my head, some of these APIs you may want to look:
GetMonitorInfo
SystemParametersInfo
GetSystemMetrics
santoshthankach
October 19th, 2004, 12:20 AM
Add SYSMETRIC( ) Function also in that list :)
Pravin Kumar
October 19th, 2004, 12:27 AM
Hello,
You can try
CClientDC DC(this);
int ScreenWidth = GetSystemMetrics(SM_CXFULLSCREEN) /
DC.GetDeviceCaps(LOGPIXELSX);
int ScreenHeight = GetSystemMetrics(SM_CYFULLSCREEN) /
DC.GetDeviceCaps(LOGPIXELSY);
But sometimes it gives wrong results, depending on your selection of driver for monitor installation.
Regards.
Pravin.
19-10-2004.
Sickboy
October 19th, 2004, 06:23 AM
these are ways to get the resolution of the monitor in px.
But i need to determine the real size of the monitor display in cm or inch.
For example my 19'' monitor got:
screen diagonal 19 '' (48,3 cm)
visible screen diagonal 18 '' (45,7 cm)
maximum viewable screen 366 x 275 mm
Is there any way to get these values of a monitor ?
thanks
VictorN
October 19th, 2004, 06:29 AM
these are ways to get the resolution of the monitor in px.
But i need to determine the real size of the monitor display in cm or inch.
For example my 19'' monitor got:
screen diagonal 19 '' (48,3 cm)
visible screen diagonal 18 '' (45,7 cm)
maximum viewable screen 366 x 275 mm
Is there any way to get these values of a monitor ?
thanksWhere do you want "to get these values of a monitor" from ?
Have you already tried some of the ways you were suggested by kirants, santoshthankach, PravinKumar?
Sickboy
October 19th, 2004, 06:38 AM
Hi Victor,
yes i´ve checked all three suggested functions from kirants but they give me pixel values. I thought my needed informations will be delivered with the driver.
Any ideas ?
thanks
VictorN
October 19th, 2004, 07:02 AM
GetDeviceCaps
Sickboy
October 19th, 2004, 07:07 AM
Thanks Victor !
getDeviceCaps should work with:
HORZSIZE Width, in millimeters, of the physical screen.
VERTSIZE Height, in millimeters, of the physical screen.
:wave:
juanpast
November 10th, 2005, 06:27 AM
Hi. i try it. The size of my TFT monitor is 17" and HORZSIZE return 320 and VERTSIZE return 240.
My code:
CWnd *CwndDesktop = GetDesktopWindow();
CDC *display_device = CwndDesktop->GetWindowDC();
int hz = display_device->GetDeviceCaps(HORZSIZE);
int vert = display_device->GetDeviceCaps(VERTSIZE);
Why not work?
Ejaz
November 10th, 2005, 06:50 AM
Why not work?
I guess 1+ year is enough for the OP to workaround it or quit it, isn't it? ;)
VictorN
November 10th, 2005, 07:00 AM
Hi. i try it. The size of my monitor is 19" and HORZSIZE return 320 and VERTSIZE return 240.
My code:
CWnd *CwndDesktop = GetDesktopWindow();
CDC *display_device = CwndDesktop->GetWindowDC();
int hz = display_device->GetDeviceCaps(HORZSIZE);
int vert = display_device->GetDeviceCaps(VERTSIZE);
Why not work?
What does "not work"?
What result did you expect?
golanshahar
November 10th, 2005, 07:07 AM
Why not work?
looks ok to me this is the width and height of the screen in milimeters.
if you dont beleive that you can use a ruler and measure yourself :D
Cheers
VictorN
November 10th, 2005, 07:10 AM
looks ok to me this is the width and height of the screen in milimeters.
if you dont beleive that you can use a ruler and measure yourself :D
CheersSuper! My 5 points to you! :D :D :D
juanpast
November 10th, 2005, 07:26 AM
Hi.
My TFT monitor is 270 mm height and 340 mm width. Perhaps because is a TFT monitor??? I dont know.
Thanks to all.
jayender.vs
November 10th, 2005, 07:30 AM
to get ur moniter screen size ... there u have 2 options.
1) in pixels
int Width = pDC->GetDeviceCaps(HORZRES);
int Height = pDC->GetDeviceCaps(VERTRES) ;
2)in millimeters
int Width = pDC->GetDeviceCaps(HORZSIZE);
int Height = pDC->GetDeviceCaps(VERTSIZE) ;
juanpast
November 10th, 2005, 11:18 AM
Hi.
i know these two opcions but HORZSIZE returns 320 but my horizontal screen measure 340 mm and VERTSIZE returns 240 when my screen measure 270 mm
Someone know what is happen??
rdrast
November 10th, 2005, 11:42 AM
Have the user enter the value.
Seriously, why do you need this? No number you get back will be valid. CRT's for example have only an approximate finite 'size', which can easily be changed by a user adjusting the width and height.
Or a user may display something on an overhead projector, in which case, unless the projector is extremely smart, and has an ultrasonic or laser rangefinder to determine distance to the screen, it would have to report to you the physical size of the imaging panel in it (less than 4 x 3 inches usually).
I suppose, if you REALLY need the physical sizing information, the best way would be to draw a vertical and a horizontal line on the display (every time the program starts up), and have the user measure them with a ruler, and enter the values. Then scale things appropriately.
Edit: the last technique is used often on plotters when exact scaling is important, such as in CAD drawings. Even as sophisticated as plotters are, there are no absolutes.
juanpast
November 10th, 2005, 12:37 PM
Perhaps these is the best way. Thanks to all. Users shout give to the program these values.
Thanks and bye.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.