Solved

opening a DialogEX from outside the EXE

Posted on 2006-06-18
7
279 Views
Last Modified: 2010-04-05
Hi guys, i'm kinda stuck with a idea.

I have a program that have some Custon Dialogs.

These dialogs have their handles when they are opened. When they get closed the only handle that remains is the main program.

1 - Is there a way to open these Custon Dialogs from outside the program (like if another program force them to show) ?
2 - If yes, what information I need to know to perform this action ?

I can find some Custom Dialogs inside the EXE by using the PE Explorer but i don't know if the information PE Explorer gives to me is enough to perform my action.



ty in adv
0
Comment
Question by:furmiga
  • 3
  • 2
  • 2
7 Comments
 
LVL 17

Accepted Solution

by:
TheRealLoki earned 250 total points
ID: 16931078
to show a dialog in another application, where you have the handle for the dialog, you *can* do
    showwindow(thehandle, sw_show);
I'm not sure how it would handle the close message though (ie. if youthen tried to close the dialog)
Also, if you have not previously shown the dialog, you may not get the controls appearing.
if program A had not created the form, or it uses "ShowModal" or frees it, then you will not have a handle.

If you wrote both programs, then you could have Program B simply ask Program A to show it
ie. Program B does: PostMessage(program1handl, wm_uer+100, 1, 0); // 1 meaning "please show dialog 1 thanks"
(Program A has a routine to catch this message)

If you want Program B to get any properties from the dialog, then you may be better off putting the dialogs in a shared DLL for both programs to access.
0
 
LVL 7

Author Comment

by:furmiga
ID: 16931423
Hey man thx for the reply.

The problem is that after I close the dialog, the hadler created for it disappears and even if I save the handle I cant open it from outside the program.

0
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 16931597
if you just do a show, and a close, you can "reshow" it again
I did a simple demo
where i had 2 forms in the .dpr being created, and form 1 had a button that said "form2.show"
and button2 said caption := inttostr(form2.handle)
the handle was the same.. in fact, if i put text in an edit box on form2, it stays the same also.
I then tried "showwindow(thehandle, sw_show);" from another application, which worked.
so um.. my point is, you can reshow it, but not if you are dynamically creating it
(e.g. with TMyDialog1.create(self) do try showmodal; finally free; end; ) <-- this will lose the handle

Does "Program 2" need to get data from the dialog?
Are you writing Program 1 and Program 2? (ie. how much design scope do you have, so we can get this working)
Does this have to work from a remote machine, or are they both on the same machine?
When Program 2 makes the dialog appear, do you want program 1 to "wait" until the dialog is closed?
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 7

Author Comment

by:furmiga
ID: 16934935
All i want is activate the menu in program 2, using the program 1 for it. The menu in program 2 is a normal menu "file - etc - etc - about" but this menu only exists inside the EXE. It never shows. When you use some resource app you can see the menu inside it but, again, it never really shows. The app don't allocate handlers for the menu either. I'm just wondering if there is a possibility to show this menu (or inject a code to force it to open). There is no possibility to change the code in app2 since all i have is it's executable.
0
 
LVL 34

Assisted Solution

by:Slick812
Slick812 earned 250 total points
ID: 16936152
hello furmiga , , I am not sure about some of the things you talk about, ,
First, in the program that you want to call the "DialogEx" and "Menu", , are these 2 a "Resource" compiled, ,  or are they "run time created" without any resouce reference. . .  as far as I can tell from your comments, They are in the programs resource set.
If these are in the resource, then I beleive you can load the executable as a library as in
hLibrary := LoadLibrary('C:\\Folder1.prog.exe');
 , and then do an API like CreateDialog( ) or  DialogBox( ) and use the hLibray as the resource hInstance.
Seems like there is also a LoadMenu( ) function
0
 
LVL 7

Author Comment

by:furmiga
ID: 16936639
Hi Slick thanks for the reply.

Look what I have:

PE Explorer.exe --> This program alows anyone to view and change some dll / exe resources. It shows Dialogs, menus, strings, icons etc.

Program.exe --> This is the program I want to change.

Now, when I load Program.exe into PE Explorer I can see 3 menus and some dialogs.

These menu / Dialogs never appear in the Program.exe (when it's running) But they are inside the Program.exe somewhere as we can see in the PE Explorer.

My question is: How can I "force" program.exe to open these Dialogs while its running ? I don't know if they will interact with the proram.exe since they are not actualy beeing called by real situations but still, is there any chance to open them ?

0
 
LVL 34

Expert Comment

by:Slick812
ID: 16938899
OH, I see a little more now, ,  
The program called  Program.exe, when it is running, will be doing what it was designed to do (programming of its code), but you want to have another program (your program) run code inside this running Program.exe. . . as I understand your last comment? . . .
I have tried to "Hack" into other running programs to try and get some minor information, but I can tell you, trying to do anything in another program (other memory space) is a really difficult thing. . . and for the most part (my opinion) a NON Productive effort, you may could execute a resource DIALOGEX in another process memory space, however, you will have no easy way (maybe no way) to route that DIALOGEX window to use the "code" (window message function ect) inside that other program,  I think it may be posible to dis-assemble some 32-bit programs and get some hints as to the function memory positions, but I do not think here at EE Delphi, that this is the place for such advanced programming methods.
Have you any experience in getting into the memory space of anothe running program? It is a hassel, much trouble for me.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question