Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Modal Dialog [modified]

Modal Dialog [modified]

Scheduled Pinned Locked Moved C#
graphicsdesignhelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kamalesh82
    wrote on last edited by
    #1

    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 {

    C 1 Reply Last reply
    0
    • K kamalesh82

      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 {

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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 )

      K 1 Reply Last reply
      0
      • C Christian Graus

        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 )

        K Offline
        K Offline
        kamalesh82
        wrote on last edited by
        #3

        sorry for the typing mistake,... i neead modal, but it's creating modeless... .

        kamalesh

        C 1 Reply Last reply
        0
        • K kamalesh82

          sorry for the typing mistake,... i neead modal, but it's creating modeless... .

          kamalesh

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          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 )

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups