-
Jon © (10.03.10 02:07) [0]I have found a bug with KOL (v2.88 from SVN on D7 and WinXP).
The problem is with MouseUp/MouseDown on a PaintBox.
This simple test program demonstrates it:
program Test;
uses
Windows, KOL;
procedure DoPaint(Dummy: Pointer; Sender: PControl; DC: HDC);
begin
with Sender.Canvas^ do
begin
Brush.BrushStyle := bsSolid;
Brush.Color := clRed;
FillRect(Sender.ClientRect);
end;
end;
procedure MouseDownDrag(Dummy: Pointer; Sender: PControl; var Mouse: TMouseEventData);
begin
case Mouse.Button of
mbLeft:
begin
Sender.Cursor := LoadCursor(0,IDC_SIZEALL);
Sender.ParentForm.DragStartEx;
end;
end;
end;
procedure MouseUpDrag(Dummy: Pointer; Sender: PControl; var Mouse: TMouseEventData);
begin
case Mouse.Button of
mbLeft:
begin
Sender.ParentForm.DragStopEx;
Sender.Cursor := LoadCursor(0,IDC_ARROW);
end;
end;
end;
begin
Applet := NewForm(nil,'KOL Paintbox Mouse Click Bug').SetClientSize(320,240);
with NewPaintbox(Applet)^ do
begin
BoundsRect := Parent.ClientRect;
OnMouseDown := TOnMouse(MakeMethod(nil,@MouseDownDrag));
OnMouseUp := TOnMouse(MakeMethod(nil,@MouseUpDrag));
OnPaint := TOnPaint(MakeMethod(nil,@DoPaint));
end;
Run(Applet);
end.
Try to click and drag the PaintBox - the MouseUp does not trigger.
Can anyone confirm and suggest a fix please. -
mdw (10.03.10 12:06) [1]In method DragStartEx () called function SetCapture () for Form.Handle, and further all mouse events come to Form.
program Test;
uses
Windows, KOL;
procedure DoPaint(Dummy: Pointer; Sender: PControl; DC: HDC);
begin
with Sender.Canvas^ do
begin
Brush.BrushStyle := bsSolid;
Brush.Color := clRed;
FillRect(Sender.ClientRect);
end;
end;
procedure MouseDownDrag(Dummy: Pointer; Sender: PControl; var Mouse: TMouseEventData);
begin
case Mouse.Button of
mbLeft:
begin
Sender.Cursor := LoadCursor(0,IDC_SIZEALL);
Sender.ParentForm.DragStartEx;
end;
end;
end;
procedure MouseUpDrag(Dummy: Pointer; Sender: PControl; var Mouse: TMouseEventData);
begin
case Mouse.Button of
mbLeft:
begin
Sender.ParentForm.DragStopEx;
Sender.Children[0].Cursor := LoadCursor(0,IDC_ARROW);
end;
end;
end;
begin
Applet := NewForm(nil,'KOL Paintbox Mouse Click Bug').SetClientSize(320,240);
with NewPaintbox(Applet)^ do
begin
BoundsRect := Parent.ClientRect;
OnMouseDown := TOnMouse(MakeMethod(nil,@MouseDownDrag));
Applet.OnMouseUp := TOnMouse(MakeMethod(nil,@MouseUpDrag));
OnPaint := TOnPaint(MakeMethod(nil,@DoPaint));
end;
Run(Applet);
end. -
Jon © (10.03.10 14:05) [2]
> In method DragStartEx () called function SetCapture () for
> Form.Handle, and further all mouse events come to Form.
Of course - thank you very much indeed.