martin2k

ForumsVB6GamesSoftwareDirectoryHTMLArticlesBlogContact

How do I show a modal form in the taskbar?


 

Home

Read and add posts to the Visual Basic 6.0 Forums

Download some of my programs and OCXs

Read the Tips here

The old style forum is still available here

Contact


 

Question

From: George M Patterson
Date: Monday, July 10, 2000 12:04 PM
Subject: VB question
Question: Hello - you helped me out before with a vb question about network neighbourhoods.

Could you possibly help me again?

Is it possible for a modal form to have a caption visible in the task bar?

Cheers.

george

I have tried this before and the only way that I can think of is to have a normal form and then just enable and disable the main form manually as modal forms cannot go into the taskbar.


blog comments powered by Disqus

Archived Comments

From: snowberry
Date: Thursday, October 9, 2008 at 07:53:21
Comments: I have found a combination of the methods given that will give a result that works, and can be done so that it does not flicker on the screen.

Before the form is shown, set something like the following so that the form is not visible to the user:

    Me.Height = 0
    Me.Width = 0
    Me.Left = -10000
    Me.Top = -10000
    Me.Show vbModal

The form will need a timer, set with an Interval of 1, and in it you will need:

    Timer1.Enabled = False
    ' For some reason you do have to do this...
    Me.Caption = Me.Caption
    Me.WindowState = vbMinimized
    Me.WindowState = vbNormal
    Me.Height = Whatever you want
    Me.Width = Whatever you want
    Me.Left = Whatever you want
    Me.Top = Whatever you want
    Me.SetFocus


Hope this helps someone.

 
From: levs
Date: Monday, November 26, 2007 at 16:22:45
Comments: "The second form would have a 0 width and 0 height so it would not be visible and it would unload itself right after it loaded."

It does not work.

 
From: Matt Ryall
Date: Wednesday, February 2, 2005 at 01:26:49
Comments: The example given by ich breaks the "modal-ness" of the form. Setting Form.Visible to false allows the execution path of the caller to continue (in Sub Main or whatever).
 
From: ich
Date: Tuesday, November 4, 2003 at 16:11:19
Comments:
Private Sub Form_Activate()
 Me.Visible = False
 Me.Caption = Me.Caption
 Me.Visible = True
End Sub
 
From: David Schofield
Date: Wednesday, September 3, 2003 at 22:36:45
Comments: You can accomplish the same thing much easier by minimizing and restoring the form in the form_activate proc. DIM a variable to hold the current state before minimizing and restore it to the previous state for user friendliness.
DS
 
From: Scott
Date: Friday, August 15, 2003 at 17:08:47
Comments: This technique works great!  Thanks!
 
From: Elliott
Date: Tuesday, June 3, 2003 at 18:17:53
Comments: I just figured this one out...

The only way to do this is to show something modally over top of your modal form and change the caption just be for you do it. This worked in VB6 for me.
Example:

-----modMain.bas---------------------

sub main()
    ...
    frmMain.Show vbModal
    ...
End Sub

--------frmMain.frm------------------

Private Sub Command1_Click()
     frmMain.Caption = frmMain.Caption
     MsgBox "Your Form will now have a TaskBar Button!"
End Sub

-------End Form----------

There is a clever way of doing this automatically by using a second form instead of a message box and placing the code in the frmMain Activate event.  The second form would have a 0 width and 0 height so it would not be visible and it would unload itself right after it loaded.


Martin Allen 1999 - 2011.  Last updated Tuesday 09 August 2011 08:11:16 PM +0100.