Reputation: 1317
Running frameworks 4.0 (VB.net)
The property ShowInTaskbar is set to True.
Here the code to run the main window.
Dim frm As New frmMain
frm.ShowInTaskbar = True
Application.Run(frm)
Here all the code from the frmMain
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Application.DoEvents()
Me.Focus()
Me.Activate()
PeutExecuterSynchronisationAutomatique = True
'placer le bouton d'aide en ligne
btnAideToolTip.Location = New Point((btnPreference.Location.X - btnAideToolTip.Width) - 5, btnAideToolTip.Location.Y)
btnAideToolTip.Visible = True
Label5.Text = "version(x)"
Catch ex As Exception
HandleException(ex)
End Try
End Sub
Here all the code from the inherits form
Public Overridable Sub FormBase_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
If Not designmode AndAlso Not Application.ExecutablePath.ToLower().IndexOf("devenv.exe") > -1 Then
If EasyDealINI.FichierINIEasyDealTailleDefaut = False Then
Me.Height = CInt(Me.Height * Ratio)
Me.Width = CInt(Me.Width * Ratio)
Me.Font = New Font(Me.Font.FontFamily, (Me.Font.Size * Ratio) - (DIMINUEUR_RATIO_POLICE * Ratio), Me.Font.Style)
Me.CenterToScreen()
UC_MenuBottom.AjusterControles()
UC_MenuBottom.AppliquerTypeBouton()
End If
End If
If Not DesignMode Then
'Sert à ce qu'EasyDeal en plein écran n'ait pas l'air d'un Transformer qui se déplie.
'Me.Visible = False --> Suspend le layout dans FormBaseDetailCalcul (voir AjusterControls) - Philippe 2008/06/04
If Not FormBase.DossierImagesPath Is Nothing Then
Dim strNomFichier As String = FormBase.DossierImagesPath & "Icone.ico" 'Le signe chinois
'Dim strNomFichier As String = FormBase.DossierImagesPath & "Logo.ico" 'La terre
Dim Fichier As New FileInfo(strNomFichier)
If Fichier.Exists Then
Me.Icon = New Icon(strNomFichier)
End If
End If
End If
Me.MaximizeBox = False
Me.MinimizeBox = True
DesactiverCloseBouton()
'Pour permettre que sur le ENTER la navigation se fasse comme en Access
'(Agir comme un (TAB)... Voir évenement FormBase_KeyUp
Me.KeyPreview = True
Me.ShowInTaskbar = True
Me.StartPosition = FormStartPosition.CenterScreen
Me.AppliquerCouleurs(Me)
'on met Easydeal comme texte de fenêtre
Me.Text = DEFAULT_WINDOW_TEXT
Me.Focus()
Me.Activate()
Catch ex As Exception
HandleException(ex)
End Try
End Sub
but this doesn't help, even if i click on the form the app doesn't appear on the task bar.
However, what is really weird is if i put a breakpoint or if i first click on the taskbar and then click again on the form the program will appear on the taskbar.
An alt-tab make the program appear in the task bar too.
Thanks!
Upvotes: 0
Views: 3308
Reputation: 1317
Toggle ShowInTaskbar in my form load event with these two lines:
It works only if the window is not a modal one. Which is kind of good for now.
This.ShowInTaskbar = False;
This.ShowInTaskbar = True;
However, if i set on a modal window showmeintaskbar to false the form close itself
here is the callstack :
> EasyDeal.exe!EasyDeal.Windows.UI.FrmMenuSuivi.FrmMenuSuivi_FormClosing(Object sender, System.Windows.Forms.FormClosingEventArgs e) Line 382 Basic
System.Windows.Forms.dll!System.Windows.Forms.Form.OnFormClosing(System.Windows.Forms.FormClosingEventArgs e) + 0x85 bytes
System.Windows.Forms.dll!System.Windows.Forms.Form.CheckCloseDialog(bool closingOnly) + 0x8d bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FContinueMessageLoop(int reason, int pvLoopData, System.Windows.Forms.NativeMethods.MSG[] msgPeeked) + 0x148 bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, int reason, int pvLoopData) + 0x1e9 bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context) + 0x16c bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) + 0x61 bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.RunDialog(System.Windows.Forms.Form form) + 0x33 bytes
System.Windows.Forms.dll!System.Windows.Forms.Form.ShowDialog(System.Windows.Forms.IWin32Window owner) + 0x38f bytes
System.Windows.Forms.dll!System.Windows.Forms.Form.ShowDialog() + 0x7 bytes
EasyDeal.exe!EasyDeal.Windows.UI.EasyDealCommon.ShowEasyDealForm(EasyDeal.Windows.UI.FormBase formToShow, EasyDeal.Windows.UI.FormBase formSender, Boolean closeFormSender, Boolean forceDialog) Line 2787 + 0xc bytes Basic
Upvotes: 0
Reputation: 2710
Sorry I only have C# Examples but the same logic applies!
I have seen this issue in some cases where form Re-Sizing or Positioning is done in the Form_Load Method. Any manoeuvre like this:
// Set Size and location of items...
this.MaximumSize = new System.Drawing.Size(1012, 665);
this.MinimumSize = new System.Drawing.Size(1012, 665);
this.MaximizeBox = false;
or anything like this:
// Centre the main form to centre screen...
this.Location = new Point((Screen.PrimaryScreen.Bounds.Size.Width / 2) - (this.Size.Width / 2), (Screen.PrimaryScreen.Bounds.Size.Height / 2) - (this.Size.Height / 2));
If you need to do any of this, make sure is done in the right place. I prefer mine in the:
Form1()
method just after the:
// Initialize Components...
InitializeComponent();
Method. This will ensure your Forms Icon will appear and solve your problem.
Upvotes: 1
Reputation: 6108
What is the window's FormBorderStyle? If it's FixedToolWindow, it wont show in the taskbar
Upvotes: 2