none
Console application maximize RRS feed

  • Question

  • Making a console application in Visual Basic and want it to run in full screen when it loads, can anyone help me out?
    Friday, May 12, 2017 10:44 AM

All replies

  • For example =>

    Imports System.Runtime.InteropServices
    Module Module1
        <DllImport("kernel32.dll", ExactSpelling:=True)>
        Private Function GetConsoleWindow() As IntPtr
        End Function
        Private Const SW_SHOWMAXIMIZED As Integer = 3
        <DllImport("user32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
        Private Function ShowWindow(hWnd As IntPtr, nCmdShow As Integer) As Boolean
        End Function
    
        Sub Main(args As String())
            ShowWindow(GetConsoleWindow(), SW_SHOWMAXIMIZED)
            Console.ReadLine()
        End Sub
    End Module

    • Proposed as answer by Cor Ligthert Friday, May 12, 2017 12:02 PM
    Friday, May 12, 2017 11:13 AM
  • Castorix,

    Nice, do you have any problem if I put this on our website? 

    (with your name of course)


    Success
    Cor

    Friday, May 12, 2017 12:03 PM
  • Nice, do you have any problem if I put this on our website? 


    Of course, nothing "revolutionary" I think :-)


    Friday, May 12, 2017 4:00 PM
  • Done, 

    http://www.vb-tips.com/FullScreenConsoleApp.ASPX

    (if you're a woman than tell it please, then I change it and remove this message)


    Success
    Cor

    Friday, May 12, 2017 6:56 PM
  • Hi ZattamZ,

    In addition to Castorix31's response, you can also try the code below.

    Imports System.Runtime.InteropServices
    
    Module Module1
        <DllImport("kernel32.dll", ExactSpelling:=True)>
        Private Function GetConsoleWindow() As IntPtr
        End Function
        Private ThisConsole As IntPtr = GetConsoleWindow()
    
    
        <DllImport("user32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
        Private Function ShowWindow(hWnd As IntPtr, nCmdShow As Integer) As Boolean
        End Function
        Private Const HIDE As Integer = 0
        Private Const MAXIMIZE As Integer = 3
        Private Const MINIMIZE As Integer = 6
        Private Const RESTORE As Integer = 9
    
        Sub Main()
            ShowWindow(ThisConsole, MAXIMIZE)
            Console.ReadKey()
    
        End Sub
    
    End Module

    Best Regards,

    Cherry


    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.

    Monday, May 15, 2017 9:09 AM
    Moderator