I use TaskDialogIndirect()
to display more advanced Error Messages. I can customize the buttons, icons, and more.
The problem is that, sometimes it makes these invisible empty dialog boxes.
I need it to be reliable. I am wondering why this is even happening in the first place.
Example of it failing (there is no visible window):
Here is the code that makes the dialogs (not production code):
int MessageBoxPosL(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType, int X, int Y)
{
TaskDialogData data;
data.X = X;
data.Y = Y;
TASKDIALOGCONFIG config = {};
config.cbSize = sizeof(config);
config.hwndParent = hWnd;
config.pszWindowTitle = lpCaption;
config.pszContent = lpText;
// configure other settings as desired, based on uType...
config.pfCallback = &TaskDialogCallback;
config.lpCallbackData = (LONG_PTR)&data;
config.dwFlags = TDF_ENABLE_HYPERLINKS;
config.hFooterIcon = LoadIcon(NULL, IDI_ERROR);
config.dwCommonButtons = ButtonActive(TDCBF_YES_BUTTON) | ButtonActive(TDCBF_NO_BUTTON) | ButtonActive(TDCBF_OK_BUTTON) | ButtonActive(TDCBF_RETRY_BUTTON) | ButtonActive(TDCBF_CLOSE_BUTTON);
config.pszMainIcon = SetIcon();
int button = 0;
TaskDialogIndirect(&config, &button, NULL, NULL);
return button;
}
CodePudding user response:
The problem was the flag TDF_ENABLE_HYPERLINKS. Adding hyperlinked text that is too long caused the dialog to spawn outside of the desktop view.