Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3672276
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:35:20+00:00 2026-05-19T02:35:20+00:00

I need to make a winform full screen. This is what i found online.

  • 0

I need to make a winform full screen. This is what i found online.

1. Hook WinProc to catch WM_SYSCOMMAND

2. Check wParam == SC_MAXIMIZE and then

3. Set my windiw's attributes

Me.ResizeMode = ResizeMode.NoResize

Me.WindowStyle = WindowStyle.None

Me.WindowState = WindowState.Maximized

I am fairly new to vb.net and do not know how to do Steps 1 or 2. Can someone give me a snippet or point me in the right direction?

Thanks giodamelio

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T02:35:21+00:00Added an answer on May 19, 2026 at 2:35 am

    The trick is to obtain the HwndSource and call its AddHook() method. This works:

    Imports System.Windows.Interop
    
    Class Window1
        Protected Overrides Sub OnSourceInitialized(ByVal e As System.EventArgs)
            MyBase.OnSourceInitialized(e)
            DirectCast(PresentationSource.FromVisual(Me), HwndSource).AddHook(AddressOf WndProc)
        End Sub
    
        Private Const WM_SYSCOMMAND As Integer = &H112
        Private Const SC_MAXIMIZE As Integer = &HF030
    
        Private Function WndProc(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wp As IntPtr, ByVal lp As IntPtr, ByRef handled As Boolean) As IntPtr
            If msg = WM_SYSCOMMAND AndAlso wp.ToInt32() = SC_MAXIMIZE Then
                Me.ResizeMode = ResizeMode.NoResize
                Me.WindowStyle = WindowStyle.None
                Me.WindowState = WindowState.Maximized
                handled = True
            End If
        End Function
    
    End Class
    

    The same code for a Winforms Form:

    Public Class Form1
        Private Const WM_SYSCOMMAND As Integer = &H112
        Private Const SC_MAXIMIZE As Integer = &HF030
    
        Protected Overrides Sub WndProc(ByRef m As Message)
            If m.Msg = WM_SYSCOMMAND AndAlso m.WParam.ToInt32() = SC_MAXIMIZE Then
                Me.FormBorderStyle = FormBorderStyle.None
                Me.WindowState = FormWindowState.Maximized
                Return
            End If
            MyBase.WndProc(m)
        End Sub
    
        Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
            '' Restore window when the user presses Escape
            If Me.WindowState = FormWindowState.Maximized AndAlso keyData = Keys.Escape Then
                Me.FormBorderStyle = Windows.Forms.FormBorderStyle.Sizable
                Me.WindowState = FormWindowState.Normal
            End If
            Return MyBase.ProcessCmdKey(msg, keyData)
        End Function
    
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a solution how could i make a Print Screen of my WinForm
I need to make a webform communicate with a winform and back to the
I need to make this function work everywhere, except IE6-7 $(function(){ window.scrollTo(0,300); }) Please
I need to make a WinForm of mine flash to alert the user, and
I have a WinForms app that I am trying to make full screen (somewhat
I need to make a div layer so that when you click on it
i need to make my window top level when i need. Code of creating
I need to make a column unique in one of our database tables, and
I need to make a proxy script that can access a page hidden behind
I need to make some changes to an old Oracle stored procedure on an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.