Solved

Display Non-Modal form over Modal form

Posted on 2002-05-30
8
532 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 15

Accepted Solution

by:
ameba earned 100 total points
Comment Utility
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
Comment Utility
ameba, I like that!
0
 
LVL 1

Author Comment

by:dslocum
Comment Utility
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
Comment Utility
Thanks, all  :-)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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.
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…
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…
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…

744 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

18 Experts available now in Live!

Get 1:1 Help Now