Solved

GetDeviceCaps under different solutions

Posted on 1998-10-21
9
714 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
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…

770 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