Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to contain a ActiveX exe server within my program 2

Status
Not open for further replies.

vb5prgrmr

Programmer
Jul 5, 2002
3,622
US
Okay, my container application is or has a standard interface. i.e. logo, menu system, and toolbar. When a new exe is detected in the same directory, I shell it with a /r so that it can register what it needs within the settings database. (not just any exe...) These settings tell the container app what menus to display and what buttons to display when it is shelled. Now, when this dropin exe is shelled for operation, it is passed the hwnd of a MDI child form that is maximized in the MDIParent form that is the container and it is passed the hwnd of a textbox that is not visible (the form is a dummy blank form...). Now, this dropin exe uses the SetParent API to affix itself to the child form and then uses sendmessage to the hidden text box to pass its hidden text boxes hwnd so further communication can commence between the two as needed. All works well but this is such a cludge. I know there has to be a better way, but as I said it works well and allows me to add functionality that I had never thought of when the container was created.

Now, over the past few days I have been rereading all my books on activex dll's, controls, and exe's and I quote from the book titled "Advanced Microsoft Visual Basic 6.0 Second Edition" Published by Microsoft Press and I guess authored by "The Mandelbrot Set" with a forward by Sean Alexander.

Okay, the quote is... "Controls (UserControls, that is) can be brought entirely inside an application or compiled to OCXs. (Servers have the potential to be brought inside an application, also)." ...,which can be found on pg 483, chapter 11 (Mixing Languages with visual studio).

Okay,... So a server is an ActiveX exe, as I understand it from reading seven chapters from three different books and countless web examples, but I cannot find an example or set of instructions that will allow me to contain an activex exe within my container program as I presently do.

After reviewing the licensing scheme at MS about UC's I cannot use a UC in the way I want.

So, the question is. How to make an activex exe's form become a child or be contained by another exe/activex exe as the objective is... To allow a customer to download the container program and the options that they want. Then if they want other options, all they would need to do is download the new exe into the same directory and it would be picked up by the container program through its existing methods (see above if you have forgotten already )

Once again, this is something like the MMC (now renamed to just Computer Management) but please do not get confused with thinking I want to know how to create a program for the MMC as I have that documentation around here somewhere already.

So, any hints or clues???
 
>I've not actually tried it in anger...[bugeyed][banghead][curse][hairpull3]

Reading that left me [shocked] (shocked) and wondering if I should [flush] (flush) this [idea] (idea) but before I am done [banghead] (banging my head) I would like to [hammer] (hammer out, nail down, and or) [auto] (chase down) every possible lead.

So with that said,... What you are saying is you tried the CBT hook and it did not work earlier today, but what about the dll I pointed out? Just first glance opinion as I am being very cautious at this point and very slowly putting these things together. Who knows, maybe I will know before you even read this... :) and do you think I have the process correct?

 
I mean that I tried the CBT idea, intercepted the window creation, but was unable to successfully turn it into a proper MDI child (any more so than SetParent does)
 
Well strongm, I not only thank you for your effort with my words, but with a star. I also realize that I have forgotten more than I ever knew about hooking since I have had no need to do so the past couple of years...

With that said, I am presently trying to adapt this code to see if I can even intercept the WM_CREATE message with the following process...

initialize collection
shell notepad with vbhide
openprocess to retrieve handle
setwindowlong with addressof windproc
show program

So then, if I am able to intercept the WM_CREATE message I will then try to do the alteration. Although, I may have to use that code to remove the title bar from notepad but as of this moment, I am not sure.

After this test, I will try the dll I mentioned above if I am unable to get the desired results...

Thanks once again dilettante and strongm. If I happen to stumble upon a solution, I will be sure to post it.

Mike
 
strongm and dilettante,

Don't think that I have not forgot about this... Been fighting a head cold for the last week so it does not go down into my chest, partially lost partially won, it did not stay long, but still feel like walking against the current if you know what I mean.

But I finally have an update, sort of...

The code from vbhelper did not work...(Process I used as follows...)

[tt]
PID = Shell("Notepad.exe", vbHide)
LoadMessageName 'load vbhelper collection of messages
OriginalProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, 0 PID)
OriginalWindowProcedure = SetWindowLong(OriginalProcessHandle, GWL_WNDPROC, AddressOf WindProc)
WindowHandle = FindWindow("notepad", vbNullString)
RetVal = ShowWindow(WindowHandle, SW_SHOW)
[/tt]

(NOTE:Removed all the error checking, comments, and other failed experiments)

But it did when I subclassed my own process, so I am on to the vbforums code and dll that says you can subclass another process. I probably will combine the two to see if I do intercept the WM_CREATE and hopefully will have another update later today.

Have a good weekend


 
I still think there has to be a "cleaner" (less fiddling with Windows' plumbing) way... but I haven't come across one.
 
OMG! strongm! I have a question...

In your attempt, I take it you tried to subclass another programs window to intercept the WM_CREATE message and failed just as I did... But what if the child, or intended child intercepted its own WM_CREATE message and did its own modifying to itself...???

Parent Shells with vbHide and passes hwnd of dummy (blank) MDI Child form as arguement.

Child, or intended child, subclasses itself (because it recognized the /hwnd arguement) and modifies its own WM_CREATE message after gets all of the relavent information it needs from the hwnd passed to it...???

What do you think???

On other note still working on dll example as that honey dew list can grow when under the weather and it takes time to get caught up!!! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top