文章分类 | 推荐文章 | 最新文章 | 热点文章 | 最新软件 | 精品软件 | 下载排行 | 推荐下载 | 免费看大片 | WPS | 杀毒软件
清风网络
首 页 软件下载 网络学院 数码学院
QQ 电脑入门 游戏 操作系统 图形处理 办公软件 媒体动画 精文荟萃 工具软件 网络编程 程序开发 网络技术 认证考试 网站建设 文章专栏
当前位置:清风网络学院程序开发C++Builder在BCB下使用GExperts的Debug功能
精品推荐
特别推荐
·菜鸟入门 认识C#中的委托和事件
·WINDOWS下的动态鼠标光标控制
热点TOP10
·在 C++ Builder中利用串行通信控件编程
·用Builder C++设计串行口COM1或COM2的读写操作
·Windows多线程间同步事件的控制方法
·用WinSock控件编写网络聊天器
·在C++ Builder中进行DirectX编程(2)
·C++ Builder VCL库函数简介
·用C++ Builder3 制作记事本
·利用C++ Builder 5.0创建用户自己的网上聊天程序
·C++ Builder 中的自画功能
·C++Builder IDE使用技巧与快捷键
·C++ Builder下数据库报表Master/Detail关系功能的实现
·WINDOWS下的动态鼠标光标控制
·菜鸟入门 认识C#中的委托和事件
·QuickReport基本知识
·C++BUILDER中一些实现界面效果的技巧
·C#动态生成树型结构的Web程序设计
·利用C++ Builder开发动画DLL
·BCB中实现全屏幕OpenGL
·C++Builder注册表编程实例详解
·利用C++Builder遍历文件目录

在BCB下使用GExperts的Debug功能

日期:2007年5月2日 作者: 查看:[大字体 中字体 小字体]



GExperts是BCB的一个插件,其中有一项功能是Debug,非常好用。但是由于定义它的是pas文件(这个文件是GExperts安装目录下DbugIntf.pas),所以不能在BCB中直接使用。我把这个文件转换成C++文件,但是使用的时候注意把dbugintf.h文件copy到工程所在的目录中,直接在文件中用#include引用,不要添加到project中!

具体的使用方法还是看帮助吧!下面是转换后的文件。
/*-----------------------------------------------------------------------------
Unit Name: dbugintf.h
Author:    yuanhen
Email:     yuanhen88@hotmail.com
            yuanhen88@mail.china.com
Purpose:   translate Delphi version to C++Builder's
Date:      2003/06/05
Time:      20:42:08
History:
NOTE NOTE NOTE:
    DON'T ADD this file to your project. Otherwise, this file should be include
    to your project manually
-----------------------------------------------------------------------------*/
#ifndef DBUGINTF_H
#define DBUGINTF_H

#ifdef LINUX
#include <iostream>
#endif LINUX

#include <vcl.h>
#include <Registry.hpp>

//---------------------------------------------------------------------------
// global variables
AnsiString  MsgPrefix;
const char  chrClearCommand = 3;
bool        PastFailedAttemptToStartDebugWin = false;
const AnsiString Indentation = "    ";

// declaration
void SendBoolean(const AnsiString &Identifier, const bool Value);
void SendDateTime(const AnsiString &Identifier, const TDateTime Value);
void SendDebugEx(const AnsiString &Msg, TMsgDlgType MType);

void SendDebug(const AnsiString &Msg);
void SendDebugClear();
void SendInteger(const AnsiString &Identifier, const int Value);
void SendMethodEnter(const AnsiString &MethodName);
void SendMethodExit(const AnsiString &MethodName);
void SendSeparator();
void SendDebugFmt(const AnsiString &Msg, const TVarRec *Args);
void SendDebugFmtEx(const AnsiString &Msg, const TVarRec *Args, TMsgDlgType MType);
HWND StartDebugWin();

// definition
void SendBoolean(const AnsiString &Identifier, const bool Value)
{
  // Note: We deliberately leave "True" and "False" as
  // hard-coded string constants, since these are
  // technical terminology which should not be localised.
  if (Value)
    SendDebugEx(Identifier + "= True", mtInformation);
  else
    SendDebugEx(Identifier + "= False", mtInformation);
}
void SendDateTime(const AnsiString &Identifier, const TDateTime Value)
{
    SendDebugEx(Identifier + '=' + DateTimeToStr(Value), mtInformation);
}
void SendDebugEx(const AnsiString &Msg, TMsgDlgType MType)
{
    TCopyDataStruct CDS;
    HWND            DebugWin;
    AnsiString      MessageString;
#ifdef LINUX
const AnsiString MTypeStr[TMsgDlgType] =
    {"Warning: ", "Error: ", "Information: ", "Confirmation: ", "Custom: "};
#endif LINUX
#ifdef LINUX
    std::cout << "GX: " << MTypeStr[MType] << Msg << std::endl;
#endif LINUX
#ifndef LINUX
    DebugWin = FindWindow("TfmDebug", NULL);

    if (DebugWin == 0)
        DebugWin = StartDebugWin();

    if (DebugWin != 0)
    {
        MessageString = MsgPrefix + Msg;
        CDS.cbData    = MessageString.Length() + 4;
        CDS.dwData    = 0;
        AnsiString com;
        if (Msg == chrClearCommand)
        {
            com = chrClearCommand;
            com += AnsiString(MType + 1) + MessageString;
            com += '\0';
        }
        else
        {
            com = '\1';
            com = com + AnsiString(MType + 1) + MessageString;
            com = com + '\0';
        }
        CDS.lpData = com.c_str();

        SendMessage(DebugWin, WM_COPYDATA, WPARAM(Application->Handle), LPARAM(&CDS));
    }
#endif LINUX
}

void SendDebug(const AnsiString &Msg)
{
    SendDebugEx(Msg, mtInformation);
}
void SendDebugClear()
{
    SendDebug(chrClearCommand);
}
void SendInteger(const AnsiString &Identifier, const int Value)
{
    SendDebugEx(AnsiString(Identifier + " = " + Value), mtInformation);
}
void SendMethodEnter(const AnsiString &MethodName)
{
    MsgPrefix = MsgPrefix + Indentation;
    SendDebugEx("Entering " + MethodName, mtInformation);
}
void SendMethodExit(const AnsiString &MethodName)
{
    SendDebugEx("Exiting " + MethodName, mtInformation);
    MsgPrefix.Delete(1, Indentation.Length());
}
void SendSeparator()
{
    const AnsiString SeparatorString = "------------------------------";
    SendDebugEx(SeparatorString, mtInformation);
}
void SendDebugFmt(const AnsiString &Msg, const TVarRec *Args)
{
    SendDebugEx(Msg.Format(Msg, Args, sizeof(Args)), mtInformation);
}
void SendDebugFmtEx(const AnsiString &Msg, const TVarRec *Args, TMsgDlgType MType)
{
    SendDebugEx(Msg.Format(Msg, Args, sizeof(Args)), MType);
}

HWND StartDebugWin()
{
    AnsiString DebugFilename;
    char Buf[MAX_PATH + 1];
    TStartupInfo si;
    TProcessInformation pi;

    MsgPrefix = "";

    HWND Result = 0;
    if (PastFailedAttemptToStartDebugWin)
        exit;

    TRegIniFile *File = new TRegIniFile("\\Software\\GExperts");
    __try
    {
        DebugFilename = File->ReadString("Debug", "FilePath", "");
    }
    __finally
    {
        delete File;
    }

    if (DebugFilename.Trim() == "")
    {
        GetModuleFileName(NULL, Buf, sizeof(Buf)-1);
        DebugFilename = ExtractFilePath(StrPas(Buf))+"GDebug.exe";
    }
    if (DebugFilename.Trim() == "" (!FileExists(DebugFilename)))
    {
        PastFailedAttemptToStartDebugWin = true;
        exit;
    }

    memset(&si, '\0', sizeof(si));
    si.cb          = sizeof(si);
    si.dwFlags     = STARTF_USESHOWWINDOW;
    si.wShowWindow = SW_SHOW;
    if (!CreateProcess(DebugFilename.c_str(), NULL,
                       NULL, NULL,
                       false, 0, NULL, NULL,
                       &si, &pi))
    {
        PastFailedAttemptToStartDebugWin = true;
        exit;
    }
    __try
    {
        WaitForInputIdle(pi.hProcess, 3000); // wait for 3 seconds to get idle
    }
    __finally
    {
        CloseHandle(pi.hThread);
        CloseHandle(pi.hProcess);
    }
    Result = FindWindow("TfmDebug", NULL);
    return Result;
}
#endif DBUGINTF_H


[1] [2] 下一页 




上一篇:在BCB中实现菜单资源的动态加载

下一篇:在bcb里实现像Winamp那样具有吸附效果的磁性窗口

在BCB下使用GExperts的Debug功能 相关文章:
·GHOST使用方法(图解)
·暗黑破坏神2:毁灭之王 符文物品、符石功能、赫拉笛克方块等 - 游戏秘籍
·Vista系统使用技巧总结
·为什么iexplore.exe在打开网页时CPU使用会100%?
·QQ空间导航代码最新版使用方法
·DataTable控件的使用
·屏蔽五项网络功能 让XP系统极速狂飙
·推荐:漂亮的手机上使用的墙纸图片分享下载
·腾讯QQ号码使用完全指南
·DENX U-Boot及Linux使用手册
在BCB下使用GExperts的Debug功能 相关软件:
·黑客视频教程 VMware虚拟机的安装和使用
·黑客视频教程-灰鸽子远控使用教程
·FLASH 8中文使用手册
·使用GPMC随心所欲管理组策略
·Adobe Photoshop CS 2 简体中文使用指南
·公司企业网站管理系统模板功能强大版
·QQ显IP 显隐身超级版 2款不同功能最新QQ版本 友情下载
·金山词霸2006 SP1 with 牛津英汉双解词典 全功能第二版
·Auto CAD R14高级使用教程
·功能较强的一个FLASH编辑器

特别声明:本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。
[打印本页] [关闭窗口] 转载请注明来源:http://www.viphot.com
| 帮助(?) | 版权声明 | 友情连接 | 关于我们 | 信息发布
Copyright 2007 www.viphot.com All Rights Reserved. 鄂ICP备05000083号Powered by:viphot