private static void ShowCustomSQLDialog(ref String sql) { sql = null; var sqldlg = new CustomSQL(); var wih = new WindowInteropHelper(sqldlg); wih.Owner = (IntPtr)_parentWindowHandle; sqldlg.ShowDialog(); if (sqldlg.DialogResult.Equals(true)) { // Get the various parameters. sql = sqldlg.SQL; } }