Posted By James Haywood

Progress Bar, Part 3

 

This will be a short post.  I just wanted to finish up this series about hosting a WPF control inside of Max by showing how, as one final method, you can also use a WPF window instead of either the MaxForm window or the rollout.  The script code is basically the same as the MaxForm version, minus the ElementHost.  You don't need it because the WPF control is being loaded into a WPF window.  No host needed.

-------------------------------------------------------------------------
dotNet.loadAssembly @"<folder name>\ProgressBar\ProgressBar\bin\Debug\ProgressBar.dll"

bar = dotNetObject "ProgressBar.UserControl1"
frm = dotnetobject "System.Windows.Window"

frm.title = "Progress"
frm.width = bar.width + 16
frm.height = bar.height + 34
frm.windowStartupLocation = frm.windowStartupLocation.centerScreen
frm.windowStyle = frm.windowStyle.toolWindow

frm.content = bar

frm.show()
-------------------------------------------------------------------------


There are a couple of extra drawbacks though. One, you need to manage all of the foreground and background colors yourself if you want it to look like it's part of Max.  Same goes for assigning the parent window as Max itself, so that it will follow along with Max as you maximize/minimize or navigate away to different programs.  Otherwise it just kinds of floats off by itself and is easy to lose.

Finally, and probably most importantly, you need to set the "accelerators" state depending on whether the window has focus or not.  Accelerators are just another name for hotkeys.  And if don't manually manage this, the user won't be able to type into any text boxes in your tool.  So in the "GotFocus" event you'll want to turn hotkeys off with "enableAccelerators = false".  And then turn them back on in the "LostFocus" event.

So overall, unless you're planning on doing something that you can't do with a regular window, like changing the shape or something crazy like that, I don't see any benefit to using a WPF window over either of the other two methods.

 
0 Comment(s):
No Comments are found for this entry.
Add a new comment using the form below.

 
Leave a Comment:
Name: * Email: *
Home Page URL:
Comment: *
   char left.

re-generate
Enter the text shown in the image on the left: *
 Remember Me?
* fields are requried
    


 
Google

User Profile
James Haywood
Seattle, WA

 
Category
 
Archives
 
Links
 
Visitors

You have 455465 hits.

 
Navigation