rogerrr
asked on
Vista DWM thumbnail with Delphi 7 - how?
Hello!
Some days ago i did find an article "Programming the Windows Vista DWM in C#" You can read it under this link: http://bartdesmet.net/blogs/bart/archive/2006/10/05/4495.aspx
I decided that i'd like to realize this method with Delphi Win32 (Delphi 7). Delphi 7 is installed under my Vista Ultimate.
I linked a dwm.pas into my project (you can download it from this site:
http://www.box.net/index.php?rm=box_v2_download_shared_file&file_id=f_83304197
the zip file is containing the dwm unit...)
but i don't how can i apply it in my program...? I tried to "copy" the original source but...
Is there any way to show a live thumbnail in my form? What is the destination handle? An image canvas or bitmap handle? I don't know....
Any help will be appreciated! Thanks in advance!
My attampt is the following:
Some days ago i did find an article "Programming the Windows Vista DWM in C#" You can read it under this link: http://bartdesmet.net/blogs/bart/archive/2006/10/05/4495.aspx
I decided that i'd like to realize this method with Delphi Win32 (Delphi 7). Delphi 7 is installed under my Vista Ultimate.
I linked a dwm.pas into my project (you can download it from this site:
http://www.box.net/index.php?rm=box_v2_download_shared_file&file_id=f_83304197
the zip file is containing the dwm unit...)
but i don't how can i apply it in my program...? I tried to "copy" the original source but...
Is there any way to show a live thumbnail in my form? What is the destination handle? An image canvas or bitmap handle? I don't know....
Any help will be appreciated! Thanks in advance!
My attampt is the following:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, dwm, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
thumb: ^integer;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function UpdateThumb():boolean;
var
size: PSize;
props: PDWM_THUMBNAIL_PROPERTIES;
begin
result:=true;
if form1.thumb <> nil then
begin
DwmQueryThumbnailSourceSize(form1.thumb^, size);
props.dwFlags:=DWM_TNP_VISIBLE and DWM_TNP_RECTDESTINATION and DWM_TNP_OPACITY;
props.fVisible:=true;
props.opacity:=50;
props.fSourceClientAreaOnly:=false;
props.rcDestination:=Rect(form1.Image1.left,form1.image1.Top,form1.Image1.Left+form1.Image1.Width,form1.Image1.Top+form1.Image1.Height);
if (size.cx<form1.Image1.Width) then props.rcDestination.Right:=props.rcDestination.Left+size.cx;
if (size.cy<form1.Image1.Height) then props.rcDestination.Top:=props.rcDestination.Left+size.cy;
DwmUpdateThumbnailProperties(form1.thumb^,Pointer(props));
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
h: Hwnd;
r: TRect;
wwidth, wheight: integer;
i: integer;
begin
h:=FindWindow(nil,'Untitled - Notepad');
if h<>0 then
begin
GetWindowRect(h,r);
wwidth:=r.Right-r.Left;
wheight:=r.Bottom-r.Top;
if thumb <> nil then DwmUnregisterThumbnail(thumb^);
i:=DwmRegisterThumbnail(image1.canvas.Handle,h,Ptr(thumb^));
if i=0 then UpdateThumb();
end;
end;
end.
wouldn't it be more like this for the destination ?
UpdateThumb(thumb, Rect(0,0,Image1.Width, Image1.Height));
UpdateThumb(thumb, Rect(0,0,Image1.Width, Image1.Height));
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
i would provide some parameters to your updatethumb (make it independant of form1)
if that don't work,
first assign a bitmap in the picture property, best is a ordinary white bitmap
or use a TPanel instead of a TImage
I don't have Vista, so can't test, just trying to help
Open in new window