News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Full screen consoles?

Started by QvasiModo, February 09, 2006, 07:55:57 PM

Previous topic - Next topic

QvasiModo

A quick question, how do I programatically set a console in full screen mode? I've been looking at the console functions at MSDN, but found nothing of interest there.

QvasiModo

Mhm, this turned up at Google:

http://www.sunlightd.com/Windows/FAQ.html#ConsoleFullScreen

QuoteCan I make a console window start up full screen programmatically?

No. There is currently no documented way to switch between windowed and full-screen mode in console applications.

I guess I'll have to try sending Alt+Enter to the console window. :(

farrier

QvasiModo,

If you can launch from a batch file, try this line before launching your program:

mode con lines=25
MyProgramName


hth,

farrier
It is a GOOD day to code!
Some assembly required!
ASM me!
With every mistake, we must surely be learning. (George...Bush)

Casper

It does not work on XP using cmd or command

Casper.

MichaelW

#4
This works under Windows 2000:

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc

    CONSOLE_FULLSCREEN_MODE EQU 1
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .data
       pSetConsoleDisplayMode dd 0
       coord                  COORD <>
       x81                    db 81 dup ('x'),0
    .code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    invoke GetModuleHandle,chr$("kernel32.dll")
    invoke GetProcAddress,eax,chr$("SetConsoleScreenBufferInfoEx")
    print ustr$(eax),13,10
   
    invoke GetModuleHandle,chr$("kernel32.dll")
    invoke GetProcAddress,eax,chr$("SetConsoleDisplayMode")
    mov   pSetConsoleDisplayMode, eax
    push  OFFSET coord       
    push  CONSOLE_FULLSCREEN_MODE
    invoke GetStdHandle,STD_OUTPUT_HANDLE
    push  eax
    call  pSetConsoleDisplayMode

    movzx eax, coord.x
    print ustr$(eax),"x"
    movzx eax, coord.y
    print ustr$(eax),13,10

    print ADDR x81,13,10
    mov   ebx, 4
    REPEAT 45
      inc   ebx
      print ustr$(ebx),13,10
    ENDM
   
    inkey "Press any key to exit..."
    exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start


Per this MSDN page SetConsoleDisplayMode requires Windows XP or later. Perhaps it was simply undocumented for previous versions of Windows. I don't have any way to test under Windows 9x.

EDIT:

I screwed up on the code and passed the COORD value instead of the address. I have now corrected the problem and added some other details. On my system (running Windows 2000) the return value for coord.x is 65404, the return value for coord.y is 18, and the size of the screen in characters is 80x50. So I don't know whether there is a problem with the documentation, or the version of kernel32.dll on my system.

There is also a new function SetConsoleScreenBufferInfoEx which is not present in the version of kernel32.dll on my system.

eschew obfuscation

farrier

Casper,

If your post was directed at my post:
From a batch file, it does!  You usually have to set the Properties to set the app to run in a Maximized window.

MichaelW shows the better way, originally in:

http://www.masmforum.com/simple/index.php?topic=1696.0

farrier
It is a GOOD day to code!
Some assembly required!
ASM me!
With every mistake, we must surely be learning. (George...Bush)

Mincho Georgiev

Yes, requires Windows XP or later, and maybe will be a good idea to be added as regular WinAPI ,not a underground one like now:



[attachment deleted by admin]

Mincho Georgiev

I'm sorry Michael, i didn't saw what you've posted already  :'(

P1

You can also change the mode by setting the proper values in the registry ( Done before starting your app. ), so that the default mode is FullScreen and 80X25.

Regards,  P1  :8)

zooba

It's generally a bad idea in UI terms to force the user to forfeit their entire screen to your program - hence the PIF option and the Alt-Enter shortcut. However, no rule is unbreakable if your reasoning is good enough :U :bg

MichaelW

Quote from: farrier on February 09, 2006, 11:37:55 PM
MichaelW shows the better way, originally in:

http://www.masmforum.com/simple/index.php?topic=1696.0

The app I posted in that topic maximizes the console window (or at least that is what it does on my system).

eschew obfuscation

QvasiModo

Wow, tons of info, thanks a lot guys! :U

I also asked a friend about this and he gave me this link:
http://www.gametutorials.com/forum/topic.asp?ARCHIVE=true&TOPIC_ID=11870

This line does the trick:
SendMessage( hWndConsole, WM_SYSKEYDOWN, VK_RETURN, 0x20000000 );

Still the SetConsoleDisplayMode method is the best, I'll check out if it existed in NT as well as 2K.