Hello

Hello,

I have a problem with IDropTarget.DragEnter event with Berlin under W10 with 125% font (Windows settings) when I disable High DPI on Delphi.

WindowFromPoint() do not find the target window when the mouse is on the right side of the Form.

The mouse coordinates sent my DragEnter do not match the Form dimensions !

let's says that the form is 800x600 pixels with top, left = 10, the DragEnter event gives me coordinates above 810x610 !

How can I fix thoses values ?

Comments

  1. I've found a trick :)

    from this commented code I've added some few things

    github.com - DragDrop

    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;

    ReplyDelete
  2. I get a similar problem with virtual machines on 4K screen. The VM scales automatically. A form which correctly centers itself in other resolutions, it fails to calculate the position in the VM. Also, a popup menu at the left bottom corner (windows maximised) does not adjust the top property correctly and it appears off-screen.

    ReplyDelete

Post a Comment