Ian Branch 127 Posted January 25, 2021 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
Anders Melander 1783 Posted January 25, 2021 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
Ian Branch 127 Posted January 25, 2021 Tks Anders. It was worth the ask to confirm one way or the other. Cheers, Ian Share this post Link to post
Remy Lebeau 1394 Posted January 25, 2021 (edited) 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 January 25, 2021 by Remy Lebeau Share this post Link to post
Anders Melander 1783 Posted January 25, 2021 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