I’m trying to track down a problem today where one of our programs apparently locks up.
Here’s the screengrab:
Notice the partially drawn window around the center, with leftover high scores from the previous window. I’m pretty sure this outer box is the window frame for the task dialog, as that’s where it’s positioned when it is shown correctly. The high scores dialog box that was on the screen was larger, and the buttons and bottom of the screen have redrawn.
Here’s how I declare the signature:
[DllImport("comctl32.dll", PreserveSig = false, CharSet = CharSet.Unicode)]
private static extern TaskDialogResult TaskDialog(IntPtr hwndParent, IntPtr hInstance,
string title, string mainInstruction, string content,
TaskDialogButtons buttons, TaskDialogIcon icon);
And here’s how I call it:
int split = text.IndexOf('\n');
TaskDialogResult tdr = TaskDialog(hWnd, IntPtr.Zero, caption,
text.Substring(split + 1), taskBtn, taskIcon);
Now, what I think is probably happening is that for some reason, the two strings passed into the TaskDialog are being garbage collected, but that’s just a wild guess at the moment.