Message Box changing focus & moved to the back of the parent window [modified]
-
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 fileif (DateTime.Now.ToLocalTime().ToShortTimeString().Equals( ConfigurationService.GetExcelMacroExecutionTime())) ExcelFile.RunMacro(); break; case (int)WM\_NCPAINT: if (PreferencesController.IsShowDateTime) Main\_OnNcPaint(ref m); break;
-
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 fileif (DateTime.Now.ToLocalTime().ToShortTimeString().Equals( ConfigurationService.GetExcelMacroExecutionTime())) ExcelFile.RunMacro(); break; case (int)WM\_NCPAINT: if (PreferencesController.IsShowDateTime) Main\_OnNcPaint(ref m); break;
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.
-
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.
-
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, modifyMessageBox.Show(someString,...)
toMessageBox.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.
-
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, modifyMessageBox.Show(someString,...)
toMessageBox.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.