Autor | Thema: Console aus Profan | | Datum:19.09.02 15:42 
(mail@stschnell.de) | |
Hallo Community,
teste gerade mit Consolen-Anwendung aus Profan herum, funktioniert gut, jedoch ist mir dabei aufgefallen, das die Windows.ph noch weitere Fehler enthält:
1. Bei der Funktion AllocConsole() muss hinten das Komma entfernt werden.
2. Bei der Funktion FreeConsole() muss hinten das Komma entfernt werden.
Jetzt noch einen Rumpf zum experimentieren mit Consolen-Anwendungen aus Profan:
$H Windows.ph
$H Structs.ph
Declare Buffer#
Dim Buffer#, 64
Declare hConsole&, bytesWritten&
~AllocConsole()
hConsole& = ~GetStdHandle(~STD_OUTPUT_HANDLE)
String Buffer#, 0 = "Hello World" + @Chr$(13) + @Chr$(10) + "Hello Stefan"
~WriteConsole(hConsole&, Buffer#, 25, @Addr(bytesWritten&), 0)
Sleep 1000
Dispose Buffer#
~FreeConsole()
End
Viel Spass noch, tschüss
Stefan
|
| | Datum: 24.09.02 22:26 
(mail@stschnell.de) | |
Hallo Community,
ConsoleApplications scheinen nicht besonders hoch im Kurs zu stehen, nun denn, folgende Ergänzung in der Windows.ph ist mir noch aufgefallen:
Die Konstante CONSOLE_TEXTMODE_BUFFER fehlt, mit folgendem Eintrag kann sie ergänzt werden
CONSOLE_TEXTMODE_BUFFER = 1;
(Hier nochmal Dank an Gerhard Putschalka, in seiner API - Equates ist die Konstante vorhanden!)
Habe das vorherige Beispielprogramm noch etwas erweitert hat im Augenblick folgenden Stand:
$H Windows.ph
$H Structs.ph
Proc Halt
Parameters ErrorCode%, ErrorMessage$
@MessageBox(ErrorMessage$, "Error " + @Str$(ErrorCode%), 48)
End
EndProc
Declare Buffer#
Dim Buffer#, 64
Declare hOutput&, WindowTitle$, bytesWritten&
IfNot ~AllocConsole()
Halt 1, "Unable to allocate console, LastError: " + @Str$(~GetLastError())
EndIf
hOutput& = ~CreateConsoleScreenBuffer(~Generic_Read + ~Generic_Write, 0, 0, \
~Console_Textmode_Buffer, 0)
If hOutput& = ~Invalid_Handle_Value
Halt 2, "Unable to create console, LastError: " + @Str$(~GetLastError())
EndIf
If ~SetConsoleActiveScreenBuffer(hOutput&) = 0
Halt 3, "Unable to set active console, LastError: " + @Str$(~GetLastError())
EndIf
WindowTitle$ = "32-bit Console Application" + @Chr$(0)
If ~SetConsoleTitle(@Addr(WindowTitle$)) = 0
@MessageBox("Unable to set console title" + @Str$(~GetLastError()), "Error", 48)
EndIf
String Buffer#, 0 = "Hello World" + @Chr$(13) + @Chr$(10) + "Hello Stefan"
~WriteConsole(hOutput&, Buffer#, 25, @Addr(bytesWritten&), 0)
Sleep 2000
Dispose Buffer#
IfNot ~FreeConsole()
Halt 6, "Unable to free console, LastError: " + @Str$(~GetLastError())
EndIf
End
Denke gerade daran, Funktionen wie ClrScr oder Low- bzw. HighVideo (des alten Pascal-Herz erfreut sich dieser Worte) via Profan für eine Console abzubilden.
Tschüss
Stefan
|
|
|