Can anyone please tell me how you switch the scope of the console
window between foreground and backgrounnd (top/bottom) of the Desktop
in W9x ?
The following program behaves as expected, but _mostly_ the GRX window
opens behind the console window (sometimes invisible) and scope doesn't
fall back to the console when closing the GRX window. Quite annoying.
______________
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <windows.h>
#include <grx20.h>
#include <grxkeys.h>
//macro to indicate that we have a GRX graphics window
#define GRX_WIN { \
GrGraphicsMode _gm=GrCurrentMode(); \
volatile int _gm_win; \
\
switch(_gm) \
{ \
case GR_80_25_text: \
case GR_default_text: \
case GR_width_height_text: \
case GR_biggest_text: \
case GR_width_height_color_text: \
case GR_width_height_bpp_text: \
case GR_NC_80_25_text: \
case GR_NC_default_text: \
case GR_NC_width_height_text: \
case GR_NC_biggest_text: \
case GR_NC_width_height_color_text: \
case GR_NC_width_height_bpp_text: \
(_gm_win=0); \
break; \
default: \
(_gm_win=1); \
} \
(_gm=_gm_win); \
}
#define kbhit() ((GRX_WIN)?(GrKeyPressed()):(_kbhit()))
#define getch() ((GRX_WIN)?(GrKeyRead() ):(_getch()))
//this allows us to use kbhit() and getch() from within
//a GRX window with the keyboard events disabled.
char * grx_ver(void)
{
static char ver[200];
static char *os[10];
static char osb[10];
char *osbp=osb;
os[GRX_VERSION_TCC_8086_DOS ]="TURBO C";
os[GRX_VERSION_GCC_386_DJGPP ]="DJGPPv2";
os[GRX_VERSION_GCC_386_LINUX ]="LINUX";
os[GRX_VERSION_GENERIC_X11 ]="X11";
os[GRX_VERSION_WATCOM_DOS4GW ]="Watcom32";
os[GRX_VERSION_GCC_386_WIN32 ]="Mingw32";
sprintf(ver,"%s -- GRX Version ",os[GrGetLibrarySystem()]);
sprintf(osb,"%X",GrGetLibraryVersion());
while(*osbp)
{
sprintf(ver+strlen(ver),"%c",*osbp);
if(*(++osbp))
sprintf(ver+strlen(ver),".");
}
sprintf(ver+strlen(ver)," -- GCC Version
%d.%d",__GNUC__,__GNUC_MINOR__);
return ver;
}
int GRXMain() //int argc, char **argv)
{
int x=100,y=200;
Beep(400,500);
//Console
GrSetMode(GR_80_25_text); //close default GRX
window
printf("%s%s\n\n","Hello World\n",grx_ver()); //output to console
window
printf("Hit Any Key\n"); //output to console
window
getch(); //input from console
window
//reopen GRX window
GrSetMode(GR_width_height_bpp_graphics,800,600,24);
GrSetWindowTitle(grx_ver());
GrTextXY(x,y,"Hit any Key",GrWhite(),GrBlack()); //text output to GRX
window
getch(); //input from GRX
window
//Console
GrSetMode(GR_80_25_text); //close GRX window
fprintf(stdout,"%s\n","Bye World\n"); //output to console
window
printf("Hit Any Key\n"); //output to console
window
getch(); //input from console
window
exit(EXIT_SUCCESS);
}
_______
Sorry for the lengthy snippet, but somebody might like to reuse it.
Any suggestions or comments were highly appreciated.
Thank you.
--
Gruss Waldemar Schultz.
Technische Universität München, Zentrum Mathematik M1, D 80290 München
Tel: +49 (0)89 2892 8226 FAX: +49 (0)89 2892 8228