Recent

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

Pascal

  • Hero Member
  • *****
  • Posts: 932
How to link with "winver = 6.0"
« on: August 17, 2017, 06:23:12 am »
How can i link my executable with "winver = 6.0"?
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11351
  • FPC developer.
Re: How to link with "winver = 6.0"
« Reply #1 on: August 17, 2017, 06:59:56 am »
winver afaik is a macro in the (C) windows headers. We don't use the C windows headers.

What are you trying to achieve exactly?

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: How to link with "winver = 6.0"
« Reply #2 on: August 17, 2017, 08:37:37 am »
On Windows 10 TForm.Left, Top, Width, Height have strange values. Top/Left is not 0/0.
See http://forum.lazarus.freepascal.org/index.php/topic,37918.msg256621.html#new

If i want to position a Window to one or more of the screen edges i need the position and dimensions of the
drawn window without the extended resize aware area around the window.

But if this a macro/define in the c headers this will not help here :D

I think best is to use:

Code: Pascal  [Select][+][-]
  1. uses
  2.   Windows,
  3.   DwmApi;
  4.  
  5. procedure xyz;
  6. var
  7.   frame: Windows.RECT;
  8. begin
  9.   DwmGetWindowAttribute(Handle, DWMWA_EXTENDED_FRAME_BOUNDS, @frame, sizeof(Windows.RECT));
  10.   ...
  11. end;
  12.  
  13. initialization
  14.   InitDwmLibrary;
  15. end.
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: How to link with "winver = 6.0"
« Reply #3 on: August 17, 2017, 08:56:59 am »
On Windows 10 TForm.Left, Top, Width, Height have strange values. Top/Left is not 0/0.
See http://forum.lazarus.freepascal.org/index.php/topic,37918.msg256621.html#new

If i want to position a Window to one or more of the screen edges i need the position and dimensions of the
drawn window without the extended resize aware area around the window.
use clientrect, clientwidth and clientheight instead.
But if this a macro/define in the c headers this will not help here :D

I think best is to use:

Code: Pascal  [Select][+][-]
  1. uses
  2.   Windows,
  3.   DwmApi;
  4.  
  5. procedure xyz;
  6. var
  7.   frame: Windows.RECT;
  8. begin
  9.   DwmGetWindowAttribute(Handle, DWMWA_EXTENDED_FRAME_BOUNDS, @frame, sizeof(Windows.RECT));
  10.   ...
  11. end;
  12.  
  13. initialization
  14.   InitDwmLibrary;
  15. end.
I would use this one instead https://msdn.microsoft.com/en-us/library/windows/desktop/ms633503(v=vs.85).aspx
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: How to link with "winver = 6.0"
« Reply #4 on: August 17, 2017, 10:26:16 am »
I would use this one instead https://msdn.microsoft.com/en-us/library/windows/desktop/ms633503(v=vs.85).aspx
No, that are not the positions and dimensions of the window (without extended resize areas). It's the usable inner space of the window.
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: How to link with "winver = 6.0"
« Reply #5 on: August 17, 2017, 10:40:39 am »
I would use this one instead https://msdn.microsoft.com/en-us/library/windows/desktop/ms633503(v=vs.85).aspx
No, that are not the positions and dimensions of the window (without extended resize areas). It's the usable inner space of the window.
I guess the 0,0 for top left through me off then. I have no idea what the "extended resize areas" are.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: How to link with "winver = 6.0"
« Reply #6 on: August 17, 2017, 10:51:12 am »
I guess the 0,0 for top left through me off then. I have no idea what the "extended resize areas" are.
On Windows 10 you have an extended area to the left, top and bottom where the cursor changes to the resize cursor and
this size is included in the window position and dimensions (equal to TForm.Left, Top, Width and Height).
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: How to link with "winver = 6.0"
« Reply #7 on: August 17, 2017, 10:53:15 am »
I guess the 0,0 for top left through me off then. I have no idea what the "extended resize areas" are.
On Windows 10 you have an extended area to the left, top and bottom where the cursor changes to the resize cursor and
this size is included in the window position and dimensions (equal to TForm.Left, Top, Width and Height).
isn't that called a frame/border in older windows?
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: How to link with "winver = 6.0"
« Reply #8 on: August 17, 2017, 11:03:02 am »
isn't that called a frame/border in older windows?
Yes, but it doesn't look like one. The visible border is 1 pixel but the whole border is 8 pixel.

I am curious how Delphi handles this (Setting window position to 0/0) on Windows 10.
Will there be a visible gap of 7 pixels to left of the window?

laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: How to link with "winver = 6.0"
« Reply #9 on: August 17, 2017, 11:10:10 am »
isn't that called a frame/border in older windows?
Yes, but it doesn't look like one. The visible border is 1 pixel but the whole border is 8 pixel.

I am curious how Delphi handles this (Setting window position to 0/0) on Windows 10.
Will there be a visible gap of 7 pixels to left of the window?
Sorry I do not have access to windows 10 and I'll probably never will in the near future but that sounds like a windows bug. If my memory serves me correctly in all windows versions from 95 upwards the mouse check for the borders had an error of 1 or 2 pixels on top of the border width to make it more user friendly but that friendliness was never part of the window it self. Are you sure its not an artifact of your current theme? Are you using the default windows theme?
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Pascal

  • Hero Member
  • *****
  • Posts: 932
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

rvk

  • Hero Member
  • *****
  • Posts: 6056
Re: How to link with "winver = 6.0"
« Reply #11 on: August 17, 2017, 12:21:06 pm »
I am curious how Delphi handles this (Setting window position to 0/0) on Windows 10.
Will there be a visible gap of 7 pixels to left of the window?
Yes there is.

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: How to link with "winver = 6.0"
« Reply #12 on: August 17, 2017, 12:25:40 pm »
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: How to link with "winver = 6.0"
« Reply #13 on: August 17, 2017, 12:50:45 pm »
I am curious how Delphi handles this (Setting window position to 0/0) on Windows 10.
Will there be a visible gap of 7 pixels to left of the window?
Yes there is.
Good to know! which is the Delphi version used?
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

rvk

  • Hero Member
  • *****
  • Posts: 6056
Re: How to link with "winver = 6.0"
« Reply #14 on: August 17, 2017, 01:08:30 pm »
I am curious how Delphi handles this (Setting window position to 0/0) on Windows 10.
Will there be a visible gap of 7 pixels to left of the window?
Yes there is.
Good to know! which is the Delphi version used?
Delphi 10.1 Berlin on Windows 10 Pro 64 bit.

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.)

 

TinyPortal © 2005-2018