Skip to content

wrong mouse coordinates under W10 in a DPI virtualized application #1

@tothpaul

Description

@tothpaul

use the commented code from

https://github.com/JBontes/DragDrop/blob/master/Source/DropTarget.pas#L1259

and add this to fix the point

var
l: TPoint;
m: TMonitor;
mi: TMonitorInfoEx;
dm: DEVMODE;
...
m := Screen.MonitorFromWindow(Result.Handle);
mi.cbSize := SizeOf(mi);
GetMonitorInfo(m.Handle, PMonitorInfo(@mi));
EnumDisplaySettings(mi.szDevice, Cardinal(-1), dm);
l := p;
if dm.dmPelsWidth <> mi.rcMonitor.Width then
begin
l.x := (l.x * mi.rcMonitor.Width) div dm.dmPelsWidth;
end;
if dm.dmPelsHeight <> mi.rcMonitor.Height then
begin
l.y := (l.y * mi.rcMonitor.Height) div dm.dmPelsHeight;
end;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions