Solved

GetDeviceCaps under different solutions

Posted on 1998-10-21
9
716 Views
Last Modified: 2010-04-06
hi,

under D3 and WIN98 there is following problem:
I use the function GetDeviceCaps for some calculations
about space on then screen.
For example: i want to draw a rectangle and its proporties
(x,y,w,h) are given in mm. Therefore i use the
GetDeviceCaps to get the size of the screen in mm and
the size in pixels and calculate the translation-factor
of the pixels per mm.
Its works fine until i realized that under WIN98
the size of the screen in mm depends on the solution !
What is that ?? My screen has not shrunk !

Here is some code :

dc:=getdc(handle);
w:=getdevicecaps(dc,horzsize);
w1:=getdevicecaps(dc,horzres);
wfactor:=w1/w;

w1 is 640 in solution 640 x 480 and
w  is 135 .
w1 is 800 in solution 800 x 600 and
w  is 169 .
Why does w depend on the screen-solution ?

thanks
titz

0
Comment
Question by:titz
9 Comments
 
LVL 5

Expert Comment

by:inter
ID: 1343639
will you please test it with handle = 0 and report the result
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1343640
As I can see you simple get the Width and Height of your form... When use dc := GetDC(Handle); it will get the DC of the form... If you want to take the desktop's DC you need to use DC := GetDC(0); as Inter suggested...

Regards,
Viktor Ivanov
0
 
LVL 1

Author Comment

by:titz
ID: 1343641
hi inter and viktor,

i tried with
dc:=getdc(0);

the results for w and w1 are exactly the same.

titz

0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
LVL 10

Expert Comment

by:viktornet
ID: 1343642
you need to have HORSIZE and VERTSIZE /or was it VERSIZE..Don't remember....

Cheers,
Viktor
0
 
LVL 1

Author Comment

by:titz
ID: 1343643
hi viktor,
there is a misunderstanding:
the results for w and w1 are the same as in my example !
That means : dc:=getdc(0) is no solution for my problem.
Its still existing!
hope for help !
titz
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1343644
Please, take a look at my previous question - it had a happy end, so I hope you can find an idea or two there...

http://www.experts-exchange.com/Q.10067947

--Matvey
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1343645
How about this one>???

DC := GetDC(GetDesktopWindow);

Does it work???

Cheers,
Viktor
0
 
LVL 1

Accepted Solution

by:
Roadrunner100598 earned 50 total points
ID: 1343646
I had a similar problem working with metafiles under Win95 and later going to NT 4.

In Windows 3.x, NT 3.5 and 95 the system knew about the resolution of your monitor. NT4 and 98 obviously only take guesses, depending on the resolution...

So try using LogPixelsX, LogPixelsY (resolution of your device in DPI, screen: 96 or 92 - I don't remember) instead. On most Screens this yields nearly the correct dimensions; on printers the value is exact.

If you need 100% correct scaling on screen, you should use HorzSize to get the number of pixels per line and have your own MEASURED value for the width of the DISPLAY AREA of your monitor. This is much better because the display area of CRT varies with the settings of its controls (screen width, cushion compensation, etc.), with the resolution, with the frequency, somtimes even with the brightness of the display ('pumping').

Maybe you can build a dialog with a calibration-picture (some boxes) where the user can enter the measured parameters.
0
 
LVL 1

Author Comment

by:titz
ID: 1343647
hi viktor,
thanks for your efforts. But your last try with getdc(getdesktopwindow) shows the same effect as before with getdc(0). Always different values for w and w1.

hi roadrunner,
thanks for your thoughts. i will do it in this way, matvey too received this answer in his question some time before.
thanks
titz

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

831 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