program Project1;
uses
Windows, KOL;
var Form, PB: PControl;
procedure FormMouseWheel(Dummy, Sender: PControl; var Mouse: TMouseEventData);
var zDelta: SmallInt; r:TRect; p: TPoint;
begin
GetWindowRect(PB.Handle, r);
GetCursorPos(p);
if PointInRect(p, r) then
begin
zDelta := HiWord(Mouse.Shift);
if zDelta < 0 then
begin
PB.Width := PB.Width - 10;
PB.Height := PB.Height - 10;
end
else begin
PB.Width := PB.Width + 10;
PB.Height := PB.Height + 10;
end;
end;
end;
procedure PBPaint(Dummy, Sender: PControl; DC: HDC);
begin
Sender.Canvas.FillRect(Sender.BoundsRect);
end;
begin
Form := NewForm(nil, 'test');
PB := NewPaintBox(Form);
PB.Canvas.Brush.Color := clRed;
PB.OnPaint := TOnPaint(MakeMethod(nil, @PBPaint));
Form.OnMouseWheel := TOnMouse(MakeMethod(nil, @FormMouseWheel));
Run(Form);
end.