Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

guaranteeing a form appears at the front of the zorder

here's the scenario:

1. i have  a standard exe that contains the main UI
2. i have an ActiveX exe that the standard exe calls sometimes to provide certain functionality
3. the ActiveX exe has a form in it which is displayed when the ActiveX exe is called.  this form is used to give the user status information

the problem:

- when my standard exe calls teh ActiveX exe - the form that the ActiveX exe pops up is ALWAYS underneath the standard exe.  I obviously need the form that the ActiveX exe displays.  how do i do that?

in the ActiveX EXE - when i display the form i use this code:

'putting up form that gives user progress and offers cancel button
            frmCancel.Show
            frmCancel.ZOrder 0
            intNumberOfFilesProcessed = 0
            frmCancel.lblStatus = "Recording information about the files you have selected"        
0
kenshaw
Asked:
kenshaw
1 Solution
 
RimvisCommented:
Your code should work (at least it does for me). Could you show us some more of it? Including call from standard exe
0
 
SmallintCommented:
Try to add this on AX exe form.

Cheers


Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const HWND_TOP = 0
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function SetActiveWindow Lib "user32" (ByVal hwnd As Long) As Long

Private Sub Form_Load()
    SetWindowPos hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
    SetForegroundWindow hwnd
    SetActiveWindow hwnd
    Me.SetFocus
End Sub
0
 
Erick37Commented:
Why not just provide a method in the ActiveX EXE to retrieve the information?  Then you can use that information to display your own form.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
kenshawAuthor Commented:
hmm... your code gives me an error on the Me.SetFocus call

says its an invlid call
0
 
kenshawAuthor Commented:
the code in teh ActiveX EXE is called by 5 or 6 different parts of our main app.  we want all the code related to the tasks - including the GUI code in the ActiveX EXE.

0
 
Erick37Commented:
There is only one way that I know of for a window to force its way to the front of other windows:

"Force another window to the foreground, when SetForegroundWindow doesn't work, by attaching to its thread."
http://www.classicvb.net/samples/project.asp?id=forcefore
0
 
amebaCommented:
It also depends from where do you call ActiveX Exe;  e.g. if it is from MouseUp event in your main exe, it is possible that ActiveX form shows, but after that focus is returned to the original form/control in main app.  To check, set a breakpoint or msgbox immediately after  frmCancel.Show  line.
0
 
RubynCommented:
In ActiveX application you must be invoking the form from some function use vbModal like this

Sub SomeFunction()
    Call Form1.Show(vbModal)
End Sub

In your application you can call it.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now