0

运行框架 4.0 (VB.net)

ShowInTaskbar 属性设置为 True。

这里是运行主窗口的代码。

 Dim frm As New frmMain
 frm.ShowInTaskbar = True
 Application.Run(frm)

这里是来自 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

这里所有来自继承表单的代码

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

但这无济于事,即使我单击表单,应用程序也不会出现在任务栏上。

然而,真正奇怪的是,如果我设置了一个断点,或者我首先单击任务栏,然后再次单击程序将出现在任务栏上的窗体。

alt-tab 使程序也出现在任务栏中。

谢谢!

4

3 回答 3

2

什么是窗口的 F​​ormBorderStyle?如果是 FixedToolWindow,它不会显示在任务栏中

于 2012-11-26T19:15:52.240 回答
0

使用这两行在我的表单加载事件中切换 ShowInTaskbar:

它仅在窗口不是模态窗口时才有效。现在这有点好。

This.ShowInTaskbar = False;
This.ShowInTaskbar = True;

但是,如果我在模式窗口 showmeintaskbar 上设置为 false 表单会自行关闭

这是调用堆栈:

>   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
于 2012-12-03T22:22:32.803 回答
0

抱歉,我只有 C# 示例,但同样的逻辑适用!

在 Form_Load 方法中完成表单大小调整或定位的某些情况下,我已经看到了这个问题。像这样的任何动作:

// 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;

或类似的东西:

// 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));

如果您需要执行上述任何操作,请确保在正确的位置完成。我更喜欢我的:

Form1()

方法就在:

// Initialize Components...
InitializeComponent();

方法。这将确保您的表单图标出现并解决您的问题。

于 2013-12-27T06:34:11.017 回答