public static String ComboKeydown(System.Windows.Forms.Form thisFrm, Keys keyCode, String query, String selectedText, int uptoIndex) { //keydown String str = ""; if (keyCode == Keys.F4 || keyCode == Keys.Down || keyCode == Keys.F10 || keyCode == Keys.Enter) { str = callFrm(thisFrm, query, selectedText, uptoIndex); } else if (keyCode == Keys.Delete) { str = ""; } else { str = selectedText; } if (thisFrm.ActiveControl != null) { if (str != "" && thisFrm.ActiveControl.GetType() != typeof(faspiGrid.ansGridView)) { thisFrm.SelectNextControl(thisFrm.ActiveControl, true, true, true, true); } } thisFrm.Activate(); return(str); }
public void goNextControl(Form form, object sender, KeyPressEventArgs e) { if ((int)e.KeyChar == (int)Keys.Enter) { form.SelectNextControl((Control)sender, true, true, true, true); e.Handled = true; } }
public static String ComboKeypress(System.Windows.Forms.Form thisFrm, char keyChar, String query, String selectedText, int uptoIndex) { //keypress String str = ""; if (char.IsLetter(keyChar) || char.IsNumber(keyChar) || keyChar == ' ' || keyChar.ToString() == "\r") { str = callFrm(thisFrm, query, selectedText, uptoIndex); if (thisFrm.ActiveControl != null) { if (str != "" && thisFrm.ActiveControl.GetType() != typeof(faspiGrid.ansGridView)) { thisFrm.SelectNextControl(thisFrm.ActiveControl, true, true, true, true); } } thisFrm.Activate(); } return(str); }
public String SelectCombo(System.Windows.Forms.Form thisFrm, char keyChar, String query, String selectedText, int uptoIndex) { //keypress String str = ""; if (char.IsLetter(keyChar) || char.IsNumber(keyChar) || keyChar == ' ' || Convert.ToInt32(keyChar) == 13) { str = callFrm(thisFrm, query, selectedText, uptoIndex); } if (str != "" && thisFrm.ActiveControl.GetType() != typeof(faspiGrid.ansGridView)) { thisFrm.SelectNextControl(thisFrm.ActiveControl, true, true, true, true); } thisFrm.Activate(); thisFrm.TopMost = true; return(str); }
// Brubbel internal virtual void AfterControlRemoved(Control control) { // Select next control, if control was active and removed. if (control == activeControl || control.Contains(activeControl)) { if (base.SelectNextControl(control, true, true, true, true)) { this.SetFocus(activeControl); } else { this.SetActiveControl(null); } } else if ((this.activeControl == null) && (this.Parent != null)) { ContainerControl container = Parent.GetContainerControl() as ContainerControl; if (null != container && container.ActiveControl == this) { Form form = base.FindForm(); if (null != form) { form.SelectNextControl(this, true, true, true, true); } } } else { } // Make sure the unvalidated control and active control are cleaned up. if (control == unvalidatedControl || control.Contains(unvalidatedControl)) { unvalidatedControl = null; } }
// Inner version of "Run". In this implementation we only allow a // message loop to be running on one of the threads. private static void RunMessageLoop(ApplicationContext context) { Form mainForm = context.MainForm; EventHandler handler; Request request; Thread thread = Thread.CurrentThread; bool isMainThread; // Connect the context's ThreadExit event to our "ExitThread". handler = new EventHandler(ContextExit); context.ThreadExit += handler; // Show the main form on-screen. if (mainForm != null) { mainForm.Show(); mainForm.SelectNextControl(null, true, true, true, false); Form.activeForm = mainForm; } // Make sure that we are the only message loop. lock (typeof(Application)) { if (mainThread != null) { isMainThread = false; } else { mainThread = thread; isMainThread = true; } } // Run the main message processing loop. if (isMainThread) { IToolkit toolkit = ToolkitManager.Toolkit; try { for (;;) { try { // Process events in the queue. if (!toolkit.ProcessEvents(false)) { #if !CONFIG_COMPACT_FORMS // There were no events, so raise "Idle". if (Idle != null) { Idle(null, EventArgs.Empty); } #endif // Block until an event, or quit, arrives. if (!toolkit.ProcessEvents(true)) { break; } } // Process requests sent via "SendRequest". while ((request = NextRequest(thread, false)) != null) { request.Execute(); } } catch (Exception e) { Application.OnThreadException(e); } } } finally { // Reset the "mainThread" variable because there // is no message loop any more. lock (typeof(Application)) { mainThread = null; } } } else { // This is not the main thread, so only process // requests that were sent via "SendRequest". while ((request = NextRequest(thread, true)) != null) { request.Execute(); } } // Disconnect from the context's "ThreadExit" event. context.ThreadExit -= handler; Form.activeForm = null; #if !CONFIG_COMPACT_FORMS // Raise the "ThreadExit" event. if (ThreadExit != null) { ThreadExit(null, EventArgs.Empty); } // Raise the "ApplicationExit" event. if (ApplicationExit != null) { ApplicationExit(null, EventArgs.Empty); } #endif }
public void TestPublicMethods () { // Public Methods that force Handle creation: // - CreateGraphics () // - GetChildAtPoint () // - Invoke, BeginInvoke throws InvalidOperationException if Handle has not been created // - PointToClient () // - PointToScreen () // - RectangleToClient () // - RectangleToScreen () // - Select () // - Show (IWin32Window) // Notes: // - CreateControl does NOT force Handle creation! Form c = new Form (); c.BringToFront (); Assert.IsFalse (c.IsHandleCreated, "A1"); c.Contains (new Form ()); Assert.IsFalse (c.IsHandleCreated, "A2"); c.CreateControl (); Assert.IsFalse (c.IsHandleCreated, "A3"); c = new Form (); Graphics g = c.CreateGraphics (); g.Dispose (); Assert.IsTrue (c.IsHandleCreated, "A4"); c.Dispose (); c = new Form (); c.Dispose (); Assert.IsFalse (c.IsHandleCreated, "A5"); c = new Form (); // This is weird, it causes a form to appear that won't go away until you move the mouse over it, // but it doesn't create a handle?? //DragDropEffects d = c.DoDragDrop ("yo", DragDropEffects.None); //Assert.IsFalse (c.IsHandleCreated, "A6"); //Assert.AreEqual (DragDropEffects.None, d, "A6b"); //Bitmap b = new Bitmap (100, 100); //c.DrawToBitmap (b, new Rectangle (0, 0, 100, 100)); //Assert.IsFalse (c.IsHandleCreated, "A7"); //b.Dispose (); c.FindForm (); Assert.IsFalse (c.IsHandleCreated, "A8"); c.Focus (); Assert.IsFalse (c.IsHandleCreated, "A9"); c.GetChildAtPoint (new Point (10, 10)); Assert.IsTrue (c.IsHandleCreated, "A10"); c.Dispose (); c = new Form (); c.GetContainerControl (); Assert.IsFalse (c.IsHandleCreated, "A11"); c.Dispose (); c = new Form (); c.GetNextControl (new Control (), true); Assert.IsFalse (c.IsHandleCreated, "A12"); c.GetPreferredSize (Size.Empty); Assert.IsFalse (c.IsHandleCreated, "A13"); c.Hide (); Assert.IsFalse (c.IsHandleCreated, "A14"); c.Invalidate (); Assert.IsFalse (c.IsHandleCreated, "A15"); //c.Invoke (new InvokeDelegate (InvokeMethod)); //Assert.IsFalse (c.IsHandleCreated, "A16"); c.PerformLayout (); Assert.IsFalse (c.IsHandleCreated, "A17"); c.PointToClient (new Point (100, 100)); Assert.IsTrue (c.IsHandleCreated, "A18"); c.Dispose (); c = new Form (); c.PointToScreen (new Point (100, 100)); Assert.IsTrue (c.IsHandleCreated, "A19"); c.Dispose (); c = new Form (); //c.PreProcessControlMessage ??? //c.PreProcessMessage ??? c.RectangleToClient (new Rectangle (0, 0, 100, 100)); Assert.IsTrue (c.IsHandleCreated, "A20"); c.Dispose (); c = new Form (); c.RectangleToScreen (new Rectangle (0, 0, 100, 100)); Assert.IsTrue (c.IsHandleCreated, "A21"); c.Dispose (); c = new Form (); c.Refresh (); Assert.IsFalse (c.IsHandleCreated, "A22"); c.ResetBackColor (); Assert.IsFalse (c.IsHandleCreated, "A23"); c.ResetBindings (); Assert.IsFalse (c.IsHandleCreated, "A24"); c.ResetCursor (); Assert.IsFalse (c.IsHandleCreated, "A25"); c.ResetFont (); Assert.IsFalse (c.IsHandleCreated, "A26"); c.ResetForeColor (); Assert.IsFalse (c.IsHandleCreated, "A27"); c.ResetImeMode (); Assert.IsFalse (c.IsHandleCreated, "A28"); c.ResetRightToLeft (); Assert.IsFalse (c.IsHandleCreated, "A29"); c.ResetText (); Assert.IsFalse (c.IsHandleCreated, "A30"); c.SuspendLayout (); Assert.IsFalse (c.IsHandleCreated, "A31"); c.ResumeLayout (); Assert.IsFalse (c.IsHandleCreated, "A32"); c.Scale (new SizeF (1.5f, 1.5f)); Assert.IsFalse (c.IsHandleCreated, "A33"); c.Select (); Assert.IsTrue (c.IsHandleCreated, "A34"); c.Dispose (); c = new Form (); c.SelectNextControl (new Control (), true, true, true, true); Assert.IsFalse (c.IsHandleCreated, "A35"); c.SetBounds (0, 0, 100, 100); Assert.IsFalse (c.IsHandleCreated, "A36"); c.Update (); Assert.IsFalse (c.IsHandleCreated, "A37"); // Form c.Activate (); Assert.IsFalse (c.IsHandleCreated, "F1"); c.AddOwnedForm (new Form ()); Assert.IsFalse (c.IsHandleCreated, "F2"); c.Close (); Assert.IsFalse (c.IsHandleCreated, "F3"); c.Hide (); Assert.IsFalse (c.IsHandleCreated, "F4"); c.LayoutMdi (MdiLayout.Cascade); Assert.IsFalse (c.IsHandleCreated, "F5"); #if !MONO c.PerformAutoScale (); Assert.IsFalse (c.IsHandleCreated, "F6"); #endif c.PerformLayout (); Assert.IsFalse (c.IsHandleCreated, "F7"); c.AddOwnedForm (new Form ()); c.RemoveOwnedForm (c.OwnedForms [c.OwnedForms.Length - 1]); Assert.IsFalse (c.IsHandleCreated, "F8"); c.ScrollControlIntoView (null); Assert.IsFalse (c.IsHandleCreated, "F9"); c.SetAutoScrollMargin (7, 13); Assert.IsFalse (c.IsHandleCreated, "F10"); c.SetDesktopBounds (-1, -1, 144, 169); Assert.IsFalse (c.IsHandleCreated, "F11"); c.SetDesktopLocation (7, 13); Assert.IsFalse (c.IsHandleCreated, "F12"); c = new Form (); c.Show (null); Assert.IsTrue (c.IsHandleCreated, "F13"); c.Close (); c = new Form (); //c.ShowDialog () c.ToString (); Assert.IsFalse (c.IsHandleCreated, "F14"); c.Validate (); Assert.IsFalse (c.IsHandleCreated, "F15"); #if !MONO c.ValidateChildren (); Assert.IsFalse (c.IsHandleCreated, "F16"); #endif c.Close (); }
public void ControlSelectNextFlatTest () { // if (TestHelper.RunningOnUnix) { // Assert.Ignore ("Relies on form.Show() synchronously generating WM_ACTIVATE"); // } Form form = new Form (); form.ShowInTaskbar = false; form.Controls.AddRange (flat_controls); form.Show (); Assert.IsTrue (flat_controls [0].Focused, "sanity-1"); Assert.AreEqual (flat_controls [0], form.ActiveControl, "sanity-2"); form.SelectNextControl (flat_controls [0], true, false, false, false); Assert.IsFalse (flat_controls [0].Focused, "A1"); Assert.IsTrue (flat_controls [1].Focused, "A2"); Assert.IsFalse (flat_controls [2].Focused, "A3"); Assert.AreEqual (flat_controls [1], form.ActiveControl, "A4"); form.SelectNextControl (flat_controls [1], true, false, false, false); Assert.IsFalse (flat_controls [0].Focused, "A5"); Assert.IsFalse (flat_controls [1].Focused, "A6"); Assert.IsTrue (flat_controls [2].Focused, "A7"); Assert.AreEqual (flat_controls [2], form.ActiveControl, "A8"); // Can't select anymore because we aren't wrapping form.SelectNextControl (flat_controls [2], true, false, false, false); Assert.IsFalse (flat_controls [0].Focused, "A9"); Assert.IsFalse (flat_controls [1].Focused, "A10"); Assert.IsTrue (flat_controls [2].Focused, "A11"); Assert.AreEqual (flat_controls [2], form.ActiveControl, "A12"); form.SelectNextControl (flat_controls [2], true, false, false, true); Assert.IsTrue (flat_controls [0].Focused, "A13"); Assert.IsFalse (flat_controls [1].Focused, "A14"); Assert.IsFalse (flat_controls [2].Focused, "A15"); Assert.AreEqual (flat_controls [0], form.ActiveControl, "A16"); form.Dispose (); }
public void EnsureDirectedSelectUsed () { Form form = new Form (); form.ShowInTaskbar = false; form.Show (); form.Controls.AddRange (flat_controls); form.SelectNextControl (null, true, false, false, false); Assert.IsTrue (flat_controls [0].directed_select_called, "A1"); form.Dispose (); }
public void SelectNextControlNullTest () { Form form = new Form (); form.ShowInTaskbar = false; form.Show (); form.Controls.AddRange (flat_controls); form.SelectNextControl (null, true, false, false, false); Assert.IsTrue (flat_controls [0].Focused, "A1"); Assert.IsFalse (flat_controls [1].Focused, "A2"); Assert.IsFalse (flat_controls [2].Focused, "A3"); Assert.AreEqual (flat_controls [0], form.ActiveControl, "A4"); form.SelectNextControl (null, true, false, false, false); Assert.IsTrue (flat_controls [0].Focused, "A5"); Assert.IsFalse (flat_controls [1].Focused, "A6"); Assert.IsFalse (flat_controls [2].Focused, "A7"); Assert.AreEqual (flat_controls [0], form.ActiveControl, "A8"); form.Dispose (); }