Delphi-PRAXiS
Seite 1 von 3  1 23      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Change text of other App Edit Control (https://www.delphipraxis.net/141183-change-text-other-app-edit-control.html)

Razor 4. Okt 2009 10:57


Change text of other App Edit Control
 
Hi!

I want to change/insert text to a Tedit control of other application ( Find File Dialog ).
I got this so far but i guess Setwindowtext won't work


Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
var
  wndMain, wndChild: HWND;
begin
  wndMain := FindWindow('CabinetWClass','Search Results');
  if wndMain <> 0 then
  begin
    wndChild := FindWindowEx(wndMain, 0, 'WorkerW', nil);
    wndChild := FindWindowEx(wndChild, 0, 'ReBarWindow32', nil);
    wndChild := FindWindowEx(wndChild, 0, 'UniversalSearchBand', nil);
    wndChild := FindWindowEx(wndChild, 0, 'Search Box', nil);
 wndChild := FindWindowEx(wndChild, 0, 'SearchEditBoxWrapperClass', nil);
  //  WINDOWS.SetWindowTextA(wndchild,'s');
     //WINDOWS.SetWindowTextW(wndchild,'s');
     sendmessage(wndchild,WM_settext,0,0);
    if wndChild <> 0 then
    begin
      ShowMessage('Window Handle: ' + IntToStr(wndChild));

    end;
  end;
end;

toms 4. Okt 2009 11:06

Re: Change text of other App Edit Control
 
Hi,

To set the text of a control in another process, send the WM_SETTEXT message directly instead of calling SetWindowText.
MSDN-Library durchsuchenSetWindowText

Razor 4. Okt 2009 11:12

Re: Change text of other App Edit Control
 
Well clearly its not working toms...I want to specify what i want to search from delphi app to the find file dialog directory is not enough.Thats why this way..

Delphi-Quellcode:
uses ddeman;

procedure TForm1.Button1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);

  var
  wndMain, wndChild: HWND;
    msg : String;

begin
  wndMain := FindWindow('CabinetWClass','Search Results');
  if wndMain <> 0 then
  begin
    wndChild := FindWindowEx(wndMain, 0, 'WorkerW', nil);
    wndChild := FindWindowEx(wndChild, 0, 'ReBarWindow32', nil);
    wndChild := FindWindowEx(wndChild, 0, 'UniversalSearchBand', nil);
    wndChild := FindWindowEx(wndChild, 0, 'Search Box', nil);
    wndChild := FindWindowEx(wndChild, 0, 'SearchEditBoxWrapperClass', nil);

msg := 'search for this';



    if wndChild <> 0 then
    begin
      ShowMessage('Window Handle: ' + IntToStr(wndChild));
       SendMessage(wndchild, WM_SETTEXT, 0, LongInt(PChar(msg)));

  end;

  end;
end;



procedure TForm1.FormCreate(Sender: TObject);
begin
  with TDDEClientConv.Create(Self) do begin
   ConnectMode := ddeManual;
   ServiceApplication := 'explorer.exe';
   SetLink( 'Folders', 'AppProperties') ;
   OpenLink;
   ExecuteMacro
       ('[FindFolder(, C:\DelphiTips)]', False) ;
   CloseLink;
   Free;
  end;


end;

toms 4. Okt 2009 12:00

Re: Change text of other App Edit Control
 
What's your OS? Is the message ShowMessage(..) shown?

Also check out http://www.delphi-forum.de/viewtopic.php?p=217770

Razor 4. Okt 2009 12:01

Re: Change text of other App Edit Control
 
WIN 7 rtm 7600

toms 4. Okt 2009 12:06

Re: Change text of other App Edit Control
 
Zitat:

Zitat von Razor
WIN 7 rtm 7600

I asked 2 questions :wink:

Razor 4. Okt 2009 12:06

Re: Change text of other App Edit Control
 
The snippet dosent seem to work with DElphi 2010.. :)

[DCC Error] Unit1.pas(90): E2010 Incompatible types: 'Char' and 'AnsiChar'
Delphi-Quellcode:
 ExecuteMacro(PChar('[FindFolder(, '+ sVerz +')]'), False);
[DCC Warning] Unit1.pas(89): W1002 Symbol 'IncludeTrailingBackslash' is specific to a platform
Delphi-Quellcode:
sVerz := IncludeTrailingBackslash(Verzeichnis);

sx2008 4. Okt 2009 12:16

Re: Change text of other App Edit Control
 
Zitat:

Zitat von Razor
WIN 7 rtm 7600

http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx
Zitat:

Zitat von MSDN
Microsoft Windows Vista and later. Message sending is subject to User Interface Privilege Isolation (UIPI). The thread of a process can send messages only to message queues of threads in processes of lesser or equal integrity level.


Razor 4. Okt 2009 12:17

Re: Change text of other App Edit Control
 
Great . now i have to worry about security levels just great.

Razor 4. Okt 2009 13:26

Re: Change text of other App Edit Control
 
Nobody...?Dont know or is it that almost everybody is lazy to hit the post button.


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:36 Uhr.
Seite 1 von 3  1 23      

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