Page 1 of 1

Override LIB Function

Posted: Mon Feb 20, 2023 4:14 am
by AUGE_OHR
hi,

i want to use "my" HB_FUNC ( HEADER_SETFONT ) which exist in c_GridEx.c
i don´t want to change LIB Source before "my Version" work

but Compiler/Linker give me a Error
multiple definition of `HB_FUN_HEADER_SETFONT'
i remember there was a Option to pass "Dupe" Error
btw. i use

Code: Select all

-w1 -es2
so how is the Compiler/Linker Switch to skip Error and use "my Version" of HB_FUNC() :?:

Re: Override LIB Function

Posted: Mon Feb 20, 2023 9:48 am
by gfilatov
AUGE_OHR wrote: Mon Feb 20, 2023 4:14 am so how is the Compiler/Linker Switch to skip Error and use "my Version" of HB_FUNC() :?:
Hi Jimmy,

Just add the following switch to your project's .HBP file:
-ldflag=-Wl,--allow-multiple-definition
You'll get the warning message from hbmk2 utility after that :o

Re: Override LIB Function

Posted: Mon Feb 20, 2023 10:44 pm
by AUGE_OHR
hi Grigory,
gfilatov wrote: Mon Feb 20, 2023 9:48 am Just add the following switch to your project's .HBP file:
-ldflag=-Wl,--allow-multiple-definition
You'll get the warning message from hbmk2 utility after that :o
thx, that work fine :D

now i can color GRID Header using "HeaderDYNAMICBACKCOLOR"" and

Code: Select all

   IF SP_DarkMode()
      hHeader := ListView_GetHeader( hGrid )
      // Set Visual Style OFF
      SetWindowTheme( hHeader, "", "" )
      HEADER_SETFONT( hHeader, Background_Color, Foreground_Color ) // 4th Parameter FONT not used here
   ENDIF   

Code: Select all

HB_FUNC( HEADER_SETFONT )
{
   #ifndef _WIN64
      LPARAM lParam = (LPARAM) hb_parnl (1);
   #else
      LPARAM lParam = (LPARAM) hb_parnll (1);
   #endif
   LPNMCUSTOMDRAW lpNMCustomDraw = (LPNMCUSTOMDRAW) lParam;
   HFONT hFont = (HFONT) hb_parnl (4);
   HBRUSH hbrush;
   RECT rect = (RECT) lpNMCustomDraw->rc ;

   SetBkColor   (lpNMCustomDraw->hdc, hb_parni(2));
   SetTextColor (lpNMCustomDraw->hdc, hb_parni(3));

   hbrush = CreateSolidBrush( hb_parni(2) );

   SetBkMode( lpNMCustomDraw->hdc, 1 );
   SelectObject( lpNMCustomDraw->hdc, hbrush);
   FillRect(lpNMCustomDraw->hdc, &rect , hbrush);
   DeleteObject(hbrush);

   if ( hFont != NULL )
       SelectObject (lpNMCustomDraw->hdc, hFont);

   hb_retni ( CDRF_NEWFONT );
}
HBFM_GridHeader_Darkmode.JPG
HBFM_GridHeader_Darkmode.JPG (34.77 KiB) Viewed 2971 times

Re: Override LIB Function

Posted: Fri Feb 24, 2023 1:17 pm
by mol
super

Re: Override LIB Function

Posted: Sat Feb 25, 2023 4:14 am
by AUGE_OHR
hi,

have found out that HB_FUNC(HEADER_SETFONT) is call twice when use "HeaderDYNAMICBACKCOLOR"

you only need to witch Theme OFF and use "modify" Version of HB_FUNC(HEADER_SETFONT) and "HeaderDYNAMICBACKCOLOR"

"modify" Version of HB_FUNC(HEADER_SETFONT) seems me STABLE so i replace it in "my" Source c:\hmg.3.4.4\SOURCE\c_GridEx.c

Re: Override LIB Function

Posted: Sat Feb 25, 2023 7:22 am
by serge_girard
Great !

Re: Override LIB Function

Posted: Sat Feb 25, 2023 1:21 pm
by gfilatov
AUGE_OHR wrote: Sat Feb 25, 2023 4:14 am hi,

have found out that HB_FUNC(HEADER_SETFONT) is call twice when use "HeaderDYNAMICBACKCOLOR"

you only need to witch Theme OFF and use "modify" Version of HB_FUNC(HEADER_SETFONT) and "HeaderDYNAMICBACKCOLOR"

"modify" Version of HB_FUNC(HEADER_SETFONT) seems me STABLE so i replace it in "my" Source c:\hmg.3.4.4\SOURCE\c_GridEx.c
Hi Jimmy,

Thanks a lot for your contribution :!:

BTW I've added the following description in the current Minigui changelog file:
* Updated: Synchronized Extended HMG for compatibility with Official HMG:
- New: DynamicFont property to have any text font and style in header.
<ParentWindow>.<GridControl>.HeaderDYNAMICFONT ( nCol ) := {|| cFontName }
where
cFontName was defined with DEFINE FONT <font> FONTNAME <name> ... command
- New: HeaderDynamicForeColor and HeaderDynamicForeColor
<ParentWindow>.<GridControl>.HeaderDYNAMICFORECOLOR ( nCol ) := {|| aColor }
<ParentWindow>.<GridControl>.HeaderDYNAMICBACKCOLOR ( nCol ) := {|| aColor }
Hope that useful :idea: