home *** CD-ROM | disk | FTP | other *** search
- unit P_form;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, ExtCtrls, Gfvcl;
-
- type
- TForm1 = class(TForm)
- GradientFill1: TGradientFill;
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- FClientInstance,
- FPrevClientProc : TFarProc;
- procedure ClientWndProc(VAR Message: TMessage);
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.ClientWndProc(VAR Message: TMessage);
- var
- MyDC : hDC;
- Ro, Co : Word;
- begin
- with Message do
- case Msg of
- WM_ERASEBKGND:
- begin
- MyDC := TWMEraseBkGnd(Message).DC;
- { Set Canvas's palette to the new one }
- SelectPalette(MyDC, GradientFill1.PaletteHandle, False);
- { Make Canvas recognize the palette }
- RealizePalette(MyDC);
-
- { This commented out code tiles the Gradient. If the Parent is
- resized, then the Gradient is tiled to fit the new size. This
- will cause a banding look if the form is sized larger than before }
- { for Ro := 0 TO ClientHeight DIV GradientFill1.Picture.Height DO
- for Co := 0 TO ClientWIDTH DIV GradientFill1.Picture.Width DO
- BitBlt(MyDC, Co*GradientFill1.Picture.Width, Ro*GradientFill1.Picture.Height,
- GradientFill1.Picture.Width, GradientFill1.Picture.Height,
- GradientFill1.Picture.Canvas.Handle, 0, 0, SRCCOPY);
- }
-
-
- { This line will stretch the Gradient to completely fill the
- background when it is resized.
- }
- StretchBlt(MyDC, 0, 0, ClientWidth, ClientHeight,
- GradientFill1.Picture.Canvas.Handle, 0, 0,
- GradientFill1.Picture.Width, GradientFill1.Picture.Height,
- SRCCOPY);
- { Returns a result to Windows }
- Result := 1;
- end;
- else
- { Returns a result to Windows }
- Result := CallWindowProc(FPrevClientProc, ClientHandle, Msg, wParam, lParam);
- end;
- end;
-
-
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- FClientInstance := MakeObjectInstance(ClientWndProc);
- FPrevClientProc := Pointer(GetWindowLong(ClientHandle, GWL_WNDPROC));
- SetWindowLong(ClientHandle, GWL_WNDPROC, LongInt(FClientInstance));
- end;
-
- end.
-