IManagementUIService.DialogOwner Property

Definition

Gets the parent window ID.

public:
 property System::Windows::Forms::IWin32Window ^ DialogOwner { System::Windows::Forms::IWin32Window ^ get(); };
public System.Windows.Forms.IWin32Window DialogOwner { get; }
member this.DialogOwner : System.Windows.Forms.IWin32Window
Public ReadOnly Property DialogOwner As IWin32Window

Property Value

The parent window ID.

Examples

The following example uses this property to set the owner of a file dialog box.

void OnBrowseButtonClick(object sender, EventArgs e) {

    OpenFileDialog fileDlg = new OpenFileDialog();

    fileDlg.Multiselect = false;

    try {
        fileDlg.InitialDirectory = Environment.GetFolderPath(
            Environment.SpecialFolder.Personal);
    } catch {
        Trace.WriteLine(" Environment.GetFolderPath failed");
    }

    IManagementUIService uiService = (IManagementUIService)GetService(typeof(IManagementUIService));

    if (fileDlg.ShowDialog(uiService.DialogOwner) == DialogResult.OK) {
        _filenameTextBox.Text = fileDlg.FileName;
    }
} 

The following example implements this property.

class MyUI_Srvc : IManagementUIService, IDisposable {

    private IDictionary _styles;
    private IManagementFrameHost _owner;
    private Stack<IWin32Window> _curWin;
    private ManagementUIColorTable _colourTbl;

    private object _currentProgressToken;
    private bool _rightToLeft; 
public MyUI_Srvc(IWin32Window ownerWindow, IManagementFrameHost owner) {

    _owner = owner;

    _curWin = new Stack<IWin32Window>();
    _curWin.Push(ownerWindow);

    SystemEvents.DisplaySettingsChanged +=
        new EventHandler(this.OnSystemSettingChanged);
    SystemEvents.InstalledFontsChanged +=
        new EventHandler(this.OnSystemSettingChanged);
    SystemEvents.UserPreferenceChanged +=
        new UserPreferenceChangedEventHandler(this.OnUserPreferenceChanged);

    _rightToLeft = bool.Parse("RightToLeftLayout");
} 
private IWin32Window DialogOwner {
    get {
        return _curWin.Peek();
    }
} 

Applies to