lcl: TTrackBar.OnChange should be called after Position change in code, add Changed method for VCL compatibility, fix qt, gtk2 to skip message sending in case of position change through code to prevent double calling of the message (issue #0014545)

git-svn-id: trunk@25161 -
This commit is contained in:
paul 2010-05-04 04:29:27 +00:00
parent d4d220476d
commit c3564e26d8
6 changed files with 27 additions and 7 deletions

View File

@ -1840,6 +1840,7 @@ type
protected
class procedure WSRegisterClass; override;
procedure ApplyChanges;
procedure Changed; virtual;
procedure DoChange(var msg); message LM_CHANGED;
procedure FixParams(var APosition, AMin, AMax: Integer);
class function GetControlClassDefaultSize: TPoint; override;

View File

@ -466,9 +466,8 @@ begin
// only fire event if reason is not some other window hide/showing etc.
if Message.Status = 0 then
begin
if Message.Show then begin
if Message.Show then
DoShowWindow;
end;
end;
finally
Exclude(FFormState, fsShowing);

View File

@ -174,6 +174,7 @@ begin
FPosition := Value;
if HandleAllocated then
TWSTrackBarClass(WidgetSetClass).SetPosition(Self, FPosition);
Changed;
end;
end;
@ -311,6 +312,12 @@ begin
TWSTrackBarClass(WidgetSetClass).ApplyChanges(Self);
end;
procedure TCustomTrackBar.Changed;
begin
if Assigned (FOnChange) then
FOnChange(Self);
end;
{------------------------------------------------------------------------------
Method: TCustomTrackBar.DoChange
Params: Msg (longint = LM_CHANGE)
@ -325,8 +332,7 @@ begin
if [csLoading,csDestroying,csDesigning]*ComponentState<>[] then
Exit;
EditingDone;
if Assigned (FOnChange) then
FOnChange(Self);
Changed;
end;
procedure TCustomTrackBar.FixParams(var APosition, AMin, AMax: Integer);

View File

@ -2283,7 +2283,6 @@ var
begin
Result := CallBackDefaultReturn;
EventTrace('Value changed', data);
if (Widget=nil) then ;
Mess.msg := LM_CHANGED;
DeliverMessage(Data, Mess);
end;

View File

@ -247,13 +247,22 @@ end;
{$I gtk2wscustomlistview.inc}
procedure GtkWSTrackBar_Changed(AWidget: PGtkWidget; AInfo: PWidgetInfo); cdecl;
var
Msg: TLMessage;
begin
if AInfo^.ChangeLock > 0 then Exit;
Msg.Msg := LM_CHANGED;
DeliverMessage(AInfo^.LCLObject, Msg);
end;
{ TGtk2WSTrackBar }
class procedure TGtk2WSTrackBar.SetCallbacks(const AWidget: PGtkWidget;
const AWidgetInfo: PWidgetInfo);
begin
TGtk2WSWinControl.SetCallbacks(PGtkObject(AWidget), TComponent(AWidgetInfo^.LCLObject));
TGtk2Widgetset(WidgetSet).SetCallback(LM_CHANGED, PGtkObject(AWidget), AWidgetInfo^.LCLObject);
SignalConnect(AWidget, 'value_changed', @GtkWSTrackBar_Changed, AWidgetInfo);
end;
class function TGtk2WSTrackBar.CreateHandle(const AWinControl: TWinControl;
@ -348,11 +357,17 @@ class procedure TGtk2WSTrackBar.SetPosition(const ATrackBar: TCustomTrackBar;
const NewPosition: integer);
var
Range: PGtkRange;
WidgetInfo: PWidgetInfo;
begin
if not WSCheckHandleAllocated(ATrackBar, 'SetPosition') then
Exit;
Range := PGtkRange(ATrackBar.Handle);
WidgetInfo := GetWidgetInfo(Range);
// lock Range, so that no OnChange event is not fired
Inc(WidgetInfo^.ChangeLock);
gtk_range_set_value(Range, NewPosition);
// unlock Range
Dec(WidgetInfo^.ChangeLock);
end;
{ TGtk2WSProgressBar }

View File

@ -5760,7 +5760,7 @@ begin
writeln('TQtTrackBar.SlotValueChanged()');
{$endif}
if not SliderPressed and not InUpdate then
if not SliderPressed and (TTrackBar(LCLObject).Position <> p1) and not InUpdate then
begin
FillChar(Msg, SizeOf(Msg), #0);
Msg.Msg := LM_CHANGED;