00001
00002
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 ,
00015 0, 0x80,0, 0 ,
00016 0, 0, 0, 0 ,
00017 0, 0x80,0x80,0 ,
00018 0x80,0, 0, 0 ,
00019 0x80,0, 0x80,0 ,
00020 0x80,0x80,0, 0 ,
00021 0xC0,0xC0,0xC0,0 ,
00022 0x80,0x80,0x80,0 ,
00023 0, 0, 0xFF,0 ,
00024 0, 0xFF,0, 0 ,
00025 0, 0xFF,0xFF,0 ,
00026 0xFF,0, 0, 0 ,
00027 0xFF,0, 0xFF,0 ,
00028 0xFF,0xFF,0, 0 ,
00029 0xFF,0xFF,0xFF,0 };
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
00052
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
00108
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 }