?
Solved

GetDeviceCaps under different solutions

Posted on 1998-10-21
9
Medium Priority
?
725 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
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 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 150 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month13 days, 21 hours left to enroll

809 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