AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi Kontextmenü einer anderen Anwendung aufrufen
Thema durchsuchen
Ansicht
Themen-Optionen

Kontextmenü einer anderen Anwendung aufrufen

Ein Thema von nezumi · begonnen am 28. Okt 2006 · letzter Beitrag vom 31. Okt 2006
Antwort Antwort
EWeiss
(Gast)

n/a Beiträge
 
#1

Re: Kontextmenü einer anderen Anwendung aufrufen

  Alt 29. Okt 2006, 13:29
Hier mal ein Beispiel wie man Text aus einer anderen Anwendung ohne
Kontexmenü bekommen kann.

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Edit1: TEdit;
    Label7: TLabel;
    Edit2: TEdit;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function LeftStr(Const Str: String; Size: Word): String;
begin
  Result := Copy(Str, 1, Size)
end;

function InStr(Start: integer; Source: string; SourceToFind: string): integer;
begin
  Result := pos(SourceToFind, copy(Source, Start, Length(Source) - (Start - 1)));
end;

procedure TForm1.Timer1Timer(Sender: TObject);
const
  MAX_BUFFER = 32767;

Var
 Res : Integer;
 Handle : HWND;
 Parent : HWND;
 Pt : TPOINT;
 Buffer : String;
 Klasse : String;

begin

    if GetCursorPos(Pt) then
    begin
      Handle := WindowFromPoint(Pt);
      Parent := GetParent(Handle);
                 SetLength(Klasse, 128);
      Res := GetClassName(Handle, PChar(Klasse), 128);
      Klasse := LeftStr(Klasse, Res);

      Label2.Caption := IntToStr(Handle);
      Label4.Caption := IntToStr(Parent);
      Label6.Caption := Klasse;

      If (InStr(1, Klasse, 'Edit') <> 0) Or (InStr(1, Klasse, 'text') <> 0) Then
        begin
          If RadioButton1.Checked = True Then
            begin
                          SetLength(Buffer, MAX_BUFFER);
            Res := SendMessage(Handle, WM_GETTEXT, Length(Buffer), Integer(PChar(Buffer)));
            Edit1.Text := LeftStr(Buffer, Res);
            end Else
            SendMessage(Handle, WM_SETTEXT, 0, Integer(Edit1.Text));
        end;
    end;
end;

end.
Gruß
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:53 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz