00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00023 #ifndef INCLUDE_MY_DEBUG_H
00024 #define INCLUDE_MY_DEBUG_H
00025
00026 #include <windows.h>
00027 #include <stdio.h>
00028 #include <stdarg.h>
00029 #include "MyString.h"
00030
00043 class MyDebug
00044 {
00045 public:
00046 static HWND hWndServer;
00047
00048 static BOOL Send(char *message)
00049 {
00050 COPYDATASTRUCT cpd;
00051 cpd.dwData = 0;
00052 cpd.cbData = (DWORD)strlen(message)+1;
00053 cpd.lpData = (void *)message;
00054 return (BOOL)SendMessage(MyDebug::hWndServer, WM_COPYDATA, NULL,(LPARAM)&cpd);
00055 }
00056
00057 public:
00058 MyDebug()
00059 {
00060 Start();
00061 }
00062
00063 ~MyDebug()
00064 {
00065 }
00066
00067 static void Start()
00068 {
00069 if (!hWndServer)
00070 {
00071 FindServer();
00072 }
00073 }
00074
00075 static BOOL FindServer()
00076 {
00077 hWndServer = FindWindow(NULL,"DebugServer");
00078 return hWndServer?TRUE:FALSE;
00079 }
00080
00081 static BOOL SendEvent(char *tabName,char *message,...)
00082 {
00083 MyString buffer;
00084
00085 char temp[1024];
00086 va_list args;
00087 va_start(args,message);
00088 vsprintf(temp,message,args);
00089
00090 buffer<<"#event \""<<tabName<<"\" "<<temp<<"\n";
00091 return Send(buffer);
00092 }
00093
00094 static BOOL SendLine(char *tabName,char *message,...)
00095 {
00096 MyString buffer;
00097
00098 char temp[1024];
00099 va_list args;
00100 va_start(args,message);
00101 vsprintf(temp,message,args);
00102
00103 buffer<<"#line \""<<tabName<<"\" "<<temp<<"\n";
00104 return Send(buffer);
00105 }
00106 };
00107
00108 #endif
00109