
See below...
****
There is something deeply suspicious here about getting a window DC. Then, having gotten
the DC, you set mapping modes, set other parameters, and of course, the DC is never going
to be accessed again, so why bother? And, oh yes, you have now leaked a DC, since you
never free it, so it sits there, being completely useless. You only want a Window DC if
you are drawing the entire window, including borders, captions, etc.
Get rid of ALL of this DC-related code; it has no business being here. It does nothing,
and serves no purpose.
****
***
This code is even worse. Why in the world would you call ::GetDC for anything? Let alone
call it in OnIntDialog, where it does nothing useful? And you have leaked another DC, that
will never be seen again. So whatever settings you do affect this DC, and this DC alone,
and it is never, ever seen again by anyone!
If you were to need a DC to a specific window, for example, for a rubber-band line or to
compute some other parameter such as a text size, you would do
CClientDC dc(this);
There are almost no GDI calls that you will need that work with raw GDI. Due to an
unfortunately oversight which has not been rectified in nearly 20 years, SetGraphicsMode
is one of them.
But generally assume under normal conditions that writing ::GetDC, or calling CWnd::GetDC,
is a programming error.
****
****
And what possible relationship does the rectangle at OnInitDialog time have to the
rectangle at drawing time? You do not want to compute these parameters until you have the
actual window to draw into. In some misguided attempt at "optimization" you may think
this saves some time, but it saves no time of any consequence whatsoever. Get rid of this
code as well.
****
****
You have not set the mapping mode or the window extent or viewport extent. These must be
done not to some randomly-chosen and never-seen-again DC in OnInitDialog/OnInitialUpdate,
but to the CDC* that is passed into OnDraw! Fix you code so you have the correct
coordinate system at the point where you are drawing.
In addition to this, your idea of keeping screen resolution in the Registry is complete
nonsense. The screen resolution could change at any time, without warning. You should not
need it at all in this case, because you should be scaling to the actual data, but if you
need it, use CDC::GetDeviceCaps. And I do not think any display in the last 10 years had
72dpi (this was low-resolution VGA, not seen since the late 1980s; 640x480 at 72dpi was an
8.8*6.6, or an 11" diagonal screen area, not seen in modern programming; most modern
screens are either 96dpi or 100dpi). But the resolution does not matter. What you should
be tracking is the max/min of the data, and the GetClientRect of the area you are drawing
in as determined in the OnDraw/OnPaint handler the instant before you start drawing.
Screen resolution does not matter at all in this case.
joe
****