views:

597

answers:

6

By design, the toolbar application thumbnail on Vista does not update when an application is minimized, since the minimized window itself is not redrawing. For a monitoring application I have, it would be useful to update the application thumbnail while the application remains minimized. I am using Delphi 2009. Can anyone suggest a good workaround for this?

HMcG

+2  A: 

That's an interesting one I guess it is possible in some way with the windows API, i'm not on a vista machine at the moment but I think Windows Media Player still shows the video playing when minimized.

I suppose a hack would be to override the minimize button and move the form off screen, then detect the form becoming active again and moving it back to the old location. This would mean the form is out of view but not minimized.

PeteT
Moving the form off the screen would probably work, but seems a bit of a bodge. Not that bodges are ruled out, though..............HMcG
HMcG
Windows Media Player does indeed managed this trick. Unless of course they are just over-riding the minimize button and moving the form off screen.
HMcG
I did put it's a hack there probably is a proper method but if you need it to work and can't find a solution I don't think it will cause any issues.
PeteT
This actually works quite well in practice. Allow the app to minimize, then hide form, restore, move off-screen, and make visible. Note that restoring after moving off-screen moves the form back on-screen again. With this sequence the app appears to minimize normally. I guess I had better document this now, so in 2 years time I can figure out why the heck this code is here...Cheers
HMcG
A: 

I have changed Application.Title in the past to show some information in the taskbar button. I dont suppose this causes a redraw of the icon?

Brian Frost
I don't think the OP is asking about the icon on the task bar, but the thumbnail ("mini screenshot") that can display in Vista so you know what the window contains before switching to it.
Scott W
Changing the Application.Title no longer seems to change the taskbar button caption. Changing the main form caption does, but unfortunately does not redraw the icon (or redraws it with the same image, perhaps.)
HMcG
+1  A: 

I don't know if this workaround still works in Delphi 2009: override CreateParams to set GetDesktopWindow as the WndParent.

Stijn Sanders
Yep, this still seems to work in D2009 in Vista, and the second form also has a thumbnail, but the thumbnail still does not update when the app. is minimised. Useful trick though, and moving the second window off the screen might give me the effect I want. BTW, doing this with a modal window has some "interesting" side effects......
HMcG
Should this trick be necessary if you set Application.MainFormOnTaskbar := true ?
Vegar
MainFormOnTaskBar was introduced in Delphi 2007, if I'm not mistaken, and this trick is from well before that time.
Stijn Sanders
A: 

In Delphi 2007 your main form is on the task bar if you set

  Application.MainFormOnTaskbar := True;

To keep it updating then you need to prevent your application from minimizing and instead just move it to the back. You can do this by putting a TApplicationEvents on the form and assigning an event handler to the OnMinimize event and then call Application.Restore in there. You will want to track your own minimization state and make sure you hide all the other forms (if you have them) and only have your main form visible, but at the lowest Z-order when it is "minimized."

I don't think Windows Vista lets you move forms off the screen, or you could just do that. Maybe there is a hack around that.

Good luck!

Jim McKeeth
+2  A: 

I found something in a Microsoft development forum that addresses this topic. The question was about a way to provide a custom thumbnail image, to which Microsoft's Leonardo Blanco responded with this:

We do no[t] plan to provide a means for an app to create a custom alternative thumbnail representation, but we will provide an API to opt out of the normal thumbnail image altogether ....

It looks like those plans might have changed in the meantime, judging from the existence in MSDN of the functions DwmSetIconicLivePreviewBitmap and DwmSetIconicThumbnail for Windows 7. Right now those entries don't really contain any explanations, but their names look promising.

Someone pointed out that the thumbnail for Windows Media Player shows moving video even while the window is minimized. Blanco's explanation:

WMP uses a new video pipeline that talks directly to the [Desktop Window Manager] to achieve a smoother playback experience. This pipeline relies on [DirectX] and doesn't depend on window visibility information, so the thumbnail can be kept alive even though the window is minimized, as long as the app continues to submit frames. You may notice, however, that the UI around the video isn't live anymore (this is tricky to observe because the UI around the video doesn't usually update). For a bit more info on this method, see the DwmSetPresentParameters API.

I'm afraid I can't find anything more about this. Documentation for DWM functions is sparse.

Given the nature of your application, maybe it's worth considering a gadget to live on the Windows Sidebar.

Rob Kennedy
Thanks for the link. For the moment moving the form off-screen rather than minimizing works around the problem. Perhaps Windows 7 will offer a better solution long term.
HMcG
A: 

Hi,

go to your source project and change Application.MainFormOnTaskbar to false: Application.MainFormOnTaskbar := false;

Regards, Mauricio

http://sourceforge.net/projects/tcycomponents/

Mauricio