Hide a form's taskbar button without using WS_EX_TOOLWIN

前端 未结 7 2192
太阳男子
太阳男子 2020-12-16 06:59

I need to hide a Windows form from the taskbar but I can\'t use WS_EX_TOOLWINDOW because I need the system menu and min/max buttons on the form\'s title bar.

相关标签:
7条回答
  • 2020-12-16 07:12

    Solved my problems in this area by BordersStyle bsDialog/bsToolWindow (but then I did not need the min/max...). But I wonder why you should want to combine these attributes.. Won't it confuse the 'normal' user?

    0 讨论(0)
  • 2020-12-16 07:18

    One way to do this in C# is:

    ShowWindow(_window, SWHide);
    
    int style = GetWindowLong(_window, GWL_EXSTYLE);
    style |= WS_EX_TOOLWINDOW;
    SetWindowLong(_window, GWL_EXSTYLE, style);
    
    ShowWindow(_window, SWShow);
    
    0 讨论(0)
  • 2020-12-16 07:20

    I'm looking a piece of code to integrate a Textbox to the Windows Taskbar.

    I plan to create a toolbar I can't to ' integrate it to the taskbar.

    Thank you for your help pj

    0 讨论(0)
  • 2020-12-16 07:22

    There's an interesting discussion of this exact problem here (from a VB6 persepective).

    The most relevant bit from your question's perspective is:

    "When you create a window, the taskbar examines the window's extended style to see if either the WS_EX_APPWINDOW (&H40000) or WS_EX_TOOLWINDOW (&H80) style is turned on. If WS_EX_APPWINDOW is turned on, the taskbar shows a button for the window, and if WS_EX_ TOOLWINDOW is turned on, the taskbar does not show a button for the window. A window should never have both of these extended styles. If the window doesn't have either of these styles, the taskbar decides to create a button if the window is unowned and does not create a button if the window is owned."

    Incidentally, you use the GetWindow API function with the GW_OWNER flag to determine whether a window is owned.

    0 讨论(0)
  • 2020-12-16 07:27

    in Delphi XE (2010) this works perfectly: you shoud edit main form,

    program prog;  
    
    uses
    Forms,
    Unit1 in 'Unit1.pas' {Form1};
    
    begin
    Application.Initialize;
    
    // this value is set to "true", but you shoud set it "false"
    Application.MainFormOnTaskbar := false;
    
    Application.CreateForm(TForm1, Form1);
    Application.Run;
    end.
    

    (for this main form search in "modeling view" window)

    after this, go to unit1.pas, your main forms unit and "OnShow" event of form1 do:

    procedure TForm1.FormShow(Sender: TObject);
    
    begin
    
    ShowWindow(Application.Handle, SW_HIDE);
    
    end;
    

    this will help, i had the same problem, searched whole net but without resolt

    0 讨论(0)
  • 2020-12-16 07:35

    With thanks to http://www.scalabium.com/faq/dct0096.htm.

    procedure TForm1.FormCreate(Sender: TObject);
    begin
      ShowWindow(Application.Handle, SW_HIDE);
      SetWindowLong(Application.Handle, GWL_EXSTYLE,
        GetWindowLong(Application.Handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW);
      ShowWindow(Application.Handle, SW_SHOW);
    end;
    

    I tested it and it worked with Delphi2006. And windows menu and min/max buttons are still visible.

    0 讨论(0)
提交回复
热议问题