目前 VS 是我工作最常碰到的 IDE,無奈的 VC6.0 是整個專案延續下來的遺產 ( 期望有機會整個移植出來 )。
用 VS 系列同好大概都對其 debug 功能有所讚許,唯 VC6.0 debug 功能其實還不算穩定,
在 Debug Mode (不是 Release Mode) 下有些特別的情況...
像是整個 IDE 當掉、Watch 視窗竟然找不到 Local Variable... etc,
其實更糟的是 VC6.0 的自定義視窗拖拉,做得很糟,一個螢幕範圍可以放得 Debug Information 其實很少。
我花了點時間寫一個 DbgWindow.exe,裡面是很單純的放三個東西
(1) check button : 切換 always on top。
(2) slider (track bar) : 調視窗透明度,vc6.0 要完成這功能的話要 LoadLibrary。
(3) edit box : 給外部程式放偵錯訊息用。
然後再寫一個 class ,裡面大致內容如下
//////////////////////////////////////////////////////////////////////////
xEnginnerTool::xEnginnerTool()
{
if(!(m_hWnd = FindWindow(NULL, "xEnginnerTools"))){
WinExec("xEnginnerTools.exe", SW_SHOW);
Sleep(1);
if(!(m_hWnd = FindWindow(NULL, "xEnginnerTools"))) {
MessageBox(NULL, "Can't Find Window xEnginnerTools", "xEnginnerTool fail", MB_OK);
return;
}
}
m_TxtCtrl = GetDlgItem(m_hWnd, 1003);
if(m_TxtCtrl==NULL)
MessageBox(NULL, "Can't Find Txt Editor", "xEnginnerTool fail", MB_OK);
m_szBuf = "";
}
void xEnginnerTool::Print( const char * s )
{
m_szBuf += string(s);
SendMessage(m_TxtCtrl ,WM_SETTEXT , NULL, (LPARAM)m_szBuf.c_str());
}
//////////////////////////////////////////////////////////////////////////
當然還有一堆擴充。壞處是速度應較慢 (不過我想對正在 Debug 的人而言應該還好? ),唯一的好處是可以設 Always on top 及透明度。目前不知道有沒有哪些 IDE 會針對 Debug Window 做透明度設定就是了(我想應該沒有吧~)。然後再繼續擴下去的話,其實可以把 C 語言裡的 console 弄到 Dialog 下執行。關鍵又是噁心的 #define
//////////////////////////////////////////////////////////////////////////
#define MY_DEBUG
#ifdef MY_DEBUG
#include "xEnginnerTool.h"
#define printf dbg.PrintFormat
#define putchar dbg.PrintChar
#define puts dbg.PrintLine
xEnginnerTool dbg;
#endif
//////////////////////////////////////////////////////////////////////////
弄張圖上來做個紀念吧。原本是在 console 裡的執行結果,跑到 dialog 裡去了。
因為是應急用的,所以其實算隨便亂寫,一些 idea 先紀錄。
Note
(0) DbgWindow.exe ,Dialog 顯示字型挑等寬,我採用 Courier New
(1) 想了一下,class xEnginnerTool 用獨體模式可能會好點。
(2) 有考慮直接在 class xEnginnerTool constructor 裡,"有考慮" 直接開一個 Thread,裡面用 Win32 DialogBox,再放三個子控制。好處是這樣就等於是廢掉 DbgWindow.exe ,壞處是多開了一條 Thread 做 Debug...這對原本的開發程式在開發時又是一筆負擔。故最後還是止於開 DbgWindow.exe。
(3) 目前不知道有沒有這份 class 已經寫好就是了,說實在我沒心力把這東西搞完整。
留言列表