Click here to Skip to main content
15,896,154 members
Home / Discussions / C#
   

C#

 
GeneralRe: Applying security for dotnet application Pin
CoderForEver8-Aug-09 8:56
CoderForEver8-Aug-09 8:56 
GeneralRe: Applying security for dotnet application Pin
harold aptroot8-Aug-09 8:59
harold aptroot8-Aug-09 8:59 
AnswerRe: Applying security for dotnet application Pin
Muhammad Mazhar8-Aug-09 3:41
Muhammad Mazhar8-Aug-09 3:41 
QuestionHow To Create multiple workspaces? each of workspace will contain multiple forms? [modified] Pin
shaktisinh8-Aug-09 1:18
shaktisinh8-Aug-09 1:18 
AnswerRe: How To Create multiple workspaces? each of workspace will contain multiple forms? Pin
Luc Pattyn8-Aug-09 1:34
sitebuilderLuc Pattyn8-Aug-09 1:34 
AnswerRe: How To Create multiple workspaces? each of workspace will contain multiple forms? Pin
Muhammad Mazhar8-Aug-09 3:37
Muhammad Mazhar8-Aug-09 3:37 
AnswerRe: How To Create multiple workspaces? each of workspace will contain multiple forms? Pin
Mycroft Holmes8-Aug-09 14:10
professionalMycroft Holmes8-Aug-09 14:10 
QuestionMessage Box changing focus & moved to the back of the parent window [modified] Pin
honeyashu7-Aug-09 22:58
honeyashu7-Aug-09 22:58 
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;
               }

           }
           catch (Exception ex)
           {
               ex.Message.ToString();

           }

method called in above code is

private void Main_OnNcPaint(ref Message m)
        {
            paintTitleBar = m;
            IntPtr hdc = GetWindowDC(m.HWnd);
            Graphics g = Graphics.FromHdc(hdc);
            RectangleF titleBarRectF = g.VisibleClipBounds;
            int formWidth = (int)titleBarRectF.Width;
            int CaptionHeight = Bounds.Height - ClientRectangle.Height;
            Size CloseButtonSize = SystemInformation.CaptionButtonSize;

            int X = formWidth - (CloseButtonSize.Width * 4) - 200;
            int Y = 4;
            int width = 200;
            int height = CaptionHeight - 10;
            string dateText;
            if (PreferencesController.IsShowDateTimeWithSeconds)
            {
                dateText = DateTime.Now.ToString("dd MMM yyyy hh:mm:ss tt");
            }
            else
            {
                dateText = DateTime.Now.ToString("dd MMM yyyy hh:mm tt");

            }

            RectangleF timeDisplayRectF = new RectangleF(X, Y, width, height);
            g.FillRectangle(new SolidBrush(Color.DarkBlue), timeDisplayRectF);

            // Fill a rectangle instead
            Font font = new Font(Font.FontFamily, Font.Size + 2, FontStyle.Bold);

            g.DrawString(dateText, font, new SolidBrush(Color.White), timeDisplayRectF);

            g.Dispose();

            ReleaseDC(m.HWnd, hdc);
            m.Result = IntPtr.Zero;
           
        }


modified on Saturday, August 8, 2009 6:43 AM

AnswerRe: Message Box changing focus & moved to the back of the parent window Pin
Luc Pattyn8-Aug-09 0:17
sitebuilderLuc Pattyn8-Aug-09 0:17 
GeneralRe: Message Box changing focus & moved to the back of the parent window Pin
honeyashu8-Aug-09 0:45
honeyashu8-Aug-09 0:45 
GeneralRe: Message Box changing focus & moved to the back of the parent window Pin
Luc Pattyn8-Aug-09 1:32
sitebuilderLuc Pattyn8-Aug-09 1:32 
GeneralRe: Message Box changing focus & moved to the back of the parent window Pin
honeyashu10-Aug-09 3:29
honeyashu10-Aug-09 3:29 
QuestionFlash on WebBrowser?? Pin
Muammar©7-Aug-09 22:32
Muammar©7-Aug-09 22:32 
AnswerSolved! Pin
Muammar©7-Aug-09 23:08
Muammar©7-Aug-09 23:08 
QuestionHow do you sort a listBox by number value rather than alphabetically Pin
Nathan Revka7-Aug-09 22:17
Nathan Revka7-Aug-09 22:17 
AnswerRe: How do you sort a listBox by number value rather than alphabetically Pin
Henry Minute8-Aug-09 0:01
Henry Minute8-Aug-09 0:01 
AnswerRe: How do you sort a listBox by number value rather than alphabetically Pin
Moreno Airoldi8-Aug-09 0:03
Moreno Airoldi8-Aug-09 0:03 
AnswerRe: How do you sort a listBox by number value rather than alphabetically [modified] Pin
Luc Pattyn8-Aug-09 0:13
sitebuilderLuc Pattyn8-Aug-09 0:13 
QuestionHow do you sort a listBox by number value rather than alphabetically Pin
Nathan Revka7-Aug-09 22:17
Nathan Revka7-Aug-09 22:17 
QuestionSplit text and Store into Arry List Pin
M Riaz Bashir7-Aug-09 20:28
M Riaz Bashir7-Aug-09 20:28 
AnswerRe: Split text and Store into Arry List Pin
Abhijit Jana7-Aug-09 21:42
professionalAbhijit Jana7-Aug-09 21:42 
GeneralRe: Split text and Store into Arry List Pin
OriginalGriff7-Aug-09 22:04
mveOriginalGriff7-Aug-09 22:04 
GeneralRe: Split text and Store into Arry List Pin
Abhijit Jana7-Aug-09 22:17
professionalAbhijit Jana7-Aug-09 22:17 
AnswerRe: Split text and Store into Arry List Pin
Arindam Sinha7-Aug-09 21:58
Arindam Sinha7-Aug-09 21:58 
AnswerRe: Split text and Store into Arry List Pin
Mycroft Holmes7-Aug-09 22:07
professionalMycroft Holmes7-Aug-09 22:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.