Modal Dialog [modified]
-
hi all, am getting a stange problem. from a call back function, am calling a MODELESS dialog,(when timeout reached for my dialog), but it's creating as a modal dialog... it's not my requirement. i've develop a sample,i think, it's created on a different thread than main thread. (may be.. not sure.).... please provide any commentsa nad solution.. please... :):confused: my code:(design form not included) using System; using System.Collections.Generic; using System.Diagnostics; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Threading; namespace TimeoutWindow { public partial class TimeoutForm : Form { private System.Threading.Timer m_Timer = null; private const int WH_KEYBOARD = 2; private const int WH_MOUSE = 7; private LowLevelKeyboardProc _procKey = KeyHookCallback; private LowLevelKeyboardProc _prockMouse = MouseHookCallBack; private static IntPtr _hookIDKey = IntPtr.Zero; private static IntPtr _hookIDMouse = IntPtr.Zero; private static UInt32 m_LastHitTime = 0; private System.Threading.TimerCallback timerCallBack = null; private AutoResetEvent autoEvent = null; private Form2 dlg; private delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam); public TimeoutForm() { InitializeComponent(); _hookIDKey = SetWindowsHookEx(WH_KEYBOARD,_procKey,(IntPtr)0,(uint)AppDomain.GetCurrentThreadId()); _hookIDMouse = SetWindowsHookEx(WH_MOUSE,_procKey,(IntPtr)0,(uint)AppDomain.GetCurrentThreadId()); timerCallBack = new System.Threading.TimerCallback(this.CheckTimeout); autoEvent = new AutoResetEvent(false); m_LastHitTime = GetTickCount(); m_Timer = new System.Threading.Timer(timerCallBack, autoEvent, 20000, 20000); } private void OnTryLogin(object sender, EventArgs e) { MessageBox.Show("HI"); Form2 dlg = new Form2(); dlg.ShowDialog(); } public void CheckTimeout(Object stateInfo) { autoEvent = (AutoResetEvent)stateInfo; UInt32 curTime = GetTickCount(); if (curTime - m_LastHitTime > 2000) { this.m_Timer.Dispose(); try {
-
hi all, am getting a stange problem. from a call back function, am calling a MODELESS dialog,(when timeout reached for my dialog), but it's creating as a modal dialog... it's not my requirement. i've develop a sample,i think, it's created on a different thread than main thread. (may be.. not sure.).... please provide any commentsa nad solution.. please... :):confused: my code:(design form not included) using System; using System.Collections.Generic; using System.Diagnostics; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Threading; namespace TimeoutWindow { public partial class TimeoutForm : Form { private System.Threading.Timer m_Timer = null; private const int WH_KEYBOARD = 2; private const int WH_MOUSE = 7; private LowLevelKeyboardProc _procKey = KeyHookCallback; private LowLevelKeyboardProc _prockMouse = MouseHookCallBack; private static IntPtr _hookIDKey = IntPtr.Zero; private static IntPtr _hookIDMouse = IntPtr.Zero; private static UInt32 m_LastHitTime = 0; private System.Threading.TimerCallback timerCallBack = null; private AutoResetEvent autoEvent = null; private Form2 dlg; private delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam); public TimeoutForm() { InitializeComponent(); _hookIDKey = SetWindowsHookEx(WH_KEYBOARD,_procKey,(IntPtr)0,(uint)AppDomain.GetCurrentThreadId()); _hookIDMouse = SetWindowsHookEx(WH_MOUSE,_procKey,(IntPtr)0,(uint)AppDomain.GetCurrentThreadId()); timerCallBack = new System.Threading.TimerCallback(this.CheckTimeout); autoEvent = new AutoResetEvent(false); m_LastHitTime = GetTickCount(); m_Timer = new System.Threading.Timer(timerCallBack, autoEvent, 20000, 20000); } private void OnTryLogin(object sender, EventArgs e) { MessageBox.Show("HI"); Form2 dlg = new Form2(); dlg.ShowDialog(); } public void CheckTimeout(Object stateInfo) { autoEvent = (AutoResetEvent)stateInfo; UInt32 curTime = GetTickCount(); if (curTime - m_LastHitTime > 2000) { this.m_Timer.Dispose(); try {
kamalesh82 wrote:
am calling a modal dialog,(when timeout reached for my dialog), but it's creating as a modal dialog
If you don't want a modal dialog, then call Show instead of ShowDialog. Or, have I missed what the problem is ?
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
kamalesh82 wrote:
am calling a modal dialog,(when timeout reached for my dialog), but it's creating as a modal dialog
If you don't want a modal dialog, then call Show instead of ShowDialog. Or, have I missed what the problem is ?
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
sorry for the typing mistake,... i neead modal, but it's creating modeless... .
kamalesh
-
sorry for the typing mistake,... i neead modal, but it's creating modeless... .
kamalesh
OK, perhaps you're right, you're on another thread, and that is the problem.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )