Solved

Display Non-Modal form over Modal form

Posted on 2002-05-30
8
534 Views
Last Modified: 2008-03-17
My MDI application has a 'pop-up' form that displays status - like "Loading..." or "Please Wait...".  This form is set to be 'top-most' by standard API calls, and then hidden when the calling form is done, using unload.  It works great with non-modal forms.

Some, but not all forms that need to call this 'pop-up' form are modal.  I've been having a bear of a time trying to figure out how to best pop-up of modal and non-modal forms.

I'm not stuck with any particular method (I'm flexible), but I'm sure there's GOT to be an API call or something that will get around this (VB ?) limitation.

HELP, please!
0
Comment
Question by:dslocum
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 7044442
Not within an application you cannot. The fact that a form is application modal which is the way that VB sets it means that you cannot popup anything over the top of this except for other modal forms such as a message box.
0
 
LVL 4

Expert Comment

by:RichW
ID: 7044456
Tim, can he create an ActiveX EXE file and use that as the pop-up form and, launch it from either modal or non-modal forms?

I've never had to do that in this situation, but since it's an asynchronous process, maybe that would work???

RichW
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 7044473
That should work, anything which is not in the same process as the original application doesn't have to follow the same rules as ApplicationModal cannot apply to it. Only a SystemModal dialog would cause a problem in this case.
0
 
LVL 4

Expert Comment

by:trkcorp
ID: 7044519
Just a thought, couldn't you create a duplicate MODAL form and use it where MODAL forms are used and use the original where MODELESS forms are used, keep hiding the MODELESS and unload the MODAL?  There is no problem displaying a new MODAL form on top of a MODAL form...  The only thing is the new duplicate MODAL version will have to drive whatever action is supposed to be taking place because it will have focus, or control, and then manage its own unload.  This should work IF it isn't too much trouble to allow the new MODAL version to drive. If it is then Brother Slocum is just between a rock and a hard place.
0
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.

 
LVL 15

Accepted Solution

by:
ameba earned 100 total points
ID: 7044686
To show a form from modal or non-modal form, instead of "Show" use:
     frmPop.ShowStatus "Hello from Modal form"

' frmPop form --------------------------------------------
Option Explicit
'APIs for showing the window without activating it:
Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal _
    nCmdShow As Long) As Long
Private Const SW_SHOWNOACTIVATE = 4

'APIs for making the window a top-most window:
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 HWND_TOPMOST = -1
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOACTIVATE = &H10

Public Sub ShowStatus(someinfo As String)
    Load Me
    Caption = someinfo
   
    ShowWindow hWnd, SW_SHOWNOACTIVATE 'Show the form, but don't activate it.
End Sub

Public Sub HideStatus()
    Unload Me
End Sub

Private Sub Form_Load()
    'Make this a topmost window, as is appropriate for a tooltip
    SetWindowPos hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE _
        Or SWP_NOSIZE Or SWP_NOACTIVATE
End Sub


Ref.: HotTrack sample
http://msdn.microsoft.com/code/default.asp?url=/msdn-files/026/000/115/readme_txt.asp
check frmToolTip.ShowToolTip / frmToolTip.HideToolTip
0
 
LVL 4

Expert Comment

by:trkcorp
ID: 7045140
ameba, I like that!
0
 
LVL 1

Author Comment

by:dslocum
ID: 7045597
Thank you all for your helpful input.

ameba:  In the words of the late game show "Hollywood Squares".... "Circle Gets the Square" !!!

 ameba --- some of the best points I've ever spent!

Thanks
0
 
LVL 15

Expert Comment

by:ameba
ID: 7045644
Thanks, all  :-)
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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…

863 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

21 Experts available now in Live!

Get 1:1 Help Now