NTaskDialog positioning


https://www.nevron.com/Forum/Topic7729.aspx
Print Topic | Close Window

By Craig Swearingen - 11 Years Ago

I'm using the NTaskDialog at the moment for replacing the standard message box support.  Works great for this.  I'd like to position this message box a specific place on the screen.  I mainly need to do this because I'd like to show a message centered over my NDocument window.  The TaskDialogDisplayPosition.CenterParent centers over the whole application when the NTaskDialog owner is an NDocument.

I noticed I can do this:

NTaskDialog dlg = new NTaskDialog();

... fill in dlg contents, etc.

dlg.DisplayPosition = TaskDialogDisplayPosition.Manual;

NRectangle nrect = new NRectangle();

nrect.X = 100; nrect.Y = 100;

I then can call dlg.Show(owner, nrect);

However, unless I also specify the nrect.Width and nrect.Height to be non-zero my position is not used and its centered on the screen instead.  I'd like to know the NTaskDialog's height and width in calculating the correct position.  How can I determine its width and height before calling NTaskDialog.Show() ?

Obviously, I can stop using the NTaskDialog and write my own message box form but you've gone to all this effort and I'd like to take advantage of your work.

By Nevron Support - 11 Years Ago
Hello Craig,

You cannot determine width and height of NTaskDialog control before show it.
Just after you call Show method it internally creates a Form which actually represents the control on the screen.
If you call Show method without parameters for width it takes the value of PreferredWidth property and determines the height so it can fit its content.
By Craig Swearingen - 11 Years Ago
Thanks for replying.  I looked further and found a way to resolve my issue.  I discovered the Notify event on the NTaskDialog.  It nicely provides access to the Form which is created during the Show.  I can then position my NTaskDialog by changing the Location property of the Form during the Notify Load event.  Sorry I missed seeing that in the first place.