|
-
Apr 27th, 2019, 10:25 AM
#1
[RESOLVED] Robust Debug/Console Window for Printing
I'm in a situation where I'd like a robust Immediate window (just for printing out things during runtime). I'm working on something that's often crashing my IDE. (I'd go into what that is, but it's not necessary for my question.)
So, when the IDE crashes, I lose anything I've printed to the Immediate window. I've been thinking about a print to some console window. The only thing that comes to mind is writing a second program that hooks its window and listens for WM_COPYDATA. Also, that window could have some very unique title so it could be found by other applications.
Then, in my IDE crashing development application, I could find that unique top-level title, and send messages to it with WM_COPYDATA.
I haven't started, but I'll probably test that concept.
I'm just wondering if I'm overlooking something easier. I'm in a situation where I need to put in Debug.Print statement (or something similar), and not lose it if/when the IDE crashes.
Yeah, I know I could append to a file, but I'd like something that's more immediately visible to me.
Thanks,
Elroy
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Apr 27th, 2019, 10:35 AM
#2
Fanatic Member
Re: Robust Debug/Console Window for Printing
I use OutputDebugString() API function in these situations, which sends the output to this external debugger(No installation needed, just unzip). The function wrapper below would cover both printing in the IDE and the EXE:
VB Code:
Public Declare Sub OutputDebugString Lib "kernel32" Alias "OutputDebugStringA" (ByVal lpOutputString As String) Public Sub DebugPrint(ByRef s As String) Debug.Print s OutputDebugString s & vbCrLf End Sub
The only drawback is that it doesn't support Print syntax, so you can't use ",;"
-
Apr 27th, 2019, 11:12 AM
#3
Fanatic Member
Re: Robust Debug/Console Window for Printing
Also, if you have VC6 installed, there is an easy way to find the cause of a GPF in a compiled VB6 app, see here for details.
-
Apr 27th, 2019, 12:04 PM
#4
Re: Robust Debug/Console Window for Printing
I'm using the same DebugPrint as qvb6 suggested w/ the added twist that actual debug output is activated w/ an environment "switch" variable like this
thinBasic Code:
Public Sub OutputDebugString(sText As String) Static lLogging As Long If lLogging = 0 Then lLogging = IIf(Val(Environ$("_MY_PLUGIN_ALLOW_DEBUG")) <> 0, 1, -1) End If If lLogging > 0 Then Call APIOutputDebugString(sText) End If End Sub
Using DbgView.exe for the actual message viewer.
cheers,
</wqw>
Last edited by wqweto; Apr 29th, 2019 at 02:15 AM.
-
Apr 28th, 2019, 12:44 PM
#5
Re: Robust Debug/Console Window for Printing
Hmmm, well, I took a look at the OutputDebugString option (in conjunction with the DebugView program), and that's not a bad option at all. However, and I'm not sure why, but I seem to have a couple of other programs running that are somewhat regularly posting debug information, and it gets woven in with my debug messages. I should probably look into those other program.
But anyway, I decided to write my own, and just finished it. Personally, I think it's pretty cool, so I'm going to post it in the CodeBank.
Thanks to all for the consideration on this. 
Elroy
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Apr 28th, 2019, 01:34 PM
#6
Re: [RESOLVED] Robust Debug/Console Window for Printing
Elroy, you can implement the IVBPrint interface in a class and create a predeclared instance of that one which wraps the OutputDebugString function. In this case you can use the code like cSomeClass.Print aa; b, qwq;;; etc. which is very similar to Debug.Print.
Alternatively, the immediate pane supports the IVBPrint interface and you can intercept and route the messages to file/pipe/etc.
-
Apr 28th, 2019, 02:35 PM
#7
Re: [RESOLVED] Robust Debug/Console Window for Printing
Great idea Trick. I see where Eduardo has used it a couple of times. When I revisit my Persistent Debug Print Window program, I'll definitely slip that in.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|