🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: cn.bbs.comp.program
1 messages
1 total messages Started by ���� Fri, 03 Apr 1998 00:00
Re: Delphi ͼ��һ��
#1568
Author: ����
Date: Fri, 03 Apr 1998 00:00
71 lines
2580 bytes
> ==> Confidence_Sun(���)                     ˵��: 
> �뿴����һ�γ��� 
> var 
>      lpLP:PLOGPALETTE; 
>     Function MakePalette:HPALETTE; 
> implementation 
> {$R *.DFM} 
> procedure TForm1.FormCreate(Sender: TObject); 
> var 
>    dwSize:DWord; 
> begin 
>      dwSize:=sizeof(TLOGPALETTE)+256*sizeof(TPALETTEENTRY); 
>      lpLP:=plogpalette(LocalAlloc(LMEM_FIXED,dwSize)); 
LocalAlloc return a handle, not a pointer.  You should use GetMem.
> end; 
> procedure TForm1.FormPaint(Sender: TObject); 
> var 
>    DCHandle:HDC; 
>    Palette:HPALETTE; 
>    i:Integer; 
> begin 
>      if Palette<>0 then 
>      begin 
>           DeleteObject(Palette); 
>           Palette:=0; 
>      end; 
>      DCHandle:=GetDC(Canvas.Handle); 
>      Palette:=MakePalette; 
>      SelectPalette(DCHandle,Palette,false); 
>      RealizePalette(DCHandle); 
>      with Canvas do 
>      for i:=0 to 255 do 
>      begin 
>           Brush.color:=PALETTEINDEX( i ); 
>           Canvas.FillRect( Rect(((i*width) div 256),0,(((1+i)*width) div 256),Height) ); 
>      end; 
>      DeleteObject(Palette); 
>      ReleaseDC(Form1.Handle,DCHandle); 
> end; 
> Function MakePalette:HPALETTE; 
> var 
>    i:Integer; 
>    Palette:HPalette; 
> begin 
>      lpLP^.palVersion:=$300; 
>      lpLP^.palNumEntries:=256; 
>      for i:=0 to 127 do 
>      begin 
>       lpLP^.palPalEntry[i].peRed:=((i*256) div 128); 
>       lpLP^.palPalEntry[i].peGreen:=0; 
>       lpLP^.palPalEntry[i].peBlue:=0; 
>       lpLP^.palPalEntry[i].peFlags:=0; 
>      end; 
>      for i:=128 to 255 do 
>      begin 
>       lpLP^.palPalEntry[i].peRed:=255; 
>       lpLP^.palPalEntry[i].peGreen:= 
>               ((256*(i-128)) div 128); 
>       lpLP^.palPalEntry[i].peBlue:= 
>               ((256*(i-128)) div 128); 
>       lpLP^.palPalEntry[i].peFlags:=0; 
>      end; 
>      Palette:=CreatePalette(lpLP^); 
>      Result:=Palette; 
> end; 
> ���к󣬽��������ϣ���ν��ͣ�(95������256ɫģʽ)���ڴ�����Ļش� 
 

--
�� ��Դ: �й�ƴ�BBSվ [bbs.ustc.edu.cn]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads