Override LIB Function

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Override LIB Function

Post 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() :?:
have fun
Jimmy
User avatar
gfilatov
Posts: 1090
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Override LIB Function

Post 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
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Override LIB Function

Post 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 2967 times
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Override LIB Function

Post 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
have fun
Jimmy
User avatar
serge_girard
Posts: 3309
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Override LIB Function

Post by serge_girard »

Great !
There's nothing you can do that can't be done...
User avatar
gfilatov
Posts: 1090
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Override LIB Function

Post 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:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
Post Reply