以下是引用片段:
var
hDesktop : THandle ;
s : string ;
function EnumChidProc(h:THandle;lp:DWORD):bool ; stdcall ;
var
cBuf : array[0..255] of char ;
begin
GetClassName(h,cBuf,255) ;
if StrComp(cBuf,'SysListView32')=0 then
begin
hDesktop:=h ;
Result:=false ;
exit ;
end ;
Result:=true ;
end ;
procedure TForm1.Button1Click(Sender: TObject);
var
h : THandle ;
dc : HDC ;
DesktopCanvas:TCanvas;
x,y ,z:integer;
begin
x:=strtoint(edit2.text);
y:=strtoint(edit3.text);
z:=trackbar1.Position;
h:=FindWindow('Progman',nil) ;
EnumChildWindows(h,@EnumChidProc,0) ;
Caption:='句柄:'+inttohex(hDesktop,8) ;
dc:=GetDC(hDesktop) ;
s:=edit1.Text ;
DesktopCanvas := TCanvas.Create;
DesktopCanvas.Handle := DC;
DesktopCanvas.Font.Color := clRed;
DesktopCanvas.Font.Name := 'Arial Black';
DesktopCanvas.Font.Size := z;
DesktopCanvas.Brush.Style := bsClear;
DesktopCanvas.Textout(x, y, s);
DesktopCanvas.Free;
// Windows.TextOut(dc,x,y,pchar(s),length(s)) ; ///
// ReleaseDC(hDesktop,dc) ; ///
end;
关键字词: