简体   繁体   中英

TaskDialogIndirect randomly fails and makes empty, undrendered window

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;
}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM