Results 1 to 7 of 7

Thread: [RESOLVED] Robust Debug/Console Window for Printing

  1. #1

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,915

    Resolved [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.

  2. #2
    Fanatic Member
    Join Date
    Feb 2019
    Posts
    924

    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:
    1. Public Declare Sub OutputDebugString Lib "kernel32" Alias "OutputDebugStringA" (ByVal lpOutputString As String)
    2.  
    3. Public Sub DebugPrint(ByRef s As String)
    4.     Debug.Print s
    5.     OutputDebugString s & vbCrLf
    6. End Sub
    The only drawback is that it doesn't support Print syntax, so you can't use ",;"

  3. #3
    Fanatic Member
    Join Date
    Feb 2019
    Posts
    924

    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.

  4. #4
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    6,192

    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:
    1. Public Sub OutputDebugString(sText As String)
    2.     Static lLogging     As Long
    3.    
    4.     If lLogging = 0 Then
    5.         lLogging = IIf(Val(Environ$("_MY_PLUGIN_ALLOW_DEBUG")) <> 0, 1, -1)
    6.     End If
    7.     If lLogging > 0 Then
    8.         Call APIOutputDebugString(sText)
    9.     End If
    10. End Sub
    Using DbgView.exe for the actual message viewer.

    cheers,
    </wqw>

  5. #5

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,915

    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.

  6. #6

  7. #7

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,915

    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
  •  



Click Here to Expand Forum to Full Width