Hi
I want to make an MFC app which displays controls on the left and a bitmap with some graphics on the right.
My problem is now, how do I have to draw the graphic elements (gdiplus rectangle , line, circle) so that they are always on the same position in relation to the windows controls? I draw the controls in Visual Studio 2019 with the resource editor, the graphic elements are drawn by code.
(DPI is set to HIGH in the mfc project settings).
I have drawn two red rectangles, one with the size of the dialog and an inner one which is the size of a group box. For the size of the dialog rectangle I use GetClientRect. It works on all font sizes (DPI scalings) correct.
For the inner rectangle inside the group box I tried to recalculate the coords with GetDeviceCaps, but that does not work. If I change scaling in windows the inner rectangle is completely off.
So I tried to figure out the correct coords for the inner rectangle by trial and error. Below are the coords which draw the correct rectangles in relation the the group box.
But how can I calculate them, I get some weird values? In the x axis I would get a factor of 1.3328 and on the y axis a factor of 1.62 with 150% scaling????
http://public.stattegg.info/_old/dpiproblem.jpg
// coords at 100%
Dialog rectangle coord = 0/0 - 1445/832
group box rectangle coord = 624/9 - 1247/581
// coords at 125%
Dialog rectangle coord = 0/0 - 1685/1088
group box rectangle coord = 728/11 - 1456/761
// coords at 150%
Dialog rectangle coord = 0/0 - 1926/1344
group box rectangle coord = 831/13 - 1664/941
How can I calculate the right coordinates for this elements ?
thanks
regards
Erich