procedure TForm1.Button1Click(Sender: TObject); Type PLOGPALETTE=^LOGPALETTE; var PDC:HDC; pScrnPalette :HPalette; lplgpl:PLOGPALETTE; Palbuf:array[0..1047] of BYTE; k:integer; begin PDC:= GetDC(form1.Handle); lplgpl := PLOGPALETTE(@Palbuf); lplgpl.palNumEntries :=GetDeviceCaps(PDC,SIZEPALETTE);lplgpl.palVersion := $300; for k:=0 to integer(lplgpl.palNumEntries) do begin pScrnPalette:=CreatePalette(lplgpl^); SelectPalette(PDC,pScrnPalette,false); RealizePalette(PDc); ReleaseDC(form1.Handle ,pDC); end; end;
我试着想帮你翻译,但头一句就有问题, Win Api HDC GetDC( HWND hWnd // handle of window );你的 CDC* pDC = GetDC(); GetDC()的参数呢?还是别的东东?
刚才少了一段procedure TForm1.Button2Click(Sender: TObject); Type PLOGPALETTE=^LOGPALETTE; var PDC:HDC; pScrnPalette :HPalette; lplgpl:PLOGPALETTE; Palbuf:array[0..1047] of BYTE; k:integer; begin PDC:= GetDC(form1.Handle); lplgpl := PLOGPALETTE(@Palbuf); lplgpl.palNumEntries :=GetDeviceCaps(PDC,SIZEPALETTE);lplgpl.palVersion := $300; for k:=0 to integer(lplgpl.palNumEntries) do begin lplgpl.palPalEntry[k].peRed := BYTE(k)+10; lplgpl.palPalEntry[k].peGreen := BYTE(k)+10; lplgpl.palPalEntry[k].peBlue:= BYTE(k)+10; lplgpl.palPalEntry[k].peFlags:= PC_NOCOLLAPSE;end; pScrnPalette:=CreatePalette(lplgpl^); SelectPalette(PDC,pScrnPalette,false); RealizePalette(PDc); ReleaseDC(form1.Handle ,pDC);end;
按照语法来说:-> 应该改成 ^.
Type
PLOGPALETTE=^LOGPALETTE;
var
PDC:HDC;
pScrnPalette :HPalette;
lplgpl:PLOGPALETTE;
Palbuf:array[0..1047] of BYTE;
k:integer;
begin
PDC:= GetDC(form1.Handle);
lplgpl := PLOGPALETTE(@Palbuf);
lplgpl.palNumEntries :=GetDeviceCaps(PDC,SIZEPALETTE);lplgpl.palVersion := $300;
for k:=0 to integer(lplgpl.palNumEntries) do
begin
pScrnPalette:=CreatePalette(lplgpl^);
SelectPalette(PDC,pScrnPalette,false);
RealizePalette(PDc);
ReleaseDC(form1.Handle ,pDC);
end;
end;
Win Api HDC GetDC(
HWND hWnd // handle of window
);你的
CDC* pDC = GetDC();
GetDC()的参数呢?还是别的东东?
Type
PLOGPALETTE=^LOGPALETTE;
var
PDC:HDC;
pScrnPalette :HPalette;
lplgpl:PLOGPALETTE;
Palbuf:array[0..1047] of BYTE;
k:integer;
begin
PDC:= GetDC(form1.Handle);
lplgpl := PLOGPALETTE(@Palbuf);
lplgpl.palNumEntries :=GetDeviceCaps(PDC,SIZEPALETTE);lplgpl.palVersion := $300;
for k:=0 to integer(lplgpl.palNumEntries) do
begin lplgpl.palPalEntry[k].peRed := BYTE(k)+10;
lplgpl.palPalEntry[k].peGreen := BYTE(k)+10;
lplgpl.palPalEntry[k].peBlue:= BYTE(k)+10;
lplgpl.palPalEntry[k].peFlags:= PC_NOCOLLAPSE;end;
pScrnPalette:=CreatePalette(lplgpl^);
SelectPalette(PDC,pScrnPalette,false);
RealizePalette(PDc);
ReleaseDC(form1.Handle ,pDC);end;
ReleaseDC(0,pDC);
再次感谢!!