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. Message Box changing focus & moved to the back of the parent window [modified]

Message Box changing focus & moved to the back of the parent window [modified]

Scheduled Pinned Locked Moved C#
helpjson
5 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.
  • H Offline
    H Offline
    honeyashu
    wrote on last edited by
    #1

    Hi all I am facing a problem in my application some times it appears to user that system/ application get hanged and he is unable to do ANY THING, the only option left to him that to kill the application using Task Manager. I found the reason that actually my message box is went to back of the current window due to which focus gets lost from the front. I searched on the net and found that in my application overriding of a windows method cause such problem this method is used to draw and display a timer/click on the MDI form rest i dont know about the functionality. I am attaching the code if any body can help please reply as it's really confusing for me and i am not getting any solution for the same

    protected override void WndProc(ref System.Windows.Forms.Message m)
    {
    try
    {
    base.WndProc(ref m);
    switch (m.Msg)
    {
    case (int)WM_TIMER:
    // If Autolock feature gets started
    if (PreferencesController.IsAutoLockStart)
    { //_stastAL will be true only for the Form load and if in Preferenes ,AutoLock is assigned as true.
    if (PreferencesController.IsSetAutoLock)
    { //Starts the hooking of Keyboard and mouse hooks
    actHook.Start();
    //specifies the end time
    PreferencesController.EndTimeAutoLock = DateTime.Now.AddMinutes(PreferencesController.LockWorkStationTimeInMinute);
    PreferencesController.IsSetAutoLock = false;
    }
    AutoLockWS();
    }
    if (PreferencesController.IsShowDateTime)
    Main_OnNcPaint(ref m);
    //To Run Macro TODO: Take it from config file

                             if (DateTime.Now.ToLocalTime().ToShortTimeString().Equals(
                                 ConfigurationService.GetExcelMacroExecutionTime()))
                                ExcelFile.RunMacro();  
                        break;
                    case (int)WM\_NCPAINT:
                        if (PreferencesController.IsShowDateTime)
                            Main\_OnNcPaint(ref m);
                        break;
    
    L 1 Reply Last reply
    0
    • H honeyashu

      Hi all I am facing a problem in my application some times it appears to user that system/ application get hanged and he is unable to do ANY THING, the only option left to him that to kill the application using Task Manager. I found the reason that actually my message box is went to back of the current window due to which focus gets lost from the front. I searched on the net and found that in my application overriding of a windows method cause such problem this method is used to draw and display a timer/click on the MDI form rest i dont know about the functionality. I am attaching the code if any body can help please reply as it's really confusing for me and i am not getting any solution for the same

      protected override void WndProc(ref System.Windows.Forms.Message m)
      {
      try
      {
      base.WndProc(ref m);
      switch (m.Msg)
      {
      case (int)WM_TIMER:
      // If Autolock feature gets started
      if (PreferencesController.IsAutoLockStart)
      { //_stastAL will be true only for the Form load and if in Preferenes ,AutoLock is assigned as true.
      if (PreferencesController.IsSetAutoLock)
      { //Starts the hooking of Keyboard and mouse hooks
      actHook.Start();
      //specifies the end time
      PreferencesController.EndTimeAutoLock = DateTime.Now.AddMinutes(PreferencesController.LockWorkStationTimeInMinute);
      PreferencesController.IsSetAutoLock = false;
      }
      AutoLockWS();
      }
      if (PreferencesController.IsShowDateTime)
      Main_OnNcPaint(ref m);
      //To Run Macro TODO: Take it from config file

                               if (DateTime.Now.ToLocalTime().ToShortTimeString().Equals(
                                   ConfigurationService.GetExcelMacroExecutionTime()))
                                  ExcelFile.RunMacro();  
                          break;
                      case (int)WM\_NCPAINT:
                          if (PreferencesController.IsShowDateTime)
                              Main\_OnNcPaint(ref m);
                          break;
      
      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      please edit your message and put all code inside PRE tags, no one is going to read it as it is now. :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


      H 1 Reply Last reply
      0
      • L Luc Pattyn

        please edit your message and put all code inside PRE tags, no one is going to read it as it is now. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


        H Offline
        H Offline
        honeyashu
        wrote on last edited by
        #3

        Thanks... any view regarding problem???

        L 1 Reply Last reply
        0
        • H honeyashu

          Thanks... any view regarding problem???

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Hi, that code is mysterious to me. I do have two suggestions: 1. add a font.Dispose() to clean up the font you created. Gives better memory handling. 2. if you don't do it already, modify MessageBox.Show(someString,...) to MessageBox.Show(this, someString,...) that might solve the problem. :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


          H 1 Reply Last reply
          0
          • L Luc Pattyn

            Hi, that code is mysterious to me. I do have two suggestions: 1. add a font.Dispose() to clean up the font you created. Gives better memory handling. 2. if you don't do it already, modify MessageBox.Show(someString,...) to MessageBox.Show(this, someString,...) that might solve the problem. :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


            H Offline
            H Offline
            honeyashu
            wrote on last edited by
            #5

            I already did that... no luck so far

            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