[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] pnetlib/System.Windows.Forms Application.cs, 1.7,
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] pnetlib/System.Windows.Forms Application.cs, 1.7, 1.8 Form.cs, 1.19, 1.20 |
Date: |
Thu, 13 Nov 2003 21:59:44 +0000 |
Update of /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms
In directory subversions:/tmp/cvs-serv24810/System.Windows.Forms
Modified Files:
Application.cs Form.cs
Log Message:
Add some infrastructure for "Form.ShowDialog".
Index: Form.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/Form.cs,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** Form.cs 10 Oct 2003 15:51:11 -0000 1.19
--- Form.cs 13 Nov 2003 21:59:41 -0000 1.20
***************
*** 37,40 ****
--- 37,41 ----
private bool keyPreview;
private bool topLevel;
+ internal bool dialogResultIsSet;
private Size autoScaleBaseSize;
private DialogResult dialogResult;
***************
*** 212,215 ****
--- 213,217 ----
{
dialogResult = value;
+ dialogResultIsSet = true;
}
}
***************
*** 742,750 ****
// Show this form as a modal dialog.
- [TODO]
private DialogResult ShowDialog(Form owner)
{
! // TODO
! return DialogResult.None;
}
public DialogResult ShowDialog()
--- 744,780 ----
// Show this form as a modal dialog.
private DialogResult ShowDialog(Form owner)
{
! // Bail out if this dialog is already displayed
modally.
! if(Modal)
! {
! return DialogResult.None;
! }
!
! // Reset the dialog result.
! dialogResult = DialogResult.None;
! dialogResultIsSet = false;
!
! // Mark this form as modal.
! SetWindowFlag(ToolkitWindowFlags.Modal, true);
! try
! {
! // Make the form visible.
! Visible = true;
!
! // Enter a message loop until the
dialog result is set.
! Application.InnerMessageLoop(this);
! }
! finally
! {
! // Make sure that the form is not
visible.
! Visible = false;
!
! // The form is no longer modal.
! SetWindowFlag(ToolkitWindowFlags.Modal,
false);
! }
!
! // Return the dialog result.
! return dialogResult;
}
public DialogResult ShowDialog()
Index: Application.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/Application.cs,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Application.cs 28 Sep 2003 22:06:36 -0000 1.7
--- Application.cs 13 Nov 2003 21:59:41 -0000 1.8
***************
*** 440,443 ****
--- 440,534 ----
}
+ // Run an inner message loop until the dialog result is set on a form.
+ internal static void InnerMessageLoop(Form form)
+ {
+ Request request;
+ Thread thread = Thread.CurrentThread;
+ bool isMainThread;
+ bool resetMainThread;
+
+ // Determine if we are running on the main
thread or not.
+ lock(typeof(Application))
+ {
+ if(mainThread == null)
+ {
+ // The main message loop hasn't
started yet.
+ // This might happen with
MessageBox dialogs.
+ mainThread = thread;
+ isMainThread = true;
+ resetMainThread = true;
+ }
+ else
+ {
+ isMainThread = (mainThread ==
thread);
+ resetMainThread = false;
+ }
+ }
+
+ // Run the main message processing loop.
+ if(isMainThread)
+ {
+ IToolkit toolkit =
ToolkitManager.Toolkit;
+ try
+ {
+ while(!(form.dialogResultIsSet)
&& form.Visible)
+ {
+ // 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();
+ }
+ }
+ }
+ finally
+ {
+ // Reset the "mainThread"
variable because there
+ // is no message loop any more.
+ lock(typeof(Application))
+ {
+ if(resetMainThread)
+ {
+ mainThread =
null;
+ }
+ }
+ }
+ }
+ else
+ {
+ // This is not the main thread, so only
process
+ // requests that were sent via
"SendRequest".
+ while(!(form.dialogResultIsSet) &&
form.Visible)
+ {
+ if((request =
NextRequest(thread, true)) != null)
+ {
+ request.Execute();
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+ }
+
// Make the specified form visible and run the main loop.
// The loop will exit when "Exit" is called.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] pnetlib/System.Windows.Forms Application.cs, 1.7, 1.8 Form.cs, 1.19, 1.20,
Rhys Weatherley <address@hidden> <=
- Prev by Date:
[Dotgnu-pnet-commits] pnetlib ChangeLog, 1.1458, 1.1459 configure.in, 1.106, 1.107
- Next by Date:
[Dotgnu-pnet-commits] pnetlib ChangeLog,1.1459,1.1460
- Previous by thread:
[Dotgnu-pnet-commits] pnetlib ChangeLog, 1.1458, 1.1459 configure.in, 1.106, 1.107
- Next by thread:
[Dotgnu-pnet-commits] pnetlib ChangeLog,1.1459,1.1460
- Index(es):