Which code segment should you insert at line 05?

You are converting a Windows Forms application to a Windows Presentation Foundation (WPF) application. You use Microsoft .NET Framework 3.5 to create the WPF application.
The WPF application will reuse 30 forms of the Windows Forms application. The WPF application contains the following class definition.

public class OwnerWindow : System.Windows.Forms.IWin32Window
{
private IntPtr handle_Renamed;
public IntPtr Handle
{
get { return handle_Renamed ; }
set { handle_Renamed = value ; }
}
}

You write the following code segment in the WPF application.
(Line numbers are included for reference only.)

01 public System.Windows.Forms.DialogResult LaunchWindowsFormsDialog(System.Windows.Forms.Form dialog, Window wpfParent)
02 {
03 System.Windows.Interop.WindowInteropHelper helper = new System.Windows.Interop.WindowInteropHelper(wpfParent) ;
04 OwnerWindow owner = new OwnerWindow() ;
05
06 }

You need to ensure that the application can launch the reusable forms as modal dialogs.
Which code segment should you insert at line 05?

You are converting a Windows Forms application to a Windows Presentation Foundation (WPF) application. You use Microsoft .NET Framework 3.5 to create the WPF application.
The WPF application will reuse 30 forms of the Windows Forms application. The WPF application contains the following class definition.

public class OwnerWindow : System.Windows.Forms.IWin32Window
{
private IntPtr handle_Renamed;
public IntPtr Handle
{
get { return handle_Renamed ; }
set { handle_Renamed = value ; }
}
}

You write the following code segment in the WPF application.
(Line numbers are included for reference only.)

01 public System.Windows.Forms.DialogResult LaunchWindowsFormsDialog(System.Windows.Forms.Form dialog, Window wpfParent)
02 {
03 System.Windows.Interop.WindowInteropHelper helper = new System.Windows.Interop.WindowInteropHelper(wpfParent) ;
04 OwnerWindow owner = new OwnerWindow() ;
05
06 }

You need to ensure that the application can launch the reusable forms as modal dialogs.
Which code segment should you insert at line 05?

A.
owner.Handle = helper.Owner;
DialogResult db = new DialogResult();
return db;

B.
owner.Handle = helper.Owner
return dialog.ShowDialog(owner);

C.
owner.Handle = helper.Owner ;
Nullable<bool> result = wpfParent.ShowDialog();
if (result.HasValue)
{
if (result.value)
return System.Windows.Forms.DialogResult.OK;
else
return System.Windows.Forms.DialogResult.Cancel;
}
else
{
return System.Windows.Forms.DialogResult.Cancel;
}

D.
owner.Handle = helper.Handle:
Nullable<bool> result = wpfParent.ShowDialog();
if (result.HasValue)
{
if (result.value)
return System.Windows.Forms.DialogResult.OK;
else
return System.Windows.Forms.DialogResult.Cancel;
}
else
{
return System.Windows.Forms.DialogResult.Cancel;
}



Leave a Reply 0

Your email address will not be published. Required fields are marked *