WS_EX_TOOLWIN을 사용하지 않고 양식의 작업 표시 줄 버튼을 숨기십시오
문제
작업 표시 줄에서 Windows 양식을 숨겨야하지만 사용할 수 없습니다. WS_EX_TOOLWINDOW
양식의 제목 표시 줄에 시스템 메뉴와 최소/최대 버튼이 필요하기 때문입니다.
런타임에 양식을 도구 창으로 전환하면 양식 스키닝이 채워집니다. 웹에서 검색에서 VB는 Showintaskbar 속성을 가지고 있으며 이것이 내가 원하는 것을 수행 할 것인지, Delphi 2006에서 구현 될 수 있는지 궁금합니다. 또한이 프로젝트는 COM 서버이며 MainForm 등이 없습니다.
해결책
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.
다른 팁
Thanks to Stu for putting me on to the answer so quickly. In my case I had to manually add the owning form's handle into the CreateParams, but that may not be necessary in other/normal cases.
procedure TfrmWord2Site.CreateParams(var Params:TCreateParams);
begin
inherited CreateParams(Params);
Params.WndParent := <your owner form>.Handle;
Params.ExStyle := Params.ExStyle and not WS_EX_APPWINDOW;
end;
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.
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
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?
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
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);