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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Active form getting hidden behind another maximized application

Status
Not open for further replies.

asya1

Programmer
Feb 22, 2002
18
US
I have a dll that is run from Microsoft Visio when a toolbar button is clicked.

When you click the button a (modal) form (call it A) appears. One of the options on this form is to open another form (call it B). On that form you can either exit or run a Fortran app.

In most cases this means that form B closes and the fortran app runs. When the fortran app is finished running from the dos command window you have to hit a key to exit the dos window.

When you have Windows 2000 and Visio 2000 (or Windows XP and Visio 2000 or 2002) form A is the topmost form and the active form (which is what I want).

For some reason when you have Windows 2000 and Visio 2002 form A then gets hidden behind Visio even though it is the active form and is supposed to be modal.

Another catch is the fortran app can also be run from form A. (again always works fine for other combinations) If the users with Windows 2000 and Visio 2002 always run the application from here there doesn't appear to be a focus issue. Once they run it once from form B the focus problem will be there every time until they reboot.

Any idea why this form seems to be losing focus when you have that particular OS/Visio combination? Any idea how I can force it to keep the focus? I don't have any control over the Fortran app so I can't make it just shut the dos window.

Thanks,
Asya
 
Gidday, I see three options, depending on your needs it's up to you which one you use.

1. Use the VB Z-Order functions to control which form is top most.

2. Use the API call that keeps a form On-Top -

========================================================
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const SWP_NOACTIVATE = &H10
Const SWP_SHOWWINDOW = &H40
Private Declare Sub 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)

Private Function ontop()
SetWindowPos Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
End Function

Private Function notOntop()
SetWindowPos Me.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
End Function

========================================================
3. Use the API call 'ShowWindow' which also uses the API call 'SendMessage'.

For example for using any of the API calls and more, check out my web site that shows how to use many of the API calls in differentlanguages.

Cheers.

My API Site: E-mail: akialia@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top