I have enabled the “gdiScaling” option in the manifest to enable the enhanced GDI scaling feature on my MFC C++ application.
I have however some issues with drawing lines with MoveTo/LineTo : drawing a simple rectangle have some “glitches” on the edges, that do not match anymore, like an off-by-one pixel because of the scaling.
Anyone have experienced this? How to fix it? (apart from changing API, for example Rectangle())
SelectObject(hdc, CreatePen(PS_SOLID, 1, 0));
int x1 = 100;
int y1 = 100;
int x2 = 199;
int y2 = 199;
int ofs = 1; // LineTo does not include last pixel!
MoveToEx(hdc, x1, y1, nullptr);
LineTo(hdc, x2 + ofs, y1);
MoveToEx(hdc, x1, y1, nullptr);
LineTo(hdc, x1, y2 + ofs);
MoveToEx(hdc, x2, y1, nullptr);
LineTo(hdc, x2, y2 + ofs);
MoveToEx(hdc, x1, y2, nullptr);
LineTo(hdc, x2 + ofs, y2);