如何获得桌面图案后经转换又将其显示在桌面上?(150分)

  • 主题发起人 主题发起人 base7
  • 开始时间 开始时间
B

base7

Unregistered / Unconfirmed
GUEST, unregistred user!
我用了如下方法:
代码:
procedure TForm1.Button1Click(Sender: TObject);
var
  hDesktop,hDesktopDC: THandle;
  FCanvas: TCanvas;
begin
  FCanvas := TCanvas.Create;
  hDeskTop := FindWindow('Progman', nil);
  try
//    hDesktopDC := GetDC(0);
//    FCanvas.Handle := hDesktopDC;
    Bitblt(FCanvas.Handle,50,0,Screen.Width+50,Screen.Height,GetDC(0),0,0,SRCCOPY);
  finally
//    ReleaseDC(hDesktop, hDesktopDC);
    FCanvas.Free;
  end;
end;
这样执行一遍后看起来就象是屏幕往右移了50像素,可是当我把这段程序
放到TTimer的Ontimer事件后由于程序第二遍拷下来的像素已是经过移动
后的图象了,这就不是我的本意了,所以请问,如何保存最初的图象?
[blue]最好有原码[/blue]
我希望的效果是:[blue]桌面一屏一屏地往右移,就象电视里经常出现的那种现象[/blue]
其实不太好意思张口就要原码,但因为任务太急了,还有劳各位帮忙则个:(
[?]
 
>>creation-zy:
感谢你的代码,但是有一个问题,在原来的桌面图象移动时,所空缺出来的部位
用什么来填补呢?怎样把原来右边的图象拼到左边去呢?我觉得这才是问题的关键.
还有,你的
代码:
  FullscreenCanvas.MoveTo(0,Tag);
  FullscreenCanvas.LineTo(300,Tag);
这两句是什么意思?
 
哦,是我糊涂了
其实加一句:
FullscreenCanvas.CopyRect(Rect(0,0,Tag,screen.Height),Fullscreen.Canvas,
Rect(Screen.Width-Tag,0,Screen.Width,Screen.Height));
就可以了
 
var
Fullscreen:Tbitmap;
procedure TForm1.FormCreate(Sender: TObject);
var
FullscreenCanvas:TCanvas;
dc:HDC;
begin
DC:=GetDC(0); //取得屏幕的 DC,参数0指的是屏幕
Fullscreen:=TBitMap.Create;
Fullscreen.Width:=Screen.Width;
Fullscreen.Height:=Screen.Height;
FullscreenCanvas := TCanvas.Create; //创建一个CANVAS对象
FullscreenCanvas.Handle := DC; //将屏幕的DC赋给HANDLE
Fullscreen.Canvas.CopyRect(Rect(0,0,screen.Width,screen.Height),fullscreenCanvas,
Rect(0,0,Screen.Width,Screen.Height)); //把整个屏幕复制到BITMAP中
FullscreenCanvas.Free; //释放CANVAS对象
ReleaseDC (0, DC); //释放DC
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var //变量声明
FullscreenCanvas:TCanvas;
dc:HDC;
begin
DC := GetDC (0);
Tag:=Tag+5;
FullscreenCanvas:=TCanvas.Create;
FullscreenCanvas.Handle := DC;
FullscreenCanvas.CopyRect(Rect(0,0,screen.Width,screen.Height),Fullscreen.Canvas,
Rect(Tag,0,Screen.Width+Tag,Screen.Height));
FullscreenCanvas.Free;
ReleaseDC(0,DC);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
fullscreen.Free;
end;
 
代码:
[blue]接受答案了.[/blue]
 

Similar threads

后退
顶部