Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to check if a console application is running in full screen mode Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
14-Dec-02
Category
System
Language
Delphi 2.x
Views
159
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas 

I made a console application that at some point needs to know if it's running in a 
window or in full screen mode. I looked at Console API calls, but cannot find 
anything distinctive.

Answer:

The function IsConsoleFullscreen() works fine with W98 and ME, but not with 2000 
(and XP, I presume). The GetConsoleDisplayMode function is also in Win2000 (not 
documented), at least with service pack 1 and up. To get the test to work on both 
series of platforms, you have to use LoadLibrary and GetProcAddress:
1   
2   function IsConsoleFullscreen: Boolean;
3   type
4     TGetConsoleDisplayMode = function(var lpdwMode: DWORD): Boolean; stdcall;
5   var
6     Handle: THandle;
7     DisplayMode: TGetConsoleDisplayMode;
8     W: HWND;
9     PID: Cardinal;
10    R: TRect;
11    CurMode: DWORD;
12    PlatFormXP2000: Boolean;
13  begin
14    Result := False;
15    PlatFormXP2000 := False;
16    Handle := LoadLibrary('kernel32.dll');
17    if Handle <> 0 then
18    begin
19      @DisplayMode := GetProcAddress(Handle, 'GetConsoleDisplayMode');
20      if @DisplayMode <> nil then
21      begin
22        PlatFormXP2000 := DisplayMode(CurMode);
23        if PlatFormXP2000 then
24          Result := (CurMode <> 0);
25      end;
26      FreeLibrary(Handle);
27    end;
28    if not PlatFormXP2000 then
29    begin
30      W := GetForegroundWindow;
31      GetWindowThreadProcessId(W, @PID);
32      if PID <> GetCurrentProcessID then
33        exit;
34      if not IsIconic(W) then
35        exit;
36      GetClientRect(W, R);
37      Result := (R.Right = 0) and (R.Bottom = 0);
38    end;
39  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC