Recent

Author Topic: [SOLVED] Single instance of SHGFI_* constants  (Read 4188 times)

lagprogramming

  • Sr. Member
  • ****
  • Posts: 407
[SOLVED] Single instance of SHGFI_* constants
« on: September 10, 2023, 08:24:39 am »
I've noticed the forum entry at Programming » Operating Systems » Windows » How to use shellapi unit?
https://forum.lazarus.freepascal.org/index.php/topic,64565.0.html
It reminded me of the following situation.

SHGFI_* constants like SHGFI_SMALLICON, SHGFI_LARGEICON and SHGFI_ICON are declared in both Lazarus and Free Pascal. In Free Pascal, the constants are declared in both rtl/wince/wininc/defines.inc and packages/winunits-base/src/shellapi.pp. Lazarus declares them in lcl/interfaces/customdrawn/customdrawn_winextra.pas and lcl/interfaces/win32/win32extra.pas.
This multiple declaration is not good at all. It would be better if Lazarus and Free Pascal developers would decide a single instance declaration in Free Pascal, declaration that would be used by LCL and third party Lazarus apps.
« Last Edit: January 04, 2024, 10:42:49 am by lagprogramming »

AlexTP

  • Hero Member
  • *****
  • Posts: 2488
    • UVviewsoft
Re: Single instance of SHGFI_* constants
« Reply #1 on: September 10, 2023, 09:58:21 pm »
So in FPC names are declared in
a. WinCE unit
b. Win32 unit
It is ok for me, WinCE and WIn32 maybe don't have lot of common units.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11947
  • FPC developer.
Re: Single instance of SHGFI_* constants
« Reply #2 on: September 11, 2023, 09:48:39 am »
win32extra is an unit with defines that should move to FPC over time, but it is only weeded occasionally (last time by Paul in 2015 after 3.0.0 or so), so there is quite a buildup of old stuff.

Bart

  • Hero Member
  • *****
  • Posts: 5469
    • Bart en Mariska's Webstek
Re: Single instance of SHGFI_* constants
« Reply #3 on: September 11, 2023, 03:17:04 pm »
We've weeded out some more stuff that is now in fpc recently...

Bart

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11947
  • FPC developer.
Re: Single instance of SHGFI_* constants
« Reply #4 on: September 11, 2023, 03:45:37 pm »
Yes, cleaned up a lot, but SHGFI_* is still there, and in shellapi since 2008

Bart

  • Hero Member
  • *****
  • Posts: 5469
    • Bart en Mariska's Webstek
Re: Single instance of SHGFI_* constants
« Reply #5 on: September 11, 2023, 10:06:46 pm »
File a bugreport (reference this topic) and I'll see if I can clear it up some more.
Yes, cleaned up a lot, but SHGFI_* is still there, and in shellapi since 2008
This is since which fpc version (Lazarus supports 3.2.0 and higher)?

Bart

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11947
  • FPC developer.
Re: Single instance of SHGFI_* constants
« Reply #6 on: September 11, 2023, 11:15:50 pm »
File a bugreport (reference this topic) and I'll see if I can clear it up some more.
Yes, cleaned up a lot, but SHGFI_* is still there, and in shellapi since 2008
This is since which fpc version (Lazarus supports 3.2.0 and higher)?

As far I can see they were already there in 2008.  Something goes wrong in the history there (probably the GIT migration tool didn't pick up SVN move/renames of old versions).   So 2.4.0 or earlier.

But maybe somebody expected them to be in windows rather than shellapi. In very old versions much more was in unit windows, so they might not have been used to looking further.

lagprogramming

  • Sr. Member
  • ****
  • Posts: 407
Re: Single instance of SHGFI_* constants
« Reply #7 on: September 20, 2023, 11:28:05 am »
So in FPC names are declared in
a. WinCE unit
b. Win32 unit
It is ok for me, WinCE and WIn32 maybe don't have lot of common units.
The rtl directory of Free Pascal has the following subdirectories: win, win16, win32, win64 and wince. Notice that the constants are declared in wince and packages/winunits-base/. Not in the win32 directory.

lagprogramming

  • Sr. Member
  • ****
  • Posts: 407
Re: Single instance of SHGFI_* constants
« Reply #8 on: January 01, 2024, 02:01:15 pm »
I've searched for "SHGFI_" in the Lazarus directory.
1/3 The declarations of SHGFI_SMALLICON, SHGFI_LARGEICON and SHGFI_ICON have been removed from both lcl/interfaces/win32/win32extra.pas and lcl/interfaces/customdrawn/customdrawn_winextra.pas files because they are declared in fpc twice already. 3rd party applications build with Lazarus should use the shellapi unit provided by fpc.
2/3 The constants are used in the lcl/interfaces/win32/win32wsshellctrls.pp file but the removal of the declarations won't affect it because this unit already has shellapi in the uses clause.
3/3 The constants are used in the lcl/interfaces/win32/win32themes.pas file reason why the shellapi unit has been added to the uses clause of the implementation.
Test the patch and if it's ok you can apply it to the official sources.
« Last Edit: January 01, 2024, 02:03:42 pm by lagprogramming »

AlexTP

  • Hero Member
  • *****
  • Posts: 2488
    • UVviewsoft

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11947
  • FPC developer.
Re: Single instance of SHGFI_* constants
« Reply #10 on: January 01, 2024, 02:34:07 pm »
(wince should be ignored as it has a separate SDK from win32/64), as in different header files .  Wince has an own wininc/ subdir while win32 and win64 use the win/ directory for shared code including the win/wininc directory.

 

TinyPortal © 2005-2018