Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

GetDeviceCaps under different solutions

Posted on 1998-10-21
9
Medium Priority
?
724 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
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…
Suggested Courses

609 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