Solved

set a console window to full screen

Posted on 1998-10-05
17
345 Views
Last Modified: 2013-12-03
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
Comment
Question by:deryckb
  • 5
  • 3
  • 3
  • +5
17 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 1414985
Have you tried simulating the keys with keybd_event?
That should work, but the console application must have the keyboard focus.

Regards, Madshi.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1414986
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
 
LVL 22

Expert Comment

by:nietod
ID: 1414987
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
 

Author Comment

by:deryckb
ID: 1414988
Misunderstood the question.

Additional comment entered.
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1414989
So..... Any luck with Madshi's solution?
0
 

Author Comment

by:deryckb
ID: 1414990
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
 
LVL 15

Expert Comment

by:NickRepin
ID: 1414991
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
 
LVL 10

Expert Comment

by:viktornet
ID: 1414992
How about this???

ShowWindow(TheAppHandle, SW_MAXIMIZED);

Regards,
Viktor Ivanov
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 15

Expert Comment

by:NickRepin
ID: 1414993
See my prev comment. There is an answer for W95/98 also. Undocumented, of course.
0
 

Author Comment

by:deryckb
ID: 1414994
OK, I've raised the ante to 200 points. Spill the beans! :-)

Deryck
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1414995
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
 
LVL 2

Expert Comment

by:avico
ID: 1414996
Have you considered using MAC address ?
0
 
LVL 2

Expert Comment

by:avico
ID: 1414997
Sorry, erase my last comment....
0
 
LVL 22

Expert Comment

by:nietod
ID: 1414998
Mirkwood, I believe that was proposed by NickRepin.
0
 

Author Comment

by:deryckb
ID: 1414999
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
 
LVL 15

Accepted Solution

by:
NickRepin earned 200 total points
ID: 1415000
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
 

Author Comment

by:deryckb
ID: 1415001
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

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now