运行frameworks 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也使程序出现在任务栏中。
谢谢!
答案 0 :(得分:2)
什么是Windows FormBorderStyle?如果它是Fixed ToolWindow,它将不会显示在任务栏中
答案 1 :(得分:0)
使用以下两行在表单加载事件中切换ShowInTaskbar:
仅当窗口不是模态窗口时才有效。这对现在有好处。
This.ShowInTaskbar = False;
This.ShowInTaskbar = True;
但是,如果我在一个模态窗口上设置showmeintaskbar为false表单关闭自己
这里是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
答案 2 :(得分: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();
方法。这将确保您的表单图标出现并解决您的问题。