Esempio n. 1
0
 public static bool CreateChildForm(System.Windows.Forms.Form childForm, System.Windows.Forms.Form parentForm)
 {
     try
     {
         if (childForm.Tag != null)
         {
             if (Services.Security.checkForm(childForm.Tag.ToString().ToUpper(), Variables.UserInfo))
             {
                 childForm.MdiParent = parentForm;
                 childForm.WindowState = FormWindowState.Maximized;
                 childForm.Show();
                 return true;
             }
             else
             {
                 MessageBox.Show("Уучлаарай! Та хандах эрхгүй байна.", "Анхааруулга", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 return false;
             }
         }
         else
         {
             MessageBox.Show("Уучлаарай! Энд хандах боломжгүй байна.", "Анхааруулга", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return false;
         }
     }
     catch (Exception Err)
     {
         MessageBox.Show("Дараахи алдаа гарлаа : " + Err.Message.ToString(), "Алдаа", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return false;
     }
 }
        /// <summary>
        /// Allows a windows form to be used as the UI for an anchor window
        /// </summary>
        public static void AttachWindowsForm(
            IVisio.Window anchor_window,
            System.Windows.Forms.Form the_form)
        {
            if (anchor_window == null)
            {
                throw new System.ArgumentNullException(nameof(anchor_window));
            }

            if (the_form == null)
            {
                throw new System.ArgumentNullException(nameof(the_form));
            }

            // Show the form as a modeless dialog.
            the_form.Show();

            // Get the window handle of the form.
            int hwnd = the_form.Handle.ToInt32();
            var hwnd_as_intptr = new System.IntPtr(hwnd);

            // Set the window properties to make it a visible child window.
            const int window_prop_index = Internal.Interop.NativeMethods.GWL_STYLE;
            const int window_prop_value = Internal.Interop.NativeMethods.WS_CHILD | Internal.Interop.NativeMethods.WS_VISIBLE;
            Internal.Interop.NativeMethods.SetWindowLong(hwnd_as_intptr, window_prop_index, window_prop_value);

            // Set the anchor bar window as the parent of the form.
            Internal.Interop.NativeMethods.SetParent(hwnd, anchor_window.WindowHandle32);

            // Force a resize of the anchor bar so it will refresh.
            int left, top, width, height;
            anchor_window.GetWindowRect(out left, out top, out width, out height);
            anchor_window.SetWindowRect(left, top, width - 1, height - 1);
            anchor_window.SetWindowRect(left, top, width, height);

            // Set the dock property of the form to fill, so that the form
            // automatically resizes to the size of the anchor bar.
            the_form.Dock = System.Windows.Forms.DockStyle.Fill;

            // had to set to false to prevent a resizing problem (it was originally set to true)
            the_form.AutoSize = true;
        }
Esempio n. 3
0
 public bool? ShowDialogWithModel(System.Windows.Window view, DialogType dialogType, DialogViewModel viewModel)
 {
     if (view == null)
     {
         throw new ArgumentNullException("view");
     }
     view.Owner = this.Window;
     view.WindowStartupLocation = WindowStartupLocation.CenterOwner;
     view.ShowInTaskbar = false;
     if (viewModel != null)
     {
         viewModel.Init();
         view.DataContext = viewModel;
     }
     if (dialogType == DialogType.Modal)
     {
         return view.ShowDialog();
     }
     view.Show();
     return null;
 }
Esempio n. 4
0
 protected void PopMenu(System.Windows.Forms.ContextMenu theMenu, MouseEventArgs e)
 {
     if (theMenu != null)
         theMenu.Show(this, new Point(e.X, e.Y));
 }
Esempio n. 5
0
 public static System.Windows.Forms.DialogResult ShowDialog(System.Windows.Forms.Form newForm, System.Windows.Forms.Form currentForm)
 {
     string title = currentForm.Text;
     currentForm.Text = "";
     System.Windows.Forms.DialogResult result = newForm.ShowDialog();
     currentForm.Text = title;
     currentForm.Show();
     currentForm.BringToFront();
     return result;
 }
Esempio n. 6
0
 public static void LoadFormChild(System.Windows.Forms.Form pForm, System.Windows.Forms.Form pMasterForm)
 {
     pForm.MdiParent = pMasterForm;
     setFormChild(pForm);
     pForm.Show();
 }
 /// <summary>
 /// Helper method used to dock a Wpf window inside a Vst Window.
 /// All UI chrome is hidden away (borders, close/minimize/maximize buttons)
 /// and the window becomes embedded inside the parent window
 /// </summary>
 /// <param name="WpfWindow"></param>
 /// <param name="vstWindow"></param>
 public static void DockWpfWindow(System.Windows.Window WpfWindow, IntPtr vstWindow)
 {
     WpfWindow.Top = 0;
     WpfWindow.Left = 0;
     WpfWindow.ShowInTaskbar = false;
     WpfWindow.WindowStyle = System.Windows.WindowStyle.None;
     WpfWindow.ResizeMode = System.Windows.ResizeMode.NoResize;
     WpfWindow.Show();
     var windowHwnd = new System.Windows.Interop.WindowInteropHelper(WpfWindow);
     IntPtr hWnd = windowHwnd.Handle;
     SetParent(hWnd, vstWindow);
 }
Esempio n. 8
0
 private void ShowForm(System.Windows.Forms.Form form)
 {
     form.set_Font(this.Font);
     if (this.forms.ContainsKey(form.GetType()))
     {
         form = this.forms[form.GetType()];
         form.Focus();
     }
     else
     {
         System.Windows.Forms.Cursor.set_Current(System.Windows.Forms.Cursors.WaitCursor);
         form.Show(this);
         this.forms.Add(form.GetType(), form);
         form.add_Closed(new System.EventHandler(this.form_Closed));
         System.Windows.Forms.Cursor.set_Current(System.Windows.Forms.Cursors.Default);
     }
 }
Esempio n. 9
0
 private void Dtg_Frm_Shw(System.Windows.Forms.Form myctl, bool myshw)
 {
     if (myshw) myctl.Show();
     else myctl.Hide();
 }