Thanks to mk-soft => LIB-PB v6.20+: IDE-Tool Build Library for all OS
and pf shadoko => PureLibrary Creator - PB 6.20
In my own experiments, I have created the following functions. For now they are windows only, but perhaps in the future .....
1. RestartCompilerNow() ; works only on windows
2. CompilerConfig_GetSaveSettingsMode()
Code: Select all
Procedure RestartCompilerNow()
Protected hwnd, item$, position
Protected hMenu, hSubMenu, wParam, mii.MENUITEMINFO
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
hwnd = Val(GetEnvironmentVariable("PB_TOOL_MainWindow")) ; - OS handle to the main IDE window
If hwnd = 0 ; fall back and testing
hwnd = FindWindow_(0, @"PureBasic 6.30 beta 2 (x64)") ; use your IDE
EndIf
If hwnd
Debug "PureBasic IDE found ..... "
hMenu = GetMenu_(hwnd)
If hMenu
; File 0) | Edit (1) | Project (2) | Form (3) | Compiler (4) | Debugger (5) ....
hSubMenu = GetSubMenu_(hMenu, 4) ; zero-based item (by position)
If hSubMenu
mii\cbSize = SizeOf(MENUITEMINFO)
mii\fMask = #MIIM_STRING | #MIIM_ID
mii\dwTypeData = 0
; count zero-based menu items (don't forget the MenuBar)
position = 7 ; Restart Compiler
; position = 9 ; Options // Test successfully -> the dialog is open
If GetMenuItemInfo_(hSubMenu, position, #True, @mii)
mii\cch + 1 ; needed for the entire text <??>
item$ = Space(mii\cch)
mii\dwTypeData = @item$ ; pointer to allocated memory
If GetMenuItemInfo_(hSubMenu, position, #True, @mii)
Debug " Menu Item = '" + item$ + "'" ; == "Re&start Compiler"
Debug " Menu Item ID = " + mii\wID
wParam = (mii\wID & $FFFF) ; LoWord is IDM_*
PostMessage_(hwnd, #WM_COMMAND, wParam, 0) ; let the IDE restart the compiler ??
EndIf
EndIf
EndIf
EndIf
Else
Debug "PureBasic IDE not found "
EndIf
; CompilerCase #PB_OS_Linux
; CompilerCase #PB_OS_MacOS
CompilerEndSelect
; ProcedureReturn 0
EndProcedure
Code: Select all
; CCS := CompilerConfigStorage
;
Enumeration ECompilerConfigStorage
#CCS_EndOfFile ; == 0
#CCS_PerFileCfg ; == 1
#CCS_PerFolderCfg ; == 2
#CCS_DoNotSave ; == 3
EndEnumeration
; PureBasic.prefs
; [Global]
; .....
; SaveSettingsMode = 0
; .....
; #PB_TOOL_Preferences .. Full path and filename of the IDE's Preference file
Procedure CompilerConfig_GetSaveSettingsMode() ; returns #CCS_X
Protected result, prefsfile$
prefsfile$ = "" ; (default)
result = #CCS_DoNotSave ; (default)
prefsfile$ = GetEnvironmentVariable("PB_TOOL_Preferences") ; the full filename including path !!
If Not Asc(prefsfile$) ; fall back and testing
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows ; standard installation stores the stuff here ??
prefsfile$ = GetEnvironmentVariable("APPDATA") + "\PureBasic\PureBasic.prefs"
;CompilerCase #PB_OS_Linux
;CompilerCase #PB_OS_MacOS
CompilerEndSelect
EndIf
If Asc(prefsfile$) And OpenPreferences(prefsfile$) ; take a closer look
PreferenceGroup("Global")
result = ReadPreferenceInteger("SaveSettingsMode", #CCS_DoNotSave)
ClosePreferences()
EndIf
ProcedureReturn result
EndProcedure


