Solved

Keep window topmost in MDI application

Posted on 1999-01-14
5
365 Views
Last Modified: 2012-06-27
I am creating an application that will display one or more MDI Child forms. I want to be able to display a Search form that will:
1. Be a child of the MDI parent form
2. Stay on top of the child forms
3. Not stay on  top of other applications that may be      running.  

I have tried the SetParent API call to achieve item 1, but when the Search form is unloaded, it also hides the toolbar on the MDI Main form.

I have also used SetWindowPos to achieve item 2, but the Search form remains on top of other applications.

I have also tried using Zorder in the activate and deactivate events on all forms, but the blinking that occurs is unacceptable.
0
Comment
Question by:kponder
  • 2
  • 2
5 Comments
 
LVL 7

Expert Comment

by:bouscal
ID: 1456431
Try setting the search form to VBModal.  That should keep it on top of the other forms in your app and still allow other apps to run on top of it.
0
 
LVL 1

Author Comment

by:kponder
ID: 1456432
I have tried this but it is not a child of the MDI form. The Search form can't be allowed to go outside of the MDI form's borders.




0
 
LVL 1

Author Comment

by:kponder
ID: 1456433
Another point:  When the search form is displayed the user will also need to be able to access the MDI child forms.
0
 
LVL 1

Accepted Solution

by:
Johnn earned 200 total points
ID: 1456434
I'm not really sure what seems to be wrong with what your doing.  As long as you reset the parent in the search form's unload event to 0, it shouldn't unload your toolbar.  Also, this window will always stay on top of the child windows without doing anything else.  My tests were in VB5.  I guess your try too hard?

Dim frmChild() As Child
Private Sub MDIForm_Load()
    Dim a%
    ReDim frmChild(1 To 5)
    For a = 1 To 5
        Set frmChild(a) = New Child
        Load frmChild(a)
        frmChild(a).Visible = True
    Next
    Load frmSearch
    SetParent frmSearch.hWnd, Me.hWnd
    frmSearch.Visible = True'set to false at design time to elminated any "flashing"
End Sub
'search form
Private Sub Form_Unload(Cancel As Integer)
    SetParent Me.hWnd, 0
End Sub

Hope that works for you
John
0
 
LVL 1

Expert Comment

by:Johnn
ID: 1456435
The reason my code works above is that we are setting the "find" windows parent to the actual MDI form, not the MDI form's client which is a totally different window.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Access 2003, my txt file export is running backwards 4 46
VBA Shell can't Find Word document 11 74
Passing a Text Box name to a Sub 6 71
VB6 ListBox Question 4 30
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

914 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

15 Experts available now in Live!

Get 1:1 Help Now