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

tpalette.c

Go to the documentation of this file.
00001 /* 00002 * Copyright (c) 1985 - 1999, Microsoft Corporation 00003 */ 00004 00005 #include <windows.h> 00006 #include <string.h> 00007 #include <stdlib.h> 00008 #include "..\..\inc\conapi.h" 00009 #define FOREGROUND_WHITE (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED) 00010 00011 00012 00013 BYTE MyPalette[64] = 00014 { 0, 0, 0x80,0 , // 1 00015 0, 0x80,0, 0 , // 2 00016 0, 0, 0, 0 , // 0 00017 0, 0x80,0x80,0 , // 3 00018 0x80,0, 0, 0 , // 4 00019 0x80,0, 0x80,0 , // 5 00020 0x80,0x80,0, 0 , // 6 00021 0xC0,0xC0,0xC0,0 , // 7 00022 0x80,0x80,0x80,0 , // 8 00023 0, 0, 0xFF,0 , // 9 00024 0, 0xFF,0, 0 , // 10 00025 0, 0xFF,0xFF,0 , // 11 00026 0xFF,0, 0, 0 , // 12 00027 0xFF,0, 0xFF,0 , // 13 00028 0xFF,0xFF,0, 0 , // 14 00029 0xFF,0xFF,0xFF,0 }; // 15 00030 00031 00032 DWORD 00033 main( 00034 int argc, 00035 char *argv[] 00036 ) 00037 { 00038 BOOL Success; 00039 int i; 00040 HPALETTE hPalette; 00041 LOGPALETTE *Palette; 00042 HANDLE hgo; 00043 CONSOLE_GRAPHICS_BUFFER_INFO cgbi; 00044 00045 Palette = LocalAlloc(LMEM_FIXED, 00046 sizeof(LOGPALETTE) + 256 * sizeof(PALETTEENTRY)); 00047 00048 Palette->palNumEntries = (WORD) 256; 00049 Palette->palVersion = 0x300; 00050 00051 /* Fill in the palette entries from the DIB color table and 00052 * create a logical color palette. 00053 */ 00054 00055 for (i = 0; i < 256; i++) { 00056 Palette->palPalEntry[i].peRed = 255-i; 00057 Palette->palPalEntry[i].peGreen = 255-i; 00058 Palette->palPalEntry[i].peBlue = 255-i; 00059 Palette->palPalEntry[i].peFlags = (BYTE)0; 00060 } 00061 00062 hPalette = CreatePalette(Palette); 00063 if (hPalette==NULL) { 00064 printf("first CreatePalette failed\n"); 00065 printf("last error is %x\n",GetLastError()); 00066 } 00067 00068 #if 0 00069 call 00070 HANDLE 00071 APIENTRY 00072 CreateConsoleScreenBuffer( 00073 DWORD dwDesiredAccess, 00074 DWORD dwShareMode, 00075 LPSECURITY_ATTRIBUTES lpSecurityAttributes, 00076 DWORD dwFlags, == CONSOLE_GRAPHICS_BUFFER 00077 PVOID lpScreenBufferData == pCONSOLE_GRAPHICS_BUFFER_INFO 00078 ); 00079 typedef struct _CONSOLE_GRAPHICS_BUFFER_INFO { 00080 DWORD dwBitMapInfoLength; 00081 LPBITMAPINFO lpBitMapInfo; 00082 DWORD dwUsage; 00083 HANDLE hMutex; 00084 PVOID lpBitMap; 00085 } CONSOLE_GRAPHICS_BUFFER_INFO, *PCONSOLE_GRAPHICS_BUFFER_INFO; 00086 00087 00088 #define CONSOLE_GRAPHICS_BUFFER 2 00089 #endif 00090 hgo = CreateConsoleScreenBuffer(MAXIMUM_ALLOWED, 0, NULL, 00091 CONSOLE_GRAPHICS_BUFFER, &cgbi); 00092 if (hgo == NULL) { 00093 DbgPrint("CreateConsoleScreenBuffer failed\n"); 00094 return FALSE; 00095 } 00096 Success = SetConsolePalette(hgo, 00097 hPalette, 00098 SYSPAL_NOSTATIC 00099 ); 00100 if (!Success) { 00101 printf("first SetConsolePalette failed\n"); 00102 } 00103 printf("palette should be different\n"); 00104 Sleep(5000); 00105 DeleteObject(hPalette); 00106 00107 /* Fill in the palette entries from the DIB color table and 00108 * create a logical color palette. 00109 */ 00110 00111 for (i = 0; i < 16; i++) { 00112 memcpy(&Palette->palPalEntry[i], 00113 MyPalette, 00114 64 00115 ); 00116 } 00117 00118 hPalette = CreatePalette(Palette); 00119 if (hPalette==NULL) { 00120 printf("first CreatePalette failed\n"); 00121 } 00122 00123 Success = SetConsolePalette(hgo, 00124 hPalette, 00125 SYSPAL_STATIC 00126 ); 00127 if (!Success) { 00128 printf("second SetConsolePalette failed\n"); 00129 } 00130 printf("palette should be different\n"); 00131 Sleep(5000); 00132 DeleteObject(hPalette); 00133 00134 printf( "TCURSOR: Exiting Test Program\n" ); 00135 return TRUE; 00136 }

Generated on Sat May 15 19:42:02 2004 for test by doxygen 1.3.7