Windows message debugging for
PureBasic

Debugging routines for windows messages. This is only useful for windows
PureBasic developers.

























































Download the source as CHM and PDF file
here

Download the
Sumatra PDF reader which also supports displaying CHM files.
Usage

For each project you define a symbol called EVENTDEBUG in your central project configuration
include file. Because there is a large amount of window messages being passed to windows
applications, enabling to display all of them, creates a large amount of text output. The parsing and
displaying into readable text, can significantly slowdown your application. Therefore we handle two
different cases.

Case 1 - During development
Case 2 - for beta or final release

A simple (though not perfect) solution is to use a global definition in a central place. As this kind of
problem is a part of most windows applications, it should be easy to drop it into any project to use it.
Personally i use a unique "apptypes.pbi" include file for all main project settings.
top of your main project source file:


CompilerIf (#EVENTDEBUG = 1)
XIncludeFile "DecodeWindowsMessage.pb"
CompilerEndIf CompilerIf (#EVENTDEBUG = 1)
XIncludeFile "DecodeWindowsMessage.pb"
CompilerEndIf



Add the following line to your global project definitions file (for example "apptypes.pbi")
#EVENTDEBUG = 1

The Windowcallback function of your main source file. Add one line for each window of your
application. That way your message debug output is easier to read.



CompilerIf (#EVENTDEBUG = 1)
WinName$ = "unknown"
If (WindowID(#Window_MainWindow) = WindowID) : WinName$ = "MainWindow" : EndIf
If ((IsWindow(#Window_MySubWindow) <> 0) And (WindowID(#Window_MySubWindow) = WindowID)) : WinName$ = "SubWindow" : EndIf
Debug WinName$ + " / " + DecodeWindowsMessage(WindowID,Message,wParam,lParam)
CompilerEndIf












Hook the window callback procedure. This should happen right after your main program window was
successfully opened.

SetWindowCallback(@WindowCallback())

Add the following file to your project files: DecodeWindowsMessage.pb
During development you set the "#EVENTDEBUG" constant to 1 and for a release/beta build, you set
the value to 0