(Gast)
n/a Beiträge
|
AW: In Canvas eines externen Fensters zeichnen
20. Mai 2015, 16:28
Code funktioniert, dein Problem muss also irgendwo anders liegen.
Delphi-Quellcode:
uses
ShellApi;
procedure TForm1.Button1Click(Sender: TObject);
var
destWnd, destHdc: hdc;
destCanvas: TCanvas;
begin
ShellExecute(0, ' open', ' notepad.exe', nil, nil, SW_NORMAL);
Edit1.Text := ' Unbenannt - Editor';
Sleep(500);
destWnd:= FindWindow( nil, pchar(Edit1.Text));
if destWnd = 0 then
begin
ShowMessage(' Did not find window handle of ' + Edit1.Text);
exit;
end;
destHdc:= GetDc(destWnd);
if destHdc = 0 then
begin
ShowMessage(' Did not get DC of window');
exit;
end;
destCanvas:= TCanvas.Create;
destCanvas.Handle:= destHdc;
destCanvas.Brush.Color := clRed;
destCanvas.Rectangle(10, 10, 100, 100);
destCanvas.Refresh;
destCanvas.Free;
ReleaseDc(destWnd, destHdc);
end;
|
|
Zitat
|