Jump to content
Ian Branch

Can the width of TaskMessageDlg be set?

Recommended Posts

HI Team,

D10.4.1.

Can I change the default width of a TaskMessageDlg?

I can't find any way to do it. :-(

Regards & TIA,

Ian

Share this post


Link to post
1 hour ago, Ian Branch said:

Can I change the default width of a TaskMessageDlg?

No.

TaskMessageDlg is just wrapper around a TTaskDialog component and unfortunately TTaskDialog doesn't provide any way to specify the cxWidth parameter of the TASKDIALOGCONFIG structure passed to TaskDialogIndirect.

 

You could create your own wrapper that calls the TaskDialogIndirect API function instead.

 

Actually now that I think of it you might subclass TTaskDialog and override the TCustomTaskDialog.CallbackProc method to intercept the TDN_CREATED or TDN_DIALOG_CONSTRUCTED  notifications. The notification messages gives you access to a pointer to the TASKDIALOGCONFIG structure used to create the dialog but I'm unsure if you can do anything with that. There are no messages you can send the task dialog to update the width. By the way, take note that the cxWidth member specifies the width in dialog units - not pixels.

Share this post


Link to post
5 hours ago, Anders Melander said:

Actually now that I think of it you might subclass TTaskDialog and override the TCustomTaskDialog.CallbackProc method to intercept the TDN_CREATED or TDN_DIALOG_CONSTRUCTED  notifications. The notification messages gives you access to a pointer to the TASKDIALOGCONFIG structure used to create the dialog

Not according to the documentation those links point to, they don’t.

Quote

but I'm unsure if you can do anything with that. There are no messages you can send the task dialog to update the width.

You can install a thread-local hook from SetWindowsHookEx() or SetWinEventHook() before calling TaskDialogIndirect()/TTaskDialog.Execute(), to intercept the dialog’s HWND when it is actually created, and then you can do whatever you want to it.

Edited by Remy Lebeau

Share this post


Link to post
32 minutes ago, Remy Lebeau said:

Not according to the documentation those links point to, they don’t.

No you're right - I misread the documentation of the callback.

The callback function does get passed the window handle of the task dialog though:

Quote

hwnd

Type: HWND

Handle to the TaskDialog window. Do not continue sending messages to hwnd after the callback procedure returns from having been called with TDN_DESTROYED.

...which can then be used to modify the window. Not that I would recommend it.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×