Autor Beitrag
Popov
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1655
Erhaltene Danke: 13

WinXP Prof.
Bei Kleinigkeiten D3Pro, bei größeren Sachen D6Pro oder D7
BeitragVerfasst: Mi 12.03.03 13:58 
Ich schreibe gerade an einem Konsolenprogramm und würde follgendes gerne einstellen:

1. Das Konsollenprogramm im Vollbild starten (oder umschalten). Das ist aber nicht das gleiche wie wsMaximized, sondern Dos Vollbild

2. Ich möchte die Hintergrundfarbe einstellen (also nicht schwarz, sondern sonstwas)

3. Ich möchte die Schriftfarbe einstellen

4. Ich möchte an einer bestimmten Stelle schreiben (also kein WriteLn, sonder eine Art GoToXY)

5. Bildschirm löschen


Ich glaube nicht, daß diese Möglichkeiten in Delphi angeboten werden. Auch wenn ich das eine der andere mit einen Trick machen könnte, so bleiben immer noch die Farben und das Vollbild.

_________________
Popov
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 12.03.03 14:03 
Kein Problem (zu mindest für die Win-Konsole):
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
(****************************************************************
 ****************************************************************
 ***                                                          ***
 ***        Copyright (c) 2001 by -=Assarbad [GoP]=-          ***
 ***       ____________                 ___________           ***
 ***      /\   ________\               /\   _____  \          ***
 ***     /  \  \       /    __________/  \  \    \  \         ***
 ***     \   \  \   __/___ /\   _____  \  \  \____\  \        ***
 ***      \   \  \ /\___  \  \  \    \  \  \   _______\       ***
 ***       \   \  \ /   \  \  \  \    \  \  \  \      /       ***
 ***        \   \  \_____\  \  \  \____\  \  \  \____/        ***
 ***         \   \___________\  \__________\  \__\            ***
 ***          \  /           /  /          /  /  /            ***
 ***           \/___________/ \/__________/ \/__/             ***
 ***                                                          ***
 ***  May the source be with you, stranger ... :-)            ***
 ***                                                          ***
 ***  Greets from -=Assarbad [GoP]=- ...                      ***
 ***  Special greets go 2 Nico, Casper, SA, Pizza, Navarion...***
 ***[for questions/proposals drop a mail to Assarbad@ePost.de]***
 *****************************************ASCII by Assa [GoP]****
 ****************************************************************)

//include file for console management
var
  SoundFrequency: Integer;

function textattribute: word;
var
  csbi: _CONSOLE_SCREEN_BUFFER_INFO;
begin
  if getconsolescreenbufferinfo(getstdhandle(STD_OUTPUT_HANDLE), csbi) then
    result := csbi.wAttributes else
    result := 0;
end;

procedure settextattribute(attr: word);
begin
  setconsoletextattribute(getstdhandle(STD_OUTPUT_HANDLE), attr);
end;

procedure ClrEol;
var
  tC: tCoord;
  Len, Nw: Cardinal;
  Cbi: TConsoleScreenBufferInfo;
begin
  GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), cbi);
  len := cbi.dwsize.x - cbi.dwcursorposition.x;
  tc.x := cbi.dwcursorposition.x;
  tc.y := cbi.dwcursorposition.y;
  FillConsoleOutputAttribute(GetStdHandle(STD_OUTPUT_HANDLE), textattribute, len, tc, nw);
  FillConsoleOutputCharacter(GetStdHandle(STD_OUTPUT_HANDLE), #32, len, tc, nw);
end;

procedure ClrScr;
var
  tc: tcoord;
  nw: Cardinal;
  cbi: TConsoleScreenBufferInfo;
begin
  getConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), cbi);
  tc.x := 0;
  tc.y := 0;
  FillConsoleOutputAttribute(GetStdHandle(STD_OUTPUT_HANDLE), textattribute, cbi.dwsize.x * cbi.dwsize.y, tc, nw);
  FillConsoleOutputCharacter(GetStdHandle(STD_OUTPUT_HANDLE), #32, cbi.dwsize.x * cbi.dwsize.y, tc, nw);
  setConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), tc);
end;

function WhereX: integer;
var
  cbi: TConsoleScreenBufferInfo;
begin
  getConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), cbi);
  result := tcoord(cbi.dwCursorPosition).x + 1
end;

function WhereY: integer;
var
  cbi: TConsoleScreenBufferInfo;
begin
  getConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), cbi);
  result := tcoord(cbi.dwCursorPosition).y + 1
end;

procedure GotoXY(const x, y: integer);
var
  coord: tcoord;
begin
  coord.x := x - 1;
  coord.y := y - 1;
  setConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
end;

procedure FlushInputBuffer;
begin
  FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE))
end;

function keypressed: boolean;
var
  NumberOfEvents: Cardinal;
begin
  GetNumberOfConsoleInputEvents(GetStdHandle(STD_INPUT_HANDLE), NumberOfEvents);
  result := NumberOfEvents > 0;
end;

function ReadKey: Char;
var
  NumRead: Cardinal;
  InputRec: TInputRecord;
begin
  while ((not ReadConsoleInput(GetStdHandle(STD_INPUT_HANDLE), InputRec, 1, NumRead)) or (InputRec.EventType <> KEY_EVENT)) do ;
  Result := InputRec.Event.KeyEvent.AsciiChar;
end;

procedure Sound(Freq, duration: Cardinal);
begin
  soundfrequency := freq;
  windows.beep(Freq, duration);
end;

procedure NoSound;
begin
  windows.beep(SoundFrequency, 0);
end;

procedure ConsoleEnd;
begin
  if isconsole then begin
    if wherex > 1 then writeln;
    settextattribute(FOREGROUND_GREEN or FOREGROUND_INTENSITY);
    setfocus(GetCurrentProcess);
    write('Press any key to continue.');
    FlushInputBuffer;
    ReadKey;
    FlushInputBuffer;
  end;
end;

Von wem das ist, ist klar oder?

Müßte auch in meiner Toolbox auf meiner Seite drin sein.