• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 365
  • Last Modified:

set a console window to full screen

In Win32, how do I change a console application's
window to full screen? i.e. the equivalent of pressing
Alt + Enter.

I'm programming in Delphi if that makes a difference.

Thanks
Deryck Brown
0
deryckb
Asked:
deryckb
  • 5
  • 3
  • 3
  • +5
1 Solution
 
MadshiCommented:
Have you tried simulating the keys with keybd_event?
That should work, but the console application must have the keyboard focus.

Regards, Madshi.
0
 
nietodCommented:
You need to get the handle to the console window.  The only way to do this that I've seen is with FindWindow() (but there may be a better way)
Then use SetWindowPos() on the console window handle.

Ask if you have questions.
0
 
nietodCommented:
Opps.  I missunderstood you.  I thought you meant maximized, but you really do mean full screen.  You can't do that the way I suggested, sorry.   Madshi, idea might be the best you can do, but it does require that the console window have the focus.  You can change the console window to have the focus with SetForegroundWindow()   Note that this always works under win95 and Win NT 4.0.  Supposidly, however, this function no longer gives another application the focus in Windows 98.  However, the console can still make itself the foreground window in windows 98.  

Sorry, reject my answer.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
deryckbAuthor Commented:
Misunderstood the question.

Additional comment entered.
0
 
thresher_sharkCommented:
So..... Any luck with Madshi's solution?
0
 
deryckbAuthor Commented:
I haven't had a chance to try it yet. The HD on my PC
died over the weekend. I came in on Monday and got clunk, clunk,
clunk, clunk,....

I hope to get back to it today or possibly tomorrow.

Many thanks for the suggestions so far!

0
 
NickRepinCommented:
I know the answer for NT. Its undocumented API call to SetConsoleDisplayMode.
To find it, I've wasted about two hours today.
If you are interesting in it, I'll give you it for grade A and 200 points .

Answer for 95 differs from NT one because there is no SetConsoleDisplayMode in 95. It'll cost more (I don't know the answer yet).
0
 
viktornetCommented:
How about this???

ShowWindow(TheAppHandle, SW_MAXIMIZED);

Regards,
Viktor Ivanov
0
 
NickRepinCommented:
See my prev comment. There is an answer for W95/98 also. Undocumented, of course.
0
 
deryckbAuthor Commented:
OK, I've raised the ante to 200 points. Spill the beans! :-)

Deryck
0
 
MirkwoodCommented:
Here is some sample code.
It is function  0463  of kernel32.dll

#include <windows.h>

WINBASEAPI
BOOL
WINAPI
GetConsoleDisplayMode(
    LPDWORD dwConsoleDisplayMode
    );

WINBASEAPI
DWORD
WINAPI
SetConsoleDisplayMode(
    HANDLE hConsoleHandle,
    DWORD dwConsoleDisplayMode,
    LPDWORD dwPreviousDisplayMode
    );

void main(void)
{
      HANDLE      hConsole;
      DWORD            Result;

      AllocConsole();
      hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
      SetConsoleDisplayMode(hConsole, 1, &Result);
};


0
 
avicoCommented:
Have you considered using MAC address ?
0
 
avicoCommented:
Sorry, erase my last comment....
0
 
nietodCommented:
Mirkwood, I believe that was proposed by NickRepin.
0
 
deryckbAuthor Commented:
Mirkwood,

Yes your solution works, but NickRepin proposed this solution first. Therefore, in the interests of fairness, I am "rejecting" your solution to give the points to him.

Sorry!

Deryck
0
 
NickRepinCommented:
Mirkwood was the first, but it seems it's only part of the answer. There is no SetConsoleDisplayMode in Win95 (if I am not wrong).

By the way, in my NT the 0463 in KERNEL32 is GetThreadContext, in Win98 - ReadConsoleInputW.

Here is the sample for Win95/98

#include <windows.h>
#include <conio.h>

void main(void) {
   // Find our console window (may be any other code here)
   char con[120];
   GetConsoleTitle(con,sizeof(con));
   HWND w=FindWindow("tty",con);

   cprintf("Test");
   getch(); // Not necessary - just to test

   // Set full screen mode
   SendMessage(w,WM_COMMAND,57359,0);

   getch(); // Not necessary - just to test
}


0
 
deryckbAuthor Commented:
The Windows NT solution worked for me, but a very big thanks for the 95/98 version too.

I guess alot of people were looking for this information too.

Deryck
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 3
  • 3
  • +5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now