Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

tgraph.c

Go to the documentation of this file.
00001 /* 00002 * Copyright (c) 1985 - 1999, Microsoft Corporation 00003 */ 00004 00005 #include "precomp.h" 00006 #pragma hdrstop 00007 #pragma hdrstop 00008 #define FOREGROUND_WHITE (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED) 00009 00010 00011 typedef struct _BITMAPINFOPAT 00012 { 00013 BITMAPINFOHEADER bmiHeader; 00014 RGBQUAD bmiColors[16]; 00015 } BITMAPINFOPAT; 00016 00017 BITMAPINFOPAT bmiPat = 00018 { 00019 { 00020 sizeof(BITMAPINFOHEADER), 00021 128, 00022 32, 00023 1, 00024 1, 00025 BI_RGB, 00026 (32 * 128 / 8), 00027 0, 00028 0, 00029 2, 00030 2 00031 }, 00032 00033 { // B G R 00034 { 0, 0, 0x80,0 }, // 1 00035 { 0, 0x80,0, 0 }, // 2 00036 { 0, 0, 0, 0 }, // 0 00037 { 0, 0x80,0x80,0 }, // 3 00038 { 0x80,0, 0, 0 }, // 4 00039 { 0x80,0, 0x80,0 }, // 5 00040 { 0x80,0x80,0, 0 }, // 6 00041 { 0xC0,0xC0,0xC0,0 }, // 7 00042 00043 { 0x80,0x80,0x80,0 }, // 8 00044 { 0, 0, 0xFF,0 }, // 9 00045 { 0, 0xFF,0, 0 }, // 10 00046 { 0, 0xFF,0xFF,0 }, // 11 00047 { 0xFF,0, 0, 0 }, // 12 00048 { 0xFF,0, 0xFF,0 }, // 13 00049 { 0xFF,0xFF,0, 0 }, // 14 00050 { 0xFF,0xFF,0xFF,0 } // 15 00051 } 00052 }; 00053 00054 static BYTE abBigCat[] = { 00055 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 00056 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 00057 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 00058 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 00059 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 00060 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 00061 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 00062 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 00063 00064 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 00065 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 00066 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 00067 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 00068 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 00069 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 00070 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 00071 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 00072 00073 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 00074 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 00075 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 00076 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 00077 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 00078 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 00079 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 00080 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 00081 00082 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 00083 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 00084 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 00085 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 00086 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 00087 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 00088 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 00089 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; 00090 00091 00092 DWORD 00093 main( 00094 int argc, 00095 char *argv[] 00096 ) 00097 { 00098 SECURITY_ATTRIBUTES SecurityAttributes; 00099 HANDLE Handle; 00100 int i; 00101 CONSOLE_GRAPHICS_BUFFER_INFO GraphicsInfo; 00102 SMALL_RECT Rect; 00103 BOOL Success; 00104 ULONG NumWritten; 00105 00106 DbgPrint( "TGRAPH: Entering graphics Test Program\n" ); 00107 00108 00109 // 00110 // open a new console 00111 // 00112 00113 SecurityAttributes.bInheritHandle = FALSE; 00114 SecurityAttributes.lpSecurityDescriptor = NULL; 00115 SecurityAttributes.nLength = sizeof (SECURITY_ATTRIBUTES); 00116 GraphicsInfo.dwBitMapInfoLength = sizeof(bmiPat); 00117 GraphicsInfo.lpBitMapInfo = &bmiPat; 00118 GraphicsInfo.dwUsage = DIB_RGB_COLORS; 00119 Handle = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 00120 FILE_SHARE_READ | FILE_SHARE_WRITE, 00121 &SecurityAttributes, 00122 CONSOLE_GRAPHICS_BUFFER, 00123 &GraphicsInfo 00124 ); 00125 if (Handle == (HANDLE)-1) { 00126 DbgPrint("CreateConsoleScreenBuffer failed\n"); 00127 return FALSE; 00128 } 00129 00130 // 00131 // make it current 00132 // 00133 00134 if (!SetConsoleActiveScreenBuffer(Handle)) { 00135 DbgPrint("SetConsoleActiveScreenBuffer failed\n"); 00136 return FALSE; 00137 } 00138 /* 00139 // 00140 // try to write to it. should fail. 00141 // 00142 00143 Success = WriteFile(Handle,"foo",3,&NumWritten,NULL); 00144 if (!Success) { 00145 DbgPrint("WriteFile failed\n"); 00146 } 00147 else { 00148 DbgPrint("WriteFile succeeded\n"); 00149 } 00150 */ 00151 // 00152 // grab mutex 00153 // 00154 00155 Success = WaitForSingleObject(GraphicsInfo.hMutex,-1); 00156 if (Success) { 00157 DbgPrint("WaitForSingleObject failed\n"); 00158 } 00159 else { 00160 DbgPrint("WaitForSingleObject succeeded\n"); 00161 } 00162 00163 // 00164 // write bitmap to memory 00165 // 00166 00167 RtlCopyMemory(GraphicsInfo.lpBitMap,abBigCat,(32*128/8)); 00168 00169 // 00170 // release mutex 00171 // 00172 00173 ReleaseMutex(GraphicsInfo.hMutex); 00174 00175 // 00176 // write bitmap to memory 00177 // 00178 00179 Rect.Left = 0; 00180 Rect.Top = 0; 00181 Rect.Right = 31; 00182 Rect.Bottom = 31; 00183 Success = InvalidateConsoleDIBits(Handle,&Rect); 00184 if (!Success) { 00185 DbgPrint("InvalidateConsoleDIBits failed\n"); 00186 } 00187 else { 00188 DbgPrint("InvalidateConsoleDIBits succeeded\n"); 00189 } 00190 00191 /* 00192 i=0; 00193 while (i<20) { 00194 INPUT_RECORD Buffer; 00195 DWORD NumRead; 00196 00197 ReadConsoleInput(GetStdHandle(STD_INPUT_HANDLE), 00198 &Buffer, 00199 1, 00200 &NumRead); 00201 if (Buffer.EventType == MOUSE_EVENT) { 00202 DbgPrint("Mouse position is %d %d\n", 00203 Buffer.Event.MouseEvent.dwMousePosition.X, 00204 Buffer.Event.MouseEvent.dwMousePosition.Y); 00205 i++; 00206 } 00207 } 00208 */ 00209 00210 while (TRUE) { 00211 Sleep(10000); 00212 } 00213 00214 if (!SetConsoleActiveScreenBuffer(GetStdHandle(STD_OUTPUT_HANDLE))) { 00215 DbgPrint("SetConsoleActiveScreenBuffer failed\n"); 00216 return FALSE; 00217 } 00218 00219 if (!CloseHandle(Handle)) { 00220 DbgPrint("CloseHandle failed\n"); 00221 return FALSE; 00222 } 00223 00224 DbgPrint( "TGRAPH: Exiting Test Program\n" ); 00225 00226 return TRUE; 00227 }

Generated on Sat May 15 19:41:57 2004 for test by doxygen 1.3.7