How to display the Delphi dll taskbar on the taskbar from an application other than delphi

I have a mixed CBuilder / Delphi DLL that I download from a non-VCL host application. I am using RAD Studio XE2. After loading the dll, I install the application descriptor in the main form of the host, which leads to the fact that my forms and dialogs do not appear on the taskbar. However, I would like to show the progress bar on the taskbar and assemble it using the host application. I googled and searched extensively, but can't find anything like it.

R. Bob wrote a good tutorial here about the various functions of the taskbar, and from this I got a progress bar on the main taskbar on the taskbar, but I really want to create a second β€œcomplex” icon for the progress bar, which is a lot of applications. For example, Bob's example assumes that you are part of the main application and use this code to add a tab:

if not Application.MainFormOnTaskBar then FormHandle := Application.Handle else FormHandle := Application.MainForm.Handle; TaskbarList.AddTab(FormHandle); 

which does nothing in my case. I tried

 FormHandle := FindWindow('TfmProg', NIL); TaskbarList.addTab(FormHandle); 

but it does not change anything.

I created a form with the Application as the owner and NIL. I created fsNormal or fsStayOnTop. Honestly, I have touched on every parameter that I can get, but nothing works.

+4
source share
1 answer

Correctly install Application.Handle as a handle to the main form of the host application. This will make the main window of the host application the owner of your windows. However, as you have noticed, this also prevents the top-level window from being turned off from the taskbar. This is because your own top-level window does not appear on the taskbar.

To place a top-level window on the taskbar, you must enable the WS_EX_APPWINDOW advanced window style. Add this to the CreateParams form.

 procedure CreateParams(var Params: TCreateParams); override; .... procedure TMyForm.CreateParams(var Params: TCreateParams); begin inherited; Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW; end; 

You can then use ITaskbarList3.SetProgressState and ITaskbarList3.SetProgressValue by passing in your form handle to display the taskbar progress for the form taskbar button.


I have to admit that your code is odd:

 FormHandle := FindWindow('TfmProg', NIL); TaskbarList.addTab(FormHandle); 

Since the code is running in your DLL, which also created the form, you should not use FindWindow to get the handle. You can simply use Form.Handle , where Form is the link to the form instance. However, I would prefer the approach described above using WS_EX_APPWINDOW , as it is resistant to window handle recovery and feels a lot easier for me.

+2
source

All Articles