Solved

how i can detirimne the size of the screen in inch's

Posted on 2001-07-25
14
286 Views
Last Modified: 2010-04-06
i tried to use TScreen property  Heiht (Width) and PixelsPerInch but the results that i get aren't right ...

Plase Help Me !!!

Igor
0
Comment
Question by:igor84
  • 3
  • 3
  • 3
  • +3
14 Comments
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
What results do you get, and what results would be correct?
0
 
LVL 3

Expert Comment

by:Stefaan
Comment Utility
What are you trying to do ? Determine the screen resolution ? If that is the case, then the follwoing should work :

  ShowMessage(IntToStr(Screen.Width ) +' x '+ IntToStr( Screen.Height));

Best regards,


Stefaan
0
 
LVL 2

Expert Comment

by:bugroger
Comment Utility
Hi,

Have a look at
 function GetSystemMetrics

"The GetSystemMetrics function retrieves various system metrics and system configuration settings.

System metrics are the dimensions (widths and heights) of Windows display elements. All dimensions retrieved by GetSystemMetrics are in pixels."

ex.:
 ScreenWidth  := GetSystemMetrics(SM_CXSCREEN);
 ScreenHeight := GetSystemMetrics(SM_CYSCREEN);

GL
 Bug



 
0
 
LVL 3

Expert Comment

by:Stefaan
Comment Utility
Hi,

Sorry didn't notice that you needed the sceen size in inches.  The coude should look like this :

  ShowMessage(FloatToStr(Screen.Width / Screen.PixelsPerInch ) +' x '+ FloatToStr( Screen.Height / Screen.PixelsPerInch ));


But of course bear the following in mind : < snippet from Delphi Help >

PixelsPerInch is only accurate for vertical measurements. Most screens have a different scaling factor for horizontal measurements. The value in PixelsPerInch is set from Windows when Delphi loads.

So the width could be wrong, but the height should be correct.

Best regards,


Stefaan
0
 

Author Comment

by:igor84
Comment Utility
Sorry but you all are wrong !!!

1. i need my data in inch's.
2. PixelPerInch doesn't realy give the value of how much  
   pixels get into one inch but the size of the font for
   example : small font 96 pixlesPerInch and ect ...

if some one know how to do it then write your answer ...
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
>> Sorry but you all are wrong !!!

How can you say that, when all I was writing was two questions to clarify what you want????

How about answering my questions? Then *maybe* I can help. I'm not even sure yet what exactly you want.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:igor84
Comment Utility
i was talking about two aspects 1. is that i need my data in inch's and not in pixels

and 2 that the use of PixelPerInch isn't used for geting the real amount of pixels per inch.

so don't get mad ...

the results that i get is aobut 13.3" the daginal of the screen when my is 16"

the correct results would be correct acording you screen size measure it and compare it to the results and see if they match
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
Okay, so you want to know whether you have a 15" monitor or a 17" monitor or anything like that? Did I understand that right? That is a real problem. Perhaps Windows knows that in the depth of its registry or perhaps the communication between Windows and the monitor could reveal it. But I fear we normal programmers have no access to those informations. Furthermore a 15" LCD monitor has a bigger "seeable" size than a 15" tube monitor. So I fear what you want is not solvable. At least I don't know how. I'm sorry...   :-(

Regards, Madshi.
0
 
LVL 21

Expert Comment

by:gemarti
Comment Utility
It seems to me that this is more of a calibration issue. I recall having to place a ruler to my screen and moving a sliding ruler across the screen until 1" on the screen ruler equaled 1" on the ruler I holding to the screen.

So here is my proposal using a factors that are [inches/pixel]. While you try this I have another Idea I am going to work on that may simplify this.

This is all contingent on my understanding your request.  

var
  Result : Variant;
begin

Result :=Screen.Width*0.012451171875;
ShowMessage(VarToStr(Result));

Result := Screen.Height*0.012044270833333333333333333333333;
ShowMessage(VarToStr(Result));

end;
0
 
LVL 21

Accepted Solution

by:
gemarti earned 100 total points
Comment Utility
You have to measure two points on the screen (This is your calibration). Screens can be curved or flat just as Madshi was saying. I put a ruler to the screen. Held down the right mouse button until I had moved it horizontally 1 inch. I then released it.
OnMouseDown got the starting coordinates.
OnMouseUp got the end coordinates.

If you divide the Screen.Width by the difference of these two numbers you'll get an approximate screen width in inches.

Do the same for the Screen.Height.


\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
procedure TForm1.Button1Click(Sender: TObject);
var
  Result : Variant;
begin
Inch := StrToInt(Label2.Caption) - StrToInt(Label1.Caption);
Label3.Caption := IntToStr(Inch);
Result := Screen.Width/Inch;
ShowMessage(VarToStr(Result));

Result := Screen.Height/Inch;
ShowMessage(VarToStr(Result));

end;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Label1.Caption := IntToStr(Mouse.CursorPos.X);  //Start to Hold Mouse down until you reach an inch
end;

procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Label2.Caption := IntToStr(Mouse.CursorPos.X); //End holding Mouse down at one inch.
end;
0
 

Author Comment

by:igor84
Comment Utility
this is no solution to me i want to get the data with out measuring something ...

sorry ...
0
 
LVL 21

Expert Comment

by:gemarti
Comment Utility
You can't get it any other way!

Your'e SOL.


GEM
0
 
LVL 26

Expert Comment

by:Russell Libby
Comment Utility
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

To accept gemarti's comment as answer

Note: There is no way to calculate the real display units without manual intervention. For further reference please see MSDN article Q127152

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Thank you,
Russell

EE Cleanup Volunteer
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

772 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

14 Experts available now in Live!

Get 1:1 Help Now