NTaskDialog positioning


Author
Message
Craig Swearingen
Craig Swearingen
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
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
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
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
Craig Swearingen
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
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.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search