Windows message debugging for

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

Download the source as CHM and PDF file

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

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"

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

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)

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


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