ERLEDIGT
NEIN
NEIN
ANTWORTEN
2
2
ZUGRIFFE
1820
1820
EMPFEHLEN
-
Borland Builder 6 C++
Ich würde gerne für mein Windowsprogramm eine Konsole öffnen, um mir Meldungen ausgeben zu lassen.
Ich hab das auch schon in meine Programm eingebaut, dank dieser Anleitung:
source: http://dslweb.nwnexus.com/~ast/dload/guicon.htm
Das hier ist also meine Funktion um die Ausgabestreams umzubiegen:
(Ich hab die Funktion zum Testen jetzt mal ins Hauptprogramm eingebaut, weil
es als Include nicht funktioniert hat.)
Code :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
--[ Testprogramm]--------------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Unit1.h" #include "IGL.h" #include "IGL3D.h" #include <fcntl.h> // osfhandle #include <io.h> // osfhandle #include <iostream> #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; void RedirectIOToConsole() { int hConHandle; long lStdHandle; CONSOLE_SCREEN_BUFFER_INFO coninfo; FILE *fp; // allocate a console for this app AllocConsole(); // set the screen buffer to be big enough to let us scroll text GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE),&coninfo); coninfo.dwSize.Y = 500; SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE),coninfo.dwSize); // redirect unbuffered STDOUT to the console lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE); hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); fp = _fdopen( hConHandle, "w" ); *stdout = *fp; setvbuf( stdout, NULL, _IONBF, 0 ); // redirect unbuffered STDERR to the console lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE); hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); fp = _fdopen( hConHandle, "w" ); *stderr = *fp; setvbuf( stderr, NULL, _IONBF, 0 ); // make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog // point to console as well ios::sync_with_stdio(); } Beim Starten des Programms wird die Initialisierung ausgeführt: void __fastcall TForm1::FormActivate(TObject *Sender) { RedirectIOToConsole(); wcout << L"xxx"<< endl; wcout << "xxx" << endl; } Und im Programm rufe ich dann diese Funktionen zum Schreiben in das Konsolenfenster auf: void RedrawAll() { wcout << L"Test output to wcerr" << endl; wclog << L"Test output to wclog" << endl; }
Soweit so gut. Mein Programm läuft und das Konsolenfenster öffnet sich.
Nur leider erscheint keine meiner Ausgaben in dem Konsolenfenster.
Hat irgendjemand eine Idee woran das liegen könnte?
Vielen Dank.
-
Ich hab jetzt mal nur das Demo von http://dslweb.nwnexus.com/~ast/dload/guicon.htm
in Borland Builder versucht, aber nicht einmal das funktioniert.
Hat jemand das Demo schon einmal zum Laufen gebracht?
-
Berichtigung: Es funktioniert zum Teil. Das umbiegen von STDIN hat funktioniert, wie ich grad überprüft habe, aber dieses fuc***** Stdout und Stderr funktioniert vielleicht, aber das juckt die Konsole von Windows einen Dreck.
Windows zeigt sich in keiner Weise angesprochen mir das, was ich in STDOUT schreibe, in der Konsole auch anzuzeigen
Ähnliche Themen
-
[C++/Winapi] Programm wird nur im Debug-Modus angezeigt, warum?
Von posi90 im Forum C/C++Antworten: 2Letzter Beitrag: 20.10.10, 20:57 -
TCP/IP WIN32 Konsole-Chat
Von 3Cyb3r im Forum C/C++Antworten: 0Letzter Beitrag: 16.07.08, 17:51 -
Win32 API ->Konsole
Von elfvyn im Forum C/C++Antworten: 13Letzter Beitrag: 08.07.05, 15:57 -
[winAPI] Konsole für Debug-Ausgabe
Von uhu01 im Forum C/C++Antworten: 4Letzter Beitrag: 23.04.05, 20:57 -
Farbe für Win32 Konsole...
Von dark_game im Forum C/C++Antworten: 6Letzter Beitrag: 30.12.04, 09:59





Zitieren
Login






