unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
Edit1: TEdit;
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
wProc:Pointer;
function NewWndProc(Handle:hWnd; msg, wParam, lParam:Longint):Longint; stdcall;
var
hdc, hbs:cardinal;
begin
Result:=CallWindowProc(wProc, Handle, msg, wParam, lParam);
If msg=WM_CTLCOLOREDIT then
begin
If (lParam=Form1.Edit1.Handle) or (lParam=Form1.Memo1.Handle) then
begin
hdc:=wParam;
hbs:=CreateSolidBrush(clYellow);
SetBkColor(hdc, clYellow);
SetTextColor(hdc, clRed);
Result:=hbs;
end;
end;
If msg=WM_PAINT then
begin
hdc:=GetDC(Form1.Memo1.Handle);
hbs:=CreateSolidBrush(clYellow);
FillRect(hdc, Rect(0, 0, Form1.Memo1.Width, Form1.Memo1.Height), hbs);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
wProc:=Pointer(SetWindowLong(Panel1.Handle, gwl_WndProc, Integer(@NewWndProc)));
end;
end.