?
Solved

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

Posted on 2001-07-25
14
Medium Priority
?
314 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
13 Comments
 
LVL 20

Expert Comment

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

Expert Comment

by:Stefaan
ID: 6317341
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
ID: 6317509
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
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!

 
LVL 3

Expert Comment

by:Stefaan
ID: 6317564
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
ID: 6317599
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
ID: 6318152
>> 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
 

Author Comment

by:igor84
ID: 6319178
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
ID: 6319264
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
ID: 6320080
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 400 total points
ID: 6320286
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
ID: 6323909
this is no solution to me i want to get the data with out measuring something ...

sorry ...
0
 
LVL 21

Expert Comment

by:gemarti
ID: 6323950
You can't get it any other way!

Your'e SOL.


GEM
0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 8732802
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month16 days, 17 hours left to enroll

864 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