Solved

ActiveX exe vbModal form

Posted on 2002-04-17
17
454 Views
Last Modified: 2007-12-19
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.
0
Comment
Question by:afpcos
  • 6
  • 6
  • 3
  • +2
17 Comments
 

Expert Comment

by:RAJz
Comment Utility
I didn't uynderstand ur ques.

did u give the reference of these EXE in ur Project?
0
 
LVL 4

Expert Comment

by:RichW
Comment Utility
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
 
LVL 5

Expert Comment

by:rkot2000
Comment Utility

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
 
LVL 5

Expert Comment

by:rkot2000
Comment Utility
or you can use a timer in your second app to active form2 every xx seconds.
0
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 300 total points
Comment Utility
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
 
LVL 2

Author Comment

by:afpcos
Comment Utility
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
 
LVL 2

Author Comment

by:afpcos
Comment Utility
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
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
are you sure that you are passing a reference to a visible form? Do you have something when you do

msgbox pform.caption
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 2

Author Comment

by:afpcos
Comment Utility
Yes the form is visible.  The msgbox displays the correct caption of the form in the first activex exe.
0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
do you have a form in a standard EXE somewhere ?
0
 
LVL 5

Expert Comment

by:rkot2000
Comment Utility
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
 
LVL 2

Author Comment

by:afpcos
Comment Utility
emoreau,

I do not understand your questions.  The two projects in question are ActiveX exe programs.
0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
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
 
LVL 2

Author Comment

by:afpcos
Comment Utility
emoreau,

I do not want them to be standard exes.
0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
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
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
any progress?
0
 
LVL 2

Author Comment

by:afpcos
Comment Utility
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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

771 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now