Hi,
is there a small tutorial how to do that?
I would need to clear all lines from that gui part (#GADGET_ErrorLog) on invocation of the tool (one that would be running via menu - tools - configure tools...) and then write (line by line) content into it again...
Thanks!
Tool - How to clear and write text into the log window part?
Re: Tool - How to clear and write text into the log window part?
Writing to the IDE is straightforward with WriteIDELog from here. Deleting the log is a little more tricky. Normally you would just use SendMessage(hWnd_IDE, #LB_RESETCONTENT, 0, 0) to clear the listbox, but PB stores the text lines so that they can be restored on a tab switch. Using WriteIDELog afterwards would just restore the previous text. It is therefore better to call the menu ID for “Clear log” directly and let PB do its thing... If #WM_COMMAND with id 73 doesn't clear the log in your IDE, you have to find the id yourself

Code: Select all
Procedure WriteIDELog(hWnd, text$)
If hWnd
Protected CopyData.COPYDATASTRUCT
CopyData\dwData = ('L' << 16) | ('O' << 8) | 'G'
CopyData\cbData = StringByteLength(text$, #PB_Ascii)
CopyData\lpData = AllocateMemory(CopyData\cbData + 1)
If CopyData\lpData
PokeS(CopyData\lpData, text$, -1, #PB_Ascii)
SendMessage_(hWnd, #WM_COPYDATA, #Null, @CopyData)
FreeMemory(CopyData\lpData)
EndIf
EndIf
EndProcedure
hWnd_IDE = Val(GetEnvironmentVariable("PB_TOOL_MainWindow"))
If hWnd_IDE
SendMessage_(hWnd_IDE, #WM_COMMAND, 73, 0) ;;; Clear the errorlog window. Use spyxx_amd64.exe (Messages) or similar to get the menu id
WriteIDELog(hWnd_IDE, "Hello, I'm an Errorlog message...")
WriteIDELog(hWnd_IDE, "... and another one")
EndIf
Et cetera is my worst enemy
Re: Tool - How to clear and write text into the log window part?
Thanks a lot chi!
On my system 73 is the correct id for that menu entry as well
Although a solution (from Fred) with a more general approach (a menu id could change in the future and then you can't easily support older and newer guis) to clear the log would be nice
Again, thank you, everything is working as expected atm
On my system 73 is the correct id for that menu entry as well

Although a solution (from Fred) with a more general approach (a menu id could change in the future and then you can't easily support older and newer guis) to clear the log would be nice

Again, thank you, everything is working as expected atm

Re: Tool - How to clear and write text into the log window part?
Happy to helphighend wrote: Fri May 17, 2024 8:56 am Thanks a lot chi!
On my system 73 is the correct id for that menu entry as well
Although a solution (from Fred) with a more general approach (a menu id could change in the future and then you can't easily support older and newer guis) to clear the log would be nice![]()
Again, thank you, everything is working as expected atm![]()

About the id: To iterate through all menu items with WinAPI, you can use GetMenu, GetMenuItemCount, GetMenuItemID and GetMenuString. After that it is quite easy to get the id for "Clear log" for past/future PB-IDE's...
Et cetera is my worst enemy
Re: Tool - How to clear and write text into the log window part?
Not necessarily 
At least not without (a bit of) effort because of different menu languages...
And timing is also crucial. You shouldn't execute that menu entry and immediate write to the log window part again.
At least here the first line is normally lost when I don't use a Sleep_(xxx) after the SendMessage_()

At least not without (a bit of) effort because of different menu languages...
And timing is also crucial. You shouldn't execute that menu entry and immediate write to the log window part again.
At least here the first line is normally lost when I don't use a Sleep_(xxx) after the SendMessage_()
Re: Tool - How to clear and write text into the log window part?
True, to make it more bulletproof, you have to fiddle around a bit 

Et cetera is my worst enemy