locked
Window form contain picture box and status strip as well as a menu strip, the status strip not shown during run the application RRS feed

  • Question

  • Hi,

    I have a window form and window state maximize.

    The window form contain menu strip at the top and status strip at the bottom (anchor top and left and Dock at bottom).

    The window form contain picture box at full size of window form (except the status strip and menu strip) and anchor top+bottom+left+right.

    The problem is that the status strip is not shown during run the application, that window task bar is cover the status strip and when I make the window task bar is Auto Hide, then I see the status strip in the bottom.

    How to make the status strip shown even the window task bar is not Auto hide?

    Kind Regards,



    Hany Metry


    • Edited by Morgan Mosa Wednesday, April 8, 2020 10:29 AM
    Wednesday, April 8, 2020 10:25 AM

All replies

  • using System;
    using System.Text;
    using System.Windows.Forms;

    namespace WindowsApplication4
    {
        public class Form1 : Form
        {
            private StatusStrip statusStrip1;
            private ToolStripStatusLabel toolStripStatusLabel1;
        
            public Form1()
            {
                InitializeComponent();
            }
            [STAThread]
            static void Main()
            {
                Application.EnableVisualStyles();
                Application.Run(new Form1());
            }

            private void InitializeComponent()
            {
                statusStrip1 = new System.Windows.Forms.StatusStrip();
                toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
                statusStrip1.SuspendLayout();
                SuspendLayout();
                // 
                // The following code example demonstrates the syntax for setting
                // various StatusStrip properties.
                statusStrip1.Dock = System.Windows.Forms.DockStyle.Top;
                statusStrip1.GripStyle = System.Windows.Forms.ToolStripGripStyle.Visible;
                statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                toolStripStatusLabel1});
                statusStrip1.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.HorizontalStackWithOverflow;
                statusStrip1.Location = new System.Drawing.Point(0, 0);
                statusStrip1.Name = "statusStrip1";
                statusStrip1.ShowItemToolTips = true;
                statusStrip1.Size = new System.Drawing.Size(292, 22);
                statusStrip1.SizingGrip = false;
                statusStrip1.Stretch = false;
                statusStrip1.TabIndex = 0;
                statusStrip1.Text = "statusStrip1";
                // 
                // toolStripStatusLabel1
                // 
                toolStripStatusLabel1.Name = "toolStripStatusLabel1";
                toolStripStatusLabel1.Size = new System.Drawing.Size(109, 17);
                toolStripStatusLabel1.Text = "toolStripStatusLabel1";
                // 
                // Form1
                // 
                ClientSize = new System.Drawing.Size(292, 273);
                Controls.Add(statusStrip1);
                Name = "Form1";
                statusStrip1.ResumeLayout(false);
                statusStrip1.PerformLayout();
                ResumeLayout(false);
                PerformLayout();
            }
        }
    }
    Wednesday, April 8, 2020 10:36 AM
  • @Max-44, we don't accept C# code here in this forum. Either modify to VB.NET or I will remove your reply shortly.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Wednesday, April 8, 2020 10:44 AM
  • Hi Max-44

    Is the above in visual basic language? I don't under stand any language except visual basic.


    Hany Metry

    Wednesday, April 8, 2020 10:47 AM
  • Hello,

    See my code sample done in VS2012 but works in all versions newer e.g. VS2013 thru VS2019.

    The base code

    Module FormExtensions
        Private Declare Function SetWindowPos Lib "user32.dll" _
            Alias "SetWindowPos" (ByVal hWnd As IntPtr,
                                  ByVal hWndIntertAfter As IntPtr,
                                  ByVal X As Integer,
                                  ByVal Y As Integer,
                                  ByVal cx As Integer,
                                  ByVal cy As Integer,
                                  ByVal uFlags As Integer) As Boolean
    
        Private HWND_TOP As IntPtr = IntPtr.Zero
        Private Const SWP_SHOWWINDOW As Integer = 64
    
        ''' <summary>
        ''' Place form into full screen
        ''' </summary>
        ''' <param name="sender"></param>
        ''' <param name="TaskBar">True to hide Windows TaskBar</param>
        ''' <remarks></remarks>
        <System.Runtime.CompilerServices.Extension()> _
        Public Sub FullScreen(ByVal sender As Form, ByVal TaskBar As Boolean)
    
            sender.WindowState = FormWindowState.Maximized
            sender.FormBorderStyle = FormBorderStyle.None
            sender.TopMost = True
    
            If TaskBar Then
    
                SetWindowPos(sender.Handle, HWND_TOP, 0, 0,
                             Screen.PrimaryScreen.Bounds.Width,
                             Screen.PrimaryScreen.Bounds.Height,
                             SWP_SHOWWINDOW _
                )
    
            End If
    
        End Sub
        ''' <summary>
        ''' Maximize window
        ''' </summary>
        ''' <param name="sender"></param>
        ''' <remarks></remarks>
        <System.Runtime.CompilerServices.Extension()> _
        Public Sub normalScreen(ByVal sender As Form)
    
            sender.WindowState = FormWindowState.Maximized
            sender.FormBorderStyle = FormBorderStyle.FixedDialog
            sender.TopMost = True
    
        End Sub
        ''' <summary>
        ''' Restore to original size/position
        ''' </summary>
        ''' <param name="sender"></param>
        ''' <remarks></remarks>
        <System.Runtime.CompilerServices.Extension()> _
        Public Sub NormalMode(ByVal sender As Form)
            sender.WindowState = FormWindowState.Normal
            sender.FormBorderStyle = FormBorderStyle.FixedSingle
            sender.TopMost = True
        End Sub
    End Module
    
    Form code in link above and you will need to tweak that code when form is max'd.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Wednesday, April 8, 2020 10:51 AM
  • Hello,

    See my code sample done in VS2012 but works in all versions newer e.g. VS2013 thru VS2019.

    The base code

    Module FormExtensions
        Private Declare Function SetWindowPos Lib "user32.dll" _
            Alias "SetWindowPos" (ByVal hWnd As IntPtr,
                                  ByVal hWndIntertAfter As IntPtr,
                                  ByVal X As Integer,
                                  ByVal Y As Integer,
                                  ByVal cx As Integer,
                                  ByVal cy As Integer,
                                  ByVal uFlags As Integer) As Boolean
    
        Private HWND_TOP As IntPtr = IntPtr.Zero
        Private Const SWP_SHOWWINDOW As Integer = 64
    
        ''' <summary>
        ''' Place form into full screen
        ''' </summary>
        ''' <param name="sender"></param>
        ''' <param name="TaskBar">True to hide Windows TaskBar</param>
        ''' <remarks></remarks>
        <System.Runtime.CompilerServices.Extension()> _
        Public Sub FullScreen(ByVal sender As Form, ByVal TaskBar As Boolean)
    
            sender.WindowState = FormWindowState.Maximized
            sender.FormBorderStyle = FormBorderStyle.None
            sender.TopMost = True
    
            If TaskBar Then
    
                SetWindowPos(sender.Handle, HWND_TOP, 0, 0,
                             Screen.PrimaryScreen.Bounds.Width,
                             Screen.PrimaryScreen.Bounds.Height,
                             SWP_SHOWWINDOW _
                )
    
            End If
    
        End Sub
        ''' <summary>
        ''' Maximize window
        ''' </summary>
        ''' <param name="sender"></param>
        ''' <remarks></remarks>
        <System.Runtime.CompilerServices.Extension()> _
        Public Sub normalScreen(ByVal sender As Form)
    
            sender.WindowState = FormWindowState.Maximized
            sender.FormBorderStyle = FormBorderStyle.FixedDialog
            sender.TopMost = True
    
        End Sub
        ''' <summary>
        ''' Restore to original size/position
        ''' </summary>
        ''' <param name="sender"></param>
        ''' <remarks></remarks>
        <System.Runtime.CompilerServices.Extension()> _
        Public Sub NormalMode(ByVal sender As Form)
            sender.WindowState = FormWindowState.Normal
            sender.FormBorderStyle = FormBorderStyle.FixedSingle
            sender.TopMost = True
        End Sub
    End Module
    Form code in link above and you will need to tweak that code when form is max'd.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Hi Karen,

    Really, I am not understand the code.

    Where is the code shall be written?

    It shall be written in the existing module or new module.

    The code are not include any specific code for the required window form?

    Kind Regards,


    Hany Metry

    Wednesday, April 8, 2020 11:17 AM

  • Hi Karen,

    Really, I am not understand the code.

    Where is the code shall be written?

    It shall be written in the existing module or new module.

    The code are not include any specific code for the required window form?

    Kind Regards,


    Hany Metry

    Then download the code from the link I provided. It's simple

    Public Class Form1
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            FullScreen(False) ' show task bar, remove False to cover task bar
        End Sub
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            NormalMode()
        End Sub
    End Class


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Wednesday, April 8, 2020 3:00 PM
  • Hi Karen,

    Temporally, I will increase the size of window form till be nearly equal full size minus window task bar but that is not the actual answer which i am searching for but it good enough especially that I am not understand your intentionally secret reply.

    Kind Regards,  


    Hany Metry

    Wednesday, April 8, 2020 5:17 PM
  • Hi Karen,

    Temporally, I will increase the size of window form till be nearly equal full size minus window task bar but that is not the actual answer which i am searching for but it good enough especially that I am not understand your intentionally secret reply.

    Kind Regards,  


    Hany Metry

    Hello, not sure what you mean by secret reply, I provided a complete code sample via a link in my first reply then in my second reply mentioned the link from my first reply.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Wednesday, April 8, 2020 5:22 PM
  • Hi Karen,

    Temporally, I will increase the size of window form till be nearly equal full size minus window task bar but that is not the actual answer which i am searching for but it good enough especially that I am not understand your intentionally secret reply.

    Kind Regards,  


    Hany Metry

    Hello, not sure what you mean by secret reply, I provided a complete code sample via a link in my first reply then in my second reply mentioned the link from my first reply.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Hi,

    Sorry I was not saw the link because it look like Paragraph head, Sorry again.

    Kind Regards,


    Hany Metry


    • Edited by Morgan Mosa Thursday, April 9, 2020 5:30 AM
    Thursday, April 9, 2020 4:08 AM
  • Hi Hany Metry,

    >>The problem is that the status strip is not shown during run the application, that window task bar is cover the status strip and when I make the window task bar is Auto Hide

    Could you provide more related code about your question? It will help us to analyze your problem and make a test.

    We are waiting for your update.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, April 9, 2020 6:20 AM
  • Hi,

    I did not face this problem before that, I produced many applications with visual studio 2013 and window 7 and always the start form shown complete with status bar and the window task bar is shown complete.

    I don't know what happened in my visual studio 2013 or window 7.

    The status bar is not shown and it is behind the window task bar and when I make the window task bar Auto Hide, then the status bar is shown.

    Many applications, I did not face this problem.

    How I can solve this problem, I need status bar to be shown and window task bar, Also shown.

    Kind Regards,


     


    Hany Metry



    • Edited by Morgan Mosa Saturday, May 16, 2020 11:03 AM
    Saturday, May 16, 2020 10:31 AM