Profile Picture

NTaskDialog positioning

Posted By Craig Swearingen 11 Years Ago
Author
Message
Craig Swearingen
Posted 11 Years Ago
View Quick Profile
Supreme Being

Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)

Group: Forum Members
Last Active: 7 Years Ago
Posts: 99, Visits: 654

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.



Nevron Support
Posted 11 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746
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.

Best Regards,
Nevron Support Team



Craig Swearingen
Posted 11 Years Ago
View Quick Profile
Supreme Being

Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)

Group: Forum Members
Last Active: 7 Years Ago
Posts: 99, Visits: 654
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.



Similar Topics


Reading This Topic