ActiveX exe vbModal form

I have two ActiveX.exe programs (ActiveX1 and ActiveX2).  ActiveX1 loads a form.  This form has a button that calls a method in ActiveX2 to show a form in that exe.  The problem I have is when ActiveX1 is minimized, and then maximized, sometimes the form in ActiveX2 is behind ActiveX1.

How can I stop this from happening?

Thank you.
LVL 2
afpcosAsked:
Who is Participating?
 
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
use the owner parameter of the Show method (the second parameter). pass the instance of your current form to the second activex and use it as the owner.

ActiveX1

call AX2Instance.ShowForm(me)



ActiveX2

Public Sub ShowForm(byref pForm as Object)
   form1.show ,pForm
End Sub
0
 
RAJzCommented:
I didn't uynderstand ur ques.

did u give the reference of these EXE in ur Project?
0
 
RichWCommented:
I know what you're saying, but I think it's working the way it should.

You want the second ActiveX EXE to act like it's a child of the first one, but when you minimize/maximize, the first form (parent) is in front of the child?

This is like having a VB form open a Word Doc object.  If you minimize the VB form, then maximize, the VB form would be on top.  This is Windows!

Even if you launched the ActiveX EXE from a standard VB project this would be the case.

You can use an API to keep the second form always on top.

Or you could not allow for 1 to be minimized.

I'm not sure what you're trying to do.  Could you explain a little better?

Thanks

0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
rkot2000Commented:

you can send an AppActivate statement from your first exe
like
first application
Form_active event
AppActive "Form's title in the second exe"


or you can use SetWindowPos API to keep your second window on top.






0
 
rkot2000Commented:
or you can use a timer in your second app to active form2 every xx seconds.
0
 
afpcosAuthor Commented:
The activate event does not occur when the window is minimized or maximized.

Even if you do not allow a form to be minimized, the user can click on "Show Desktop" button in windows and the window will minimize.

I need the form in the second ActiveX exe to show like a pop up for to the first ActiveX exe.

I can not set the for to always stay on top because it stays on top of other forms in the application.
0
 
afpcosAuthor Commented:
emoreau,

When I try to do this, i get the following error.
Run-time error '371': The specified object can't be used as an owner form for Show()
0
 
Éric MoreauSenior .Net ConsultantCommented:
are you sure that you are passing a reference to a visible form? Do you have something when you do

msgbox pform.caption
0
 
afpcosAuthor Commented:
Yes the form is visible.  The msgbox displays the correct caption of the form in the first activex exe.
0
 
Éric MoreauSenior .Net ConsultantCommented:
do you have a form in a standard EXE somewhere ?
0
 
rkot2000Commented:
You may need to subclass your first form to send messages to the second form.

Or in the second form you can use timer to :
Locate first form
Get  state
Based on results : Move/Hide/Show the second form
0
 
afpcosAuthor Commented:
emoreau,

I do not understand your questions.  The two projects in question are ActiveX exe programs.
0
 
Éric MoreauSenior .Net ConsultantCommented:
can't you transform one as a STANDARD EXE?

when you start a new vb project, you have many templates. one of them is the standard exe and should be use for regular application.
0
 
afpcosAuthor Commented:
emoreau,

I do not want them to be standard exes.
0
 
Éric MoreauSenior .Net ConsultantCommented:
it seems that the form in your ActiveX 1 does not have a regular handle so it can't be used as an owner.
0
 
Éric MoreauSenior .Net ConsultantCommented:
any progress?
0
 
afpcosAuthor Commented:
Each parent form has to have the min button enabled for the min and max events to fire when you click on the Windows "Show Desktop" button.  I had to set up a series of events between the two forms so they let eachother know when it was resizing to tell the other form to resize.

I also had to disable all controls on the parent form when it launched the child form so that if the user clicked back on the parent form while the child form was up, the Form_OnFocus event would fire so I could send focus back to the child window.

It is very ugly, but it works.  I could not figure anything else out.

Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.