?
Solved

set a console window to full screen

Posted on 1998-10-05
17
Medium Priority
?
356 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 

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
 
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 800 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

752 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