- I first tried placing lots of InfoBox() calls to report on the code state. This worked to a point, but when I needed to see what way going on in a dynamic cursor, or anywhere that the user needed to interact with CC3, the InfoBox() tended to interfere. Plus building a string, that usually included numbers, just to output it to a message box seemed like a lot of work.
- Then I added a bunch of code to write to a text file. This worked great but is was quite a bit of code and if I forgot to remove it, the end users got debug files that the shouldn't have. Plus you still needed to do all that code for creating your output string. And, if you wanted the file readable, you needed to include newlines, tabs etc.
Unfortunately, with the development of windowing software we no longer have the console window. Or do we?
If you are developing an XP add-on, (or any windows application for that matter) adding a console window is quite easy. Simply slip into your code two commands: AllocConsole & FreeConsole.
Simply change your code to match the code bellow and start some searious debugging!
Code Snippet - Display Console Window
- BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
- {
- switch (dwReason)
- {
- case DLL_PROCESS_ATTACH:
- {
- AllocConsole();
- MyXP.ModHdl=hDLL;
- XPRegCmd(&MyXP);
- break;
- }
- case DLL_PROCESS_DETACH:
- {
- FreeConsole();
- XPUnregCmd(&MyXP);
- break;
- }
- }
- return TRUE;