Recent

Author Topic: How to link with "winver = 6.0"  (Read 9169 times)

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: How to link with "winver = 6.0"
« Reply #15 on: August 17, 2017, 01:32:16 pm »
B.T.W. for setting winver=6 you need to set the MajorSubsystemVersion, not the MajorOperatingSystemVersion, in the IMAGE_OPTIONAL_HEADER flags to 6. In Delphi you can do this by adding {$SETPESUBSYSVERSION 6.0}
( for MajorSubsystemVersion it would be {$SETPEOSVERSION 6.0} )

But both have no effect on Windows 10.
(I checked with PEview that the PE-flags where really set correctly.)
This may only affect other things: https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/6c1c67a9-5548-4e9b-989f-c7dbac0b1375/getwindowrect-on-nonresizable-windows-under-aero-glass?forum=windowsuidevelopment
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

rvk

  • Hero Member
  • *****
  • Posts: 6163
Re: How to link with "winver = 6.0"
« Reply #16 on: August 17, 2017, 01:37:05 pm »
So you can do something like this (like you mentioned) but it's far from optimal.

Code: Pascal  [Select][+][-]
  1. uses Windows, dwmapi;
  2.  
  3. function GetRealWindowRect(Handle: HWND; var R: TRect): Boolean;
  4. begin
  5.   Result := (GetParent(Handle) = 0) and DwmCompositionEnabled and
  6.     (DwmGetWindowAttribute(Handle, DWMWA_EXTENDED_FRAME_BOUNDS, @R, SizeOf(R)) = S_OK);
  7.   if not Result then
  8.     Result := GetWindowRect(Handle, R);
  9. end;
  10.  
  11. function GetInvisibleBorder(Handle: Hwnd): Integer;
  12. var
  13.   R1, R2: TRect;
  14. begin
  15.   Result := 0;
  16.   if GetRealWindowRect(Handle, R1) and GetWindowRect(Handle, R2) then
  17.   begin
  18.     Result := R1.Left - R2.Left;
  19.   end;
  20. end;
  21.  
  22. procedure TForm1.FormCreate(Sender: TObject);
  23. begin
  24.   InitDwmLibrary;
  25.   Top := 0;
  26.   Left := 0;
  27. end;
  28.  
  29. procedure TForm1.FormActivate(Sender: TObject);
  30. begin
  31.   Left := 0 - GetInvisibleBorder(Handle); // only possible after window is visible
  32. end;

 

TinyPortal © 2005-2018