about writing function

122 views
Skip to first unread message

Jackson Santos

unread,
Jun 5, 2026, 2:40:55 PMJun 5
to Harbour Minigui
Hello friends of the group
Is there a way for me to overwrite a function that already exists in the minigui library and not generate duplication errors when compiling? For example: I want to overwrite msginfo and not generate an error when compiling this function.

Adam Lubszczyk

unread,
Jun 12, 2026, 6:59:19 AMJun 12
to Harbour Minigui
Example way to overvrite MsgInfo()   !! For all functions that use it !!

Copy to test folder files:
  minigui\SAMPLES\BASIC\ini\demo.prg       <-- sample demo with MsgInfo
  minigui\SOURCE\h_msgbox.prg                    <-- source of MsgInfo function 

Correct the code of the MsgInfo() function in h_msgbox.prg,  ( Leave the rest of the code in h_msgbox.prg  unchanged  !!! )  e.g. :  
....
FUNCTION MsgInfo ( Message, Title, nIcon, lSysModal, lTopMost )
   LOCAL nStyle := MB_OK
   nStyle += iif( hb_defaultValue( nIcon, 0 ) == MB_DEFAULT_ICON, MB_ICONINFORMATION, MB_USERICON )
RETURN _MsgBox( Message, "TEST Overwrite :) "+hb_defaultValue( Title, _HMG_MESSAGE [11] ), nStyle, nIcon, lSysModal, lTopMost )
....

In demo.prg, add at the END  line:
#include "h_msgbox.prg"

Compile demo.prg.
All MINIGUI functions use Your version of MsgInfo()

Adam

Adam Lubszczyk

unread,
Jun 12, 2026, 7:09:56 AMJun 12
to Harbour Minigui
Additionally, create a folder named DEMO.INI  to trigger the error.
Run test.exe.
You'll see that the INI library also uses your version of MsgInfo() to display the error message.

Grigory Filatov

unread,
Jun 13, 2026, 6:32:13 AMJun 13
to Harbour Minigui

Hello Jackson,

Yes, but you cannot simply create another MsgInfo() function with the same name because MinGW compiler will generate a duplicate symbol/function error during linking.

If your goal is to replace all calls to MsgInfo() with your own implementation, you can use a preprocessor directive such as:

#translate MsgInfo( <cMsg>, [<cTitle>] ) => MyMsgInfo( <cMsg>, <cTitle> )

and then implement your own MyMsgInfo() function.

This way, every call to MsgInfo() in your application source code will be translated to MyMsgInfo() at compile time, avoiding any duplicate function definitions.

Regards.

Grigory

пятница, 5 июня 2026 г. в 20:40:55 UTC+2, jac...@cavalomarinhoinformatica.com.br:

Jackson Santos

unread,
Jun 13, 2026, 6:40:52 AMJun 13
to Grigory Filatov, Harbour Minigui
Good morning Thank you

--
Visit our website on https://www.hmgextended.com/ or https://www.hmgextended.org/
---
You received this message because you are subscribed to the Google Groups "Harbour Minigui" group.
To unsubscribe from this group and stop receiving emails from it, send an email to minigui-foru...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/minigui-forum/dc2dfe2b-630b-4511-b634-3db331fe733dn%40googlegroups.com.

Adam Lubszczyk

unread,
Jun 15, 2026, 6:44:16 AMJun 15
to Harbour Minigui
Correct verison:
#translate MsgInfo( <cMsg> [ , <cTitle>] ) => MyMsgInfo( <cMsg>, <cTitle> )

 and better:
#xtranslate MsgInfo( <cMsg> [ , <cTitle>] ) => MyMsgInfo( <cMsg>, <cTitle> )

With #translate  like with  #command  you  may  trucate function name to 4 chars,  so
Msgi( "abc" )  ,  Msgin( "abc" )  ,  Msginf( "abc" )    to  be   also  translated


#xtranslate work ONLY with your code (not modify function in linked library)

Adam
Reply all
Reply to author
Forward
0 new messages