AV using SetMapMode on macOS

Issue #133 resolved
Ronald Klitsche
created an issue

The following code generate an AV on macOS with 0.99c

const
  ScreenResolution = 600;
var
  ScreenDC: HDC;
  FScreenReferenceDC : HDC;
  FScreenReference : TCanvas;
  ScreenCanvasPX : Integer;
  ScreenCanvasPY : Integer;
begin
    ScreenDC := GetDC(0);
    try
      FScreenReferenceDC := CreateCompatibleDC(ScreenDC);
      FScreenReference := TCanvas.Create;
      TCanvas(FScreenReference).Handle := FScreenReferenceDC;

      ScreenCanvasPX := GetDeviceCaps(FScreenReferenceDC, LOGPIXELSX);
      ScreenCanvasPY := GetDeviceCaps(FScreenReferenceDC, LOGPIXELSY);
      SetMapMode(FScreenReferenceDC, MM_ANISOTROPIC);
      SetWindowExtEx(FScreenReferenceDC, ScreenCanvasPX, ScreenCanvasPY, nil);
      SetViewPortExtEx(FScreenReferenceDC, ScreenResolution, ScreenResolution, nil);
      SetViewPortOrgEx(FScreenReferenceDC, 0, 0, nil);

    finally
      FScreenReference.Free;
      ReleaseDC(0, ScreenDC);  // <--- AV here
    end;

Comments (1)

  1. Log in to comment