应用程序标题位于任务栏但不在标题栏

4 .net c# titlebar winforms

这是我正在做的一件奇怪的事情,但是我如何在任务栏中设置 winform 表单的标题,而不是在其标题栏中?

小智 6

一个可能的解决方案(对我来说效果很好)是覆盖 CreateParams 属性并设置要在任务栏中显示的标题:

protected override CreateParams CreateParams
{
   get
   {
      new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();

      // Extend the CreateParams property of the Button class.
      CreateParams cp = base.CreateParams;
      // Update the button Style.
      cp.Style &= ~0xC00000; //WS_CAPTION;
      cp.Caption = PRODUCT_NAME;

      return cp;
   }
}
Run Code Online (Sandbox Code Playgroud)

我希望这对你有用

丽莎