4

Can the Delphi TTaskDialog be made to use VCLStyles?

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
mmmm
  • 2,431
  • 2
  • 35
  • 56
  • 5
    The [`TTaskDialog`](http://docwiki.embarcadero.com/Libraries/en/Vcl.Dialogs.TTaskDialog) is entirely [`Windows Vista up dialog`](http://msdn.microsoft.com/en-us/library/windows/desktop/bb787471%28v=vs.85%29.aspx), and I'm afraid this would be hard to do (if it's even possible). My suggestion is to create your own (moreover, you will get the benefit, your own task dialog will work also on Windows XP below). – TLama May 04 '12 at 07:47
  • [`Arnaud`](http://stackoverflow.com/users/458259/arnaud-bouchez) made a [`task dialog simulation`](http://blog.synopse.info/post/2011/03/05/Open-Source-SynTaskDialog-unit-for-XP,Vista,Seven) for Windows XP and below. – TLama May 04 '12 at 08:25
  • 1
    Tlama / Arnaud - I am once again astounded by the knowledge and helpfulness of the StackOverflow community! – mmmm May 04 '12 at 19:04

2 Answers2

8

I just added TTaskDialog support to the VCL Styles Utils library.

enter image description here

enter image description here

To activate this feature you need to add these units to your project.

  • Vcl.Styles.Utils.Forms
  • Vcl.Styles.Utils.SysStyleHook
  • Vcl.Styles.Utils.SysControls
  • Vcl.Styles.Hooks

More info can be found on this blog post.

RRUZ
  • 134,889
  • 20
  • 356
  • 483
5

AFAIK, and as stated by TLama in his comment, this TTaskDialog just maps Windows API directly, you won't be able to do VCL Style directly.

BUT you may be able to do this, by using a hack similar to the one described in this article about using VCL Styles within a TWebBrowser.

This would be some work, or even not feasible, I suspect. You would have to hack all components created by Windows, which is not easy. The Task Dialog API does not provide a full and detailed COM interface, with a lot of callbacks, ready to be overriden, just like TWebBrowser does.

If you use our Open-Source Task Dialog emulation code as a start, you can enforce to use our emulation layer with pure VCL components. In this case, it will be easy to work with styles. Do not forget to send feedback and a patch to us, in order to let the unit be improved! Other users would like to benefit for such a nice features, I think. This is what is great with Open Source: you start something, publish, then contributions are integrated, and the result gets better. :)

Arnaud Bouchez
  • 42,305
  • 3
  • 71
  • 159
  • +1ed, I don't want to steal the credits :-) Anyway I've found a strange issue with the positioning. Setting the `Form.Canvas.TextWidth` changes the position to a high negative values, also every subsequent change to the form size decrease the position values too, thus the form never gets visible. I don't get why this happens, since this should not affect the form position IMHO. – TLama May 04 '12 at 09:23
  • @TLama What do you mean by "Setting the Form.Canvas.TextWidth" ? – Arnaud Bouchez May 04 '12 at 09:32
  • The `SynTaskDialog.pas`, line 653. I've called the `Execute` like in my deleted post and on that line the `Form.Left` and `Form.Top` were changed to the negative values (very weird anyway). Btw. I've had the caller form with `poScreenCenter` position set (it depends somehow, don't get why). – TLama May 04 '12 at 09:37
  • And sorry, it was a typo, I meant to say `getting the Form.Canvas.TextWidth` not setting, of course :-) – TLama May 04 '12 at 10:05