Add includes while modifying minimum of code
Posted: Sat Jan 03, 2026 6:32 pm
Hello at all,
For my project, after use the method "embeded addons.exe", i search another method for adding include while modifying minimum of code in the main windows but also in the include too (The more simple way)
With this method, each include can be compiled and working alone, and also adding before compiling in the mother application like an ADDON
I'd like to get your opinion before I start making all the changes, and also to know if you know of anything simpler.
I have take a look to the PB IDE code of FRED, and i see, he use different constants and functions for each addon, at my advice it's the more simple way, because i have understand
But perhaps another method can be automatic, just adding the line "IncludeFile MyAddon.pbi" and the mother code can include all the events of the addon
I have try with the MACROS, but it's a little bit too complex for KCC
The mother code
The include code
Have a good day
For my project, after use the method "embeded addons.exe", i search another method for adding include while modifying minimum of code in the main windows but also in the include too (The more simple way)
With this method, each include can be compiled and working alone, and also adding before compiling in the mother application like an ADDON
I'd like to get your opinion before I start making all the changes, and also to know if you know of anything simpler.
I have take a look to the PB IDE code of FRED, and i see, he use different constants and functions for each addon, at my advice it's the more simple way, because i have understand
But perhaps another method can be automatic, just adding the line "IncludeFile MyAddon.pbi" and the mother code can include all the events of the addon
I have try with the MACROS, but it's a little bit too complex for KCC
The mother code
Code: Select all
Enumeration
#FormMain
#ButtonMain
EndEnumeration
Structure Include
EvenementsWin.i
EvenementsGad.i
EndStructure
Global NewMap MapInclude.Include()
IncludeFile "Include_1.pbi"
Procedure Main_GadgetsEvents(EvenementGadget)
Select EvenementGadget
Case #ButtonMain
MessageRequester("", "Le bouton dans la fenetre principale a été cliqué")
EndSelect
EndProcedure
Procedure Main_WindowEvents(Evenement)
Fenetre = EventWindow()
Select Evenement
Case #PB_Event_MoveWindow
Debug WindowX(#FormMain)
Debug WindowY(#FormMain)
Case #PB_Event_LeftDoubleClick
Debug "Double clic sur la fenetre principale"
EndSelect
EndProcedure
OpenWindow(#FormMain, 150, 150, 250, 250, "Fenetre principale", #PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
ButtonGadget(#ButtonMain, 50, 50, 160, 40, "Boutton principal")
Repeat
Evenement = WaitWindowEvent()
EvenementGadget = EventGadget()
IdFenetre = EventWindow()
Select Evenement
Case #PB_Event_Gadget
If IdFenetre = #FormMain
Main_GadgetsEvents(EvenementGadget)
Else
ForEach MapInclude()
CallFunctionFast(MapInclude()\EvenementsGad, EvenementGadget)
Next
EndIf
Case #PB_Event_CloseWindow
If IdFenetre = #FormMain
End
Else
CloseWindow(IdFenetre)
EndIf
Default
If IdFenetre = #FormMain
Main_WindowEvents(Evenement)
Else
ForEach MapInclude()
CallFunctionFast(MapInclude()\EvenementsWin, Evenement)
Next
EndIf
EndSelect
ForEver
Code: Select all
Enumeration #PB_Compiler_EnumerationValue
#FormInclude1
#ButtonInclude1
EndEnumeration
Procedure Include1_WindowEvents(Evenement)
Fenetre = EventWindow()
Select Evenement
Case #PB_Event_MoveWindow
Debug WindowX(#FormInclude1)
Debug WindowY(#FormInclude1)
Case #PB_Event_LeftDoubleClick
Debug "Double clic sur la fenetre Include1"
EndSelect
EndProcedure
Procedure Include1_GadgetsEvents(EvenementGadget)
Select EvenementGadget
Case #ButtonInclude1
MessageRequester("", "Le bouton dans la fenetre Include1 a été cliqué")
EndSelect
EndProcedure
OpenWindow(#FormInclude1, 150, 150, 250, 250, "Include1", #PB_Window_SizeGadget|#PB_Window_MinimizeGadget)
ButtonGadget(#ButtonInclude1, 50, 50, 160, 40, "Boutton Include1")
CompilerIf #PB_Compiler_IsMainFile
Repeat
Evenement = WaitWindowEvent()
EvenementGadget = EventGadget()
Select Evenement
Case #PB_Event_Gadget
Include1_GadgetsEvents(EvenementGadget)
Default
Include1_WindowEvents(Evenement)
EndSelect
Until Evenement = #PB_Event_CloseWindow
CompilerElse
MapInclude("Include1")\EvenementsWin = @Include1_WindowEvents()
MapInclude("Include1")\EvenementsGad = @Include1_GadgetsEvents()
CompilerEndIf