Home » U++ Library support » TopWindow&PopUp, TrayIcon » Is it possible to show a console window in GUI_APP_MAIN?
Re: Is it possible to show a console window in GUI_APP_MAIN? [message #18688 is a reply to message #18680] |
Fri, 17 October 2008 07:52   |
pepe11
Messages: 16 Registered: June 2006 Location: Slovakia
|
Promising Member |

|
|
Hi,
Do you mean GUI + Console in one aplication ?In WIN is it possible. I use it for debuging in real time application(very old aplication). But i do not whether that is implemeted in U++.
#include <wincon.h>
void InitDebugPrintf(char *Format)
{
COORD Size;
InitializeCriticalSection( &Criticalsection );
ConsoleCreated = TRUE;
ConsoleCreated = AllocConsole();
ConsoleScreenBuffer = CreateConsoleScreenBuffer( GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL );
Size.X = 120;
Size.Y = 1024;
SetConsoleScreenBufferSize( ConsoleScreenBuffer, Size );
if( ConsoleScreenBuffer != NULL ) SetConsoleActiveScreenBuffer( ConsoleScreenBuffer );
SetConsoleTitle(Format);
}
void CancelDebugPrintf()
{
DeleteCriticalSection( &Criticalsection );
fclose(stream);
fclose(stream1);
CloseHandle( ConsoleScreenBuffer );
// FreeConsole();
}
void DebugPrintf( unsigned char Type, char *Format, ... )
{
char LocalBuffer[128];
int SizeWritten;
DWORD SizeToWriteToConsole;
va_list ap;
va_start( ap, Format );
if(( SizeWritten = _vsnprintf( LocalBuffer , sizeof( LocalBuffer ), Format, ap )) != -1 )
{
LocalBuffer[sizeof(LocalBuffer)-1] = '\0';
if( ConsoleCreated == FALSE ) InitDebugPrintf("PEPE I");
EnterCriticalSection( &Criticalsection );
if( ConsoleScreenBuffer != NULL )
{
SetConsoleTextAttribute(ConsoleScreenBuffer,FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
WriteConsole( ConsoleScreenBuffer, TEXT(LocalBuffer), SizeToWriteToConsole = SizeWritten, &SizeToWriteToConsole, NULL );
}
LeaveCriticalSection( &Criticalsection );
}
va_end( ap );
}
Pepe
|
|
|
Goto Forum:
Current Time: Sun Aug 17 16:47:38 CEST 2025
Total time taken to generate the page: 0.06003 seconds
|