Solved

GetDeviceCaps under different solutions

Posted on 1998-10-21
9
708 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now