所见及所得的类分析跟踪器

2016-02-19 12:52 6 1 收藏

想要天天向上,就要懂得享受学习。图老师为大家推荐所见及所得的类分析跟踪器,精彩的内容需要你们用心的阅读。还在等什么快点来看看吧!

【 tulaoshi.com - 编程语言 】

  {以下代码可以分析Windows下的鼠标处的对象类名,句柄及其递归父类等信息,是很久以前火鸟的工具软件视窗超人中的一段代码。其触发使用了Timer控件,其实更好的实现是用Windows Mouse Hook来做触发,就当抛砖引玉吧;此代码还实现了不依赖于Windows2000以上要求的半透明窗口(在Win98/WinMe下也可半透明),本实现的实现其实比较类似于金山词霸的即指即译功能,只不过大家在做不同的应用而已。 在Delphi环境下,新建一个窗体,把代码贴入即可,本工具主要会对做Windows环境下的开发人员工作有些帮助(如分析别人的程序的控件对象,跟踪对象句柄等)}
  unit Unit1;

  interface

  uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, ExtCtrls, StdCtrls;

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

  type
    TForm1 = class(TForm)
      procedure Timer1Timer(Sender: TObject);
      procedure FormCreate(Sender: TObject);
    private
      { Private declarations }
    public
      { Public declarations }
    end;

  var
    Form1: TForm1;
    Timer1: TTimer;

  implementation

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

  {$R *.dfm}

  procedure TForm1.Timer1Timer(Sender: TObject);
  var poss:TPoint;
      ic:Hdc;
      Bmp:TbitMap;
    Hands: HWND;
    Buf: array[0..129] of Char;
    Stmp:TStrings;
    itmp,iwidth,iheight:integer;
    sword,sline:string;
  begin
    GetCursorPos(Poss);
    with self do
    begin
      if (poss.x tag-10) or (poss.ytimer1.Tag-10) then left:=screen.Width
      else
      begin
        Hands := WindowFromPoint(Poss);
        if (left=tag) or (hands=handle) then exit;
        stmp:=TStringList.create;
        stmp.Add('句柄: '+IntToStr(Hands));
        GetClassName(Hands, Buf, 128);
        stmp.Add ('类名: '+Buf);
        itmp:=GetParent(Hands);
        while itmp0  do
        begin
            GetClassName(itmp, Buf, 128);
            if buf'' then stmp.Add (inttostr(stmp.Count-1)+'级父类: '+Buf);
            itmp:=GetParent(itmp);
        end;
        SendMessage(Hands, WM_GETTEXT, 128, Integer(@Buf));
        sword:='字符: '+buf;
        if length(sword)132 then sword:=sword+'....';
        repeat
          itmp:=pos(chr(10),sWord);
          if itmp0 then
          begin
            sline:=copy(sWord,1,itmp-1);
            sword:=copy(sWord,itmp+1,length(sword));
          end
          else sline:=sword;
          itmp:=pos(chr(13),sline);
          if itmp0 then sline:=copy(sline,1,itmp-1);
          stmp.Add(sline);
        until sline=sword;
        iwidth:=0;
        for itmp:=0 to stmp.Count-1 do if canvas.TextWidth(stmp[itmp])+15iWidth then iWidth:=canvas.TextWidth(stmp[itmp])+15;
        iheight:=stmp.Count*(canvas.TextHeight(stmp[0])+2);
        width:=iwidth;
        height:=iheight;
        SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE+ SWP_NOSIZE+SWP_NOACTIVATE+SWP_NOOWNERZORDER);
        ic:=CreateDC('DISPLAY',nil,nil,nil);
        if tag+widthscreen.Width then tag:=screen.Width-width;
        if timer1.Tag +heightscreen.Height then timer1.Tag:=screen.Height-height;
        Bmp:=Tbitmap.Create;
        bmp.Width := Width;
        bmp.Height :=Height;
        bitblt(bmp.Canvas.handle,0,0,Width,Height,ic,tag,timer1.Tag,SRCCOPY);
        Left :=tag;
        Top :=timer1.tag;
        bitblt(canvas.handle,0,0,Width,Height,bmp.Canvas.handle,0,0,SRCAND);
        canvas.Font.Color:=$0000FF;
        SetBkMode(canvas.handle,TRANSPARENT);
        for itmp:=0 to stmp.Count-1 do canvas.TextOut(5,5+itmp*canvas.TextHeight(stmp[itmp]),TrimRight(stmp[itmp]));
        deletedc(ic);
        bmp.free;
        stmp.Free;
      end;
      tag:=poss.x+10;
      timer1.Tag:=poss.y+10;
    end;
  end;
  procedure TForm1.FormCreate(Sender: TObject);
  begin
    self.BorderStyle:=bsNone;
    Timer1:=TTimer.Create(self);
    timer1.Interval:=300;
    timer1.OnTimer:=Timer1Timer;
  end;

  end.
  

来源:https://www.tulaoshi.com/n/20160219/1602262.html

延伸阅读
标签: ASP
  First you need a database to store your banners. We are using 2 tables; tblBanners and tblVendors: tblBanners: bID - auto number (banner ID) bBanner - text (image file) bUsedViews - number (# of views the banner has received) bTotalViews - number (# of impressions the vendor has paid for) bClicks - number (# o...
===================类的代码========================== {*******************************************************} {                               &n...
深入分析MFC中的CArray类 作者:湖北 董志勇 我们在使用vc进行比较复杂的编程时,经常需要用到复杂的数组结构,并希望能实现动态管理。由于C++并不支持动态数组,MFC提供了一个CArray类来实现动态数组的功能。有效的使用CArray类,可以提高程序的效率。 MFC提供了一套模板库,来实现一些比较常见的数据结构如Ar...
标签: 育儿知识
幼儿厌学的原因及对策分析 很多家长都碰到过这样的情况:突然某一天孩子告诉自己,明天不要上幼儿园了。早上也不愿意去学校,再说说就哭闹,怎么也不愿意去。为此,家长伤透了脑筋,怎么好好的就不愿意上学了呢? 图老师一位有多年教育经验的教师指出,孩子厌学,主要有如下几点原因: 1、与同学相处不融洽,觉得上学去就是受欺负...
鸡蛋的营养分析及功能     妈妈可能在坐月子期间也吃了不少的鸡蛋了吧,为什么要吃鸡蛋呢?鸡蛋有哪些营养,它有哪些保健功能呢?       鸡蛋的营养分析     鸡蛋中含有丰富的DHA和卵磷脂等,对神经系统和身体发育有很大的作用,能健脑益智,避免老年人智...

经验教程

822

收藏

43
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部