掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
キャレットを持っているコンポーネントのハンドルを取得するには? (ID:16543)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
下記のコードではメモ帳に対してはうまくできませんでした・・・ よくわかりません・・・ function GetFocusInAnotherProcess: HWND; var hWin: HWND; TID, PID, MyID: Integer; begin MyID := GetCurrentThreadID; hWin := GetForegroundWindow; TID := GetWindowThreadProcessID(hWin, @PID); if AttachThreadInput(TID, MyID, True) then begin SetForegroundWindow(hWin); Result := GetFocus; AttachThreadInput(TID, MyID, False); end else begin Result := 0; end; end; procedure TForm1.Timer1Timer(Sender: TObject); var wh, wd, ThisWH: HWND; wc: TWinControl; buf: array[0..1000] of char; selfID, otherID, prcID: DWORD; begin buf := 'ABCDEFG'; Timer1.Enabled := false; wd := GetFocusInAnotherProcess; selfID := GetCurrentThreadID; wh := GetForegroundWindow; otherID := GetWindowThreadProcessID(wh, @prcID); if AttachThreadInput(otherID, selfID, True) then begin SetForegroundWindow(wh); ThisWH := GetFocus; AttachThreadInput(otherID, selfID, False); SendMessage(wd, WM_GETTEXT, 1000, Integer(@buf[0])); Edit1.Text := StringReplace(string(buf), #0, '', [rfReplaceAll]); end else begin Edit1.Text := ''; end; end;
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.