Link to home
Start Free TrialLog in
Avatar of furmiga
furmiga

asked on

showing a dialog by using FindWindowEX

First of all... srry about the points. This is all I have :(

2 apps

the first app have:

Form Title: "my 1st app"
dialog name: "my dialog 1" (dialogEx)

the second app have a button "call the dialog from app 1"

now...

In app 2 I want to find the app1 handle and its dialog handle and then open the dialog from the app2.

is that possible ?

wnd := FindWindow(nil, 'my 1st app');
wnd := FindWindowEx(wnd, 0, '????????',nil); < -- I really don't know how it works
...


ty in advance

Avatar of LMuadDIb
LMuadDIb
Flag of United States of America image

procedure TForm1.Button1Click(Sender: TObject);
var
  h,openDialog:hwnd;
begin
  h := FindWindow(nil,'my 1st app');
  if h <> 0 then begin// if we found notepad
    openDialog := FindWindowEx(h, 0, 'TButton', nil);
    sendmessage(openDialog,WM_LButtonDown,0,0);
    sendmessage(openDialog,WM_LButtonUp,0,0);
  end else
    ShowMessage('not found.');
end;

If you had a button on your first app that would open a dialog than you can simulate the buttonclick, shown above.
I dont know if its possible to open a dialog window without using a menuitem/button/action or similiar control.

Syntax:}

  FindWindowEx(Parent: HWND;  {a handle to a parent window}
               Child: HWND;  {a handle to a child window}
               ClassName: PChar;  {a pointer to a null-terminated class name string}
               WindowName: PChar  {a pointer to a null-terminated window name string}
               ): HWND;  {returns a handle to a window}
ASKER CERTIFIED SOLUTION
Avatar of LMuadDIb
LMuadDIb
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of furmiga
furmiga

ASKER

Thats why i gave the name of the dialog "my dialog 1" wich is a EX dialog

I really don't know if I have to use the FindWindowEX since the Dialog is hidden and there is nothing phisical to open it ( I mean, if i start the program with a param -menu then the MainMenu is visible wich allow me to open the "my dialog 1" ).


Now, if I start the program without the param, is there any chance to open the main menu or just call the dialog ?.


They exist so I was wondering if i can force them to show