我想做一个屏幕精灵,象WORD的助手那样。我现在利用不规则窗口实现了静态的屏幕精灵,但是要做多帧时,其他帧会进行叠加!怎么刷新桌面是个大问题,另外不规则窗口每帧都要进行区域设置,会出现一些画布出错的情况。请各位大大帮帮忙~分数不够是可以加的!!!

解决方案 »

  1.   

    你可以用agent控件啊。。很好用
    和office一样的
    ************
    * 努力学习 *
    *   全为   *
    *¥人民币¥*
    ************
      

  2.   

    componet->
    import activex control..->
    Microsoft agent control 2.0
    ************
    * 努力学习 *
    *   全为   *
    *¥人民币¥*
    ************
      

  3.   

    SORRY~我知道用agent可以做,但是我想模仿自己做一下,因为就是有几个关键的技术搞不清,有点不甘心~:)
      

  4.   

    在Delphi中调用Agent控件 ---- ⑴、在Delphi IDE 中新建Project1(包含Form1),在Form1上放置Agent1(Name属性为MyAgent)、Button1。 ---- ⑵、定义变量。 Var
    Peedy: IagentCtlCharacterEx;
    Request1,Request2: IagentCtlRequest;---- ⑶Agent主要属性、方法、事件。 ---- ①Characters属性与Load、Unload方法:初始化Agent,加载动画数据,卸载动画人物 ---- Request1 := MyAgent.Characters.Load( 'Peedy', 'C:\Windows\System\Peedy.acs' ); 
    ---- Peedy := MyAgent.Characters.Character( 'Peedy' ); 
    ---- MyAgent.Characters.Unload('Peedy'); ---- ②Show与Hide方法:显示、隐藏Agent动画人物。参数Fast表示动画人物显示、隐藏的速度。Fast为0表示Agent飞入、飞出,Fast为1表示Agent直接出现、消失,没有动画过程。 ---- Peedy.Show(0); 
    ---- Peedy.Hide(1); ---- ③StopAll、Stop方法:停止所有动作。 
    ---- Peedy.StopAll(''); 
    ---- Peedy.Stop(Request); ---- ④Connected属性:Agent是否与Microsoft Agent服务器连接。 
    ---- MyAgent.Connected := True; ---- ⑤Get_Height、Get_Width、Set_Height、Set_Width方法:获得、设置Agent动画人物的高度、宽度。 AgentHight := Peedy.Get_Height;
    AgentWidth := Peedy.Get_Width;
    Peedy.Set_Height( round(AgentHeight / 2 ));
    Peedy.Set_Width( round( AgentWidth / 2 ));---- ⑥MoveTo方法:参数x,y表示Agent动画人物移动到的坐标,参数Speed表示移动的速度。 ---- Peedy.MoveTo( (Screen.Width-Peedy.Get_Width) Div 2, (Screen.Height-Peedy.Get_Height) Div 2, 2 ); ---- ⑦Interrupt方法:中断指定角色的动画。在几十种动画动作中,有一类后缀名为“ing” 的动作比较特殊,如“processing”、“searching”、“reading”、“writing”,一旦执行就必须通过调用另外一个动画人物的Interrupt方法才能中断 。角色不能中断自身的动作,否则会导致异常。 Request1 := Robby.Play('reading');
    Peedy.Interrupt(Request1);---- ⑧Wait方法:在多个不同动画人物之间协调动画动作,如等待sRobby的当前动作执行完毕后,Peedy做另外一个动作。 Request1 := Robby.Play('read');
    Peedy.Wait(Request1);
    Peedy.Play('search');---- ⑨Play方法:执行指定的动画动作,参数Animation为一常量,表示动画类型。Agent提供了几十种预定义动作,开发软件时只需直接调用这些常量即可。下面简要介绍其中常用的一些常量仅供编程参考。 ---- 动作类型 中文含意 动作类型 中文含意 动作类型 中文含意 Acknowledge 承认 LookDown 向下看 Sad 悲伤
    Alert 警告 LookDownBlink 向下看眨眼 Search 寻找
    Announce 声明 LookUp 向上看 StartListening 开始聆听
    Blink 眨眼 LookUpBlink 向下看眨眼 StopListening 停止聆听
    Confused 迷惑 LookLeft 向左看 Suggest 建议
    Congratulate 祝贺 LookLeftBlink 向左看眨眼 Surprised 吃惊
    Decline 拒绝 LookRight 向右看 Think 思考
    DontRecognize 不承认 LookRightBlink 向右看眨眼 Wave 挥动
    Explain 解释 MoveDown 向下移动 Write 书写
    GestureDown 向下姿势 MoveUp 向上移动 Processing 计算……
    GestureUp 向上姿势 MoveRight 向右移动 Reading 阅读……
    GestureLeft 向左姿势 MoveLeft 向左移动 Searching 寻找……
    GestureRight 向右姿势 Pleased 高兴 Writing 书写……
    GetAttention 获得注意 Read 阅读 Greet
    问候 RestPose 恢复初始状态
    Request := peedy.Play('search');---- ⑩Speak方法:Agent通过调用语音合成引擎,支持英语的语音合成输出功能,只需输入英文字符串,Agent就能通过声卡、音箱“说话”。Agent的当前版本尚不具备支持中文语音合成功能,所以只能以.wav文件的形式播放中文。使用时可以将想要说的中文句子预先录好,以.wav形式存储,在程序中调用即可。参数Text表示文字气球中显示的文字,参数url表示.wav文件的路径。 ---- Peedy.speak('嗨,朋友们,你们好,现在由我为您提供帮助!','C:\新建文件夹\Help.wav'); ---- Peedy.Speak( 'Do you like my help? If so, Please send me an email! Thank you!', '' ); ---- ⑾Commands.Add方法:在Button1Click事件中为Agent添加自定义语音识别命令,参数const Name表示语音命令的标识,参数Caption表示该命令在输入命令窗口中的显示标题,参数Voice表示该命令对应的语句。当用户通过麦克风向动画人物发出语音命令时,触发Agent的Command事件,因此我们可以另外编写一个过程完成语音识别功能。 procedure TForm1.Button1Click(Sender: TObject);
    begin
    Peedy.Commands.Add('Delphi','Run 
    Delphi','Delphi',True,True);
    Peedy.Commands.Add('Visual Basic','
    Run VB','VB',True,True);
    Peedy.Show(0);
    Peedy.Speak('What can I do for you, sir?','');
    end;
      

  5.   

    SORRY~~感谢 rocktan大哥,但是我是想通过自己来作,不想用agent啊~~
    现在的问题就是当我换图片的时候,桌面上的图片会产生前几帧图片叠加的情况,我不知道应该如何解决!:(
      

  6.   

    转载,仅供参考:
    以下是一个演示程序,在DELPHI5.0+WINDOWS2000P中调试通过。创建一个窗体Form1,放上两个Image控件,命名为Image1,Image2,再放上一个Timer控件,命名为Timer1。准备两张位图,一张放入Image1,另一张放入Image2。笔者用了如下样式的位图(截取了一部分),你可以自己画动画对象,也可以借用别人的,笔者就是用微软画的图片。从图片你可以看出,图片中包括了许多连续的动画帧,一张图片完成一个动作,如旋转一周等,每帧动画大小完全一样,除了动画对象其它像素用一种透明色填充。好了你可以看具体的代码了。
    unit Unitmain;
    interface
    uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    ExtCtrls, StdCtrls,mmsystem;
    type
    TForm1 = class(TForm)
    Timer1: TTimer;//爆炸定时器
    Image1: TImage;//储存爆炸的图片
    Image2: TImage;//储存飞行器的图片
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    private
    { Private declarations }
    DeskTopDC:HDC;//桌面窗口的图形设备描述表句柄
    stop:boolean;//控制循环的变量
    expnum:integer;//爆炸的当前次数 
    procedure Explode(X:integer;Y:integer);//爆炸函数
    procedure shipmove(X:integer;Y:integer);//飞行器函数
    public
    { Public declarations }
    end;
    var
    Form1: TForm1;implementation{$R *.DFM}
    //保存桌面背景
    procedure savebackground(BKCanvas :TCanvas;
    sp_w:integer;
    sp_h :integer ;
    nx:integer;
    ny:integer);
    var sc:TCanvas;
    begin
    sc:=TCanvas.Create;
    try
    sc.Handle:=GetDC(0);
    bkcanvas.CopyRect( rect(0,0,sp_w, sp_h), sc,rect(nx, ny, nx+sp_w, ny+sp_h));
    ReleaseDC(0, sc.handle);
    finally
    sc.free;
    end;
    end;
    //透明拷贝图像函数
    //静态调用API函数TransparentBlt
    procedure tranbit(hdcDest:HDC;
    nXOriginDest:integer;
    nYOriginDest:integer;
    nWidthDest:integer;
    hHeightDest:integer;
    hdcSrc:HDC;
    nXOriginSrc:integer;
    nYOriginSrc:integer;
    nWidthSrc:integer;
    nHeightSrc:integer;
    crTransparent:UINT) ;
    Var
    LibHandle:HWND;//动态连接库句柄
    //函数原型定义
    DllName:Procedure(hdcDest:HDC;
    nXOriginDest:integer;
    nYOriginDest:integer;
    nWidthDest:integer;
    hHeightDest:integer;
    hdcSrc:HDC;
    nXOriginSrc:integer;
    nYOriginSrc:integer;
    nWidthSrc:integer;
    nHeightSrc:integer;
    crTransparent:UINT);Stdcall;
    begin
    //以下是静态调用dll中函数的例行公事
    LibHandle:=LoadLibrary('msimg32.dll');
    if LibHandle<32 then
    begin
    MessageBox(Form1.Handle,'Not Found msimg32.dll','Error',0);
    Exit;
    end;
    @DllName:=GetProcAddress(LibHandle,'TransparentBlt');
    if @DllName=nil then
    begin
    MessageBox(Form1.Handle,'Not Found TransparentBlt in msimg32.dll','Error',0);
    FreeLibrary(LibHandle);
    Exit;
    end;
    try
    TransparentBlt(hdcDest,
    nXOriginDest,
    nYOriginDest,
    nWidthDest,
    hHeightDest,
    hdcSrc,
    nXOriginSrc,
    nYOriginSrc,
    nWidthSrc,
    nHeightSrc,
    crTransparent);
    finally
    FreeLibrary(LibHandle);
    end;
    end;
    //爆炸函数
    //在桌面的X,Y坐标处发生爆炸
    procedure TForm1.Explode(X:integer;Y:integer);
    var
    BitMapB : TBitMap;//保存桌面指定区域的内存位图
    w:integer;//一帧动画的宽度
    h:integer;//一帧动画的高度
    i:integer;
    j:integer;
    begin
    BitMapB:=TBitMap.Create;
    try
    //动画位图为4*5=20帧
    w:=Image1.Width div 4;//计算每帧的宽度 h:=image1.Height div 5;//计算每帧的高度
    //初始化内存为图的大小
    BitMapB.Height :=h;
    BitMapB.Width :=w;
    //保存桌面上指定区域的位图
    //注意,由于爆炸是在同一位置完成的,所以只要保存爆炸区域一次就行了。
    savebackground(BitMapB.canvas,w,h,X,Y);
    for i:=0 to 4 do
    begin
    for j:=0 to 3 do
    begin
    //把相应帧画到桌面上
    tranbit(DeskTopDC ,x,y,w,h,
    image1.Canvas.Handle,j*w,i*h,w,h,RGB(208,2,178));
    Sleep(20);//显示速度太快,停顿20毫秒
    //恢复桌面
    bitblt(DeskTopDC,X,Y,w,h,BitMapB.Canvas.handle,0,0,srccopy);
    end;
    end;
    finally
    BitMapB.Free;
    end;
    end;
    //飞行器的飞行函数
    //参数x,y指定飞行器飞行的目的地
    procedure TForm1.shipmove(X:integer;Y:integer);
    var
    w:integer;
    h:integer;
    i:integer;
    j:integer;
    k:integer;
    l:integer;
    BitMapB : TBitMap;
    begin
    Randomize();
    BitMapB:=TBitMap.Create;
    try
    //动画位图为4*16-3帧空帧=61帧
    w:=Image2.Width div 4;
    h:=image2.Height div 16;
    BitMapB.Height :=h;
    BitMapB.Width :=w;
    k:=0;
    l:=0;
    while not stop do
    for i:=0 to 15 do
    for j:=0 to 3 do
    begin
    if (i=15) and (i>0) then break;//如果是空帧就不画了
    //保存桌面上指定区域的位图
    //注意,由于飞行是在不同位置完成的,所以要保存即将被绘图的桌面区域
    savebackground(BitMapB.canvas,w,h,k,l);
    tranbit(DeskTopDC ,k,l,w,h,image2.Canvas.Handle,j*w,i*h,w,h,RGB(208,2,178));
    sleep(10);
    bitblt(DeskTopDC,k,l,w,h,BitMapB.Canvas.handle,0,0,srccopy);
    if(k<x)then k:=k+1;
    if(l<y)then l:=l+1;
    if timer1.Enabled =false then
    if(k>x-10)then//到达目的地就停止飞行,并引爆炸弹
    begin
    stop:=true;
    timer1.Enabled :=true;//炸弹引爆器
    end;
    end;
    finally
    BitMapB.Free;
    end;
    end;
    procedure TForm1.Timer1Timer(Sender: TObject);
    var
    x,y:integer;
    begin
    if(expnum = 0) then
    begin
    Explode(screen.width div 2-20,screen.Height div 2-20);
    sndPlaySound('explosion.wav',SND_NOSTOP);
    expnum:=expnum+1;end
    else if expnum<10 then//爆炸最多10次
    begin
    //产生随机位置
    x:=Random(screen.Width-100);
    y:=Random(Screen.Height-100);
    Explode(x,y);//爆炸
    sndPlaySound('explosion.wav',SND_NOSTOP);//播放爆炸声音
    expnum:=expnum+1;
    end
    else
    begin
    stop:=true;
    timer1.Enabled :=false;
    close();
    end;
    end;
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    DeskTopDC:=GetDC(0);
    chdir(ExtractFilePath(application.ExeName));
    stop:=false;
    expnum:=0;
    //飞行器开始飞行,目的地为屏幕中央
    self.shipmove(screen.width div 2,screen.Height div 2);
    end;
    procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
    stop:=true;
    Timer1.Enabled :=false;
    ReleaseDC(0, DeskTopDC);
    end;
    end.
      

  7.   

    xugang96兄的转载我看过,那个只是在桌面上画图,但是我是想用不规则窗口来做,因为OFFICE助手都是用DIALOG来做的。不过同样谢谢你的帮忙~:)
      

  8.   

    请问agent控件在那找???????