View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0005817 | JEDI VCL | 00 JVCL Components | public | 2012-03-01 15:59 | 2012-09-10 14:15 |
Reporter | uholeschak | Assigned To | obones | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | Daily / GIT | ||||
Target Version | Fixed in Version | 3.46 | |||
Summary | 0005817: JvPrvwDoc Hint hide issues | ||||
Description | The Hint window created by OnScrollHint() is sometimes not removed fully after the hint timeout (the shadow of the hint resides, at least with Win7). The correct way to remove the hint is using ReleaseHandle() not simply hiding the hint control. Unfortunately the hint removal code is implemented in a different thread, so calling ReleaseHandle() is simply not allowed here! (I am not sure if disabling a control from a different thread is allowed at all!). But there is another problem with creation of the hints. For every hint shown a new control is created, but the old one is never freed (only the pointer is set to nul). Of course at application exit everything is cleaned up, but many controls could accumulate in this time ... In the attached file there is a solution for all these problems. The timeout thread is replaced by a timer, so it's possible to access the hint control. On the other side only one hint control is created per instance and is cleaned up at destruction. | ||||
Tags | No tags attached. | ||||
2012-03-01 15:59
|
JvPrvwDoc_Hint.patch (4,305 bytes)
--- JvPrvwDocOld.pas Thu Mar 1 15:09:06 2012 +++ JvPrvwDoc.pas Thu Mar 1 15:15:28 2012 @@ -63,7 +63,7 @@ JclUnitVersioning, {$ENDIF UNITVERSIONING} Windows, Messages, SysUtils, Classes, Graphics, Controls, StdCtrls, - Forms, Dialogs, + Forms, Dialogs, ExtCtrls, // [UH] ExtCtrls added JvComponent, JvExControls; type @@ -276,6 +276,8 @@ FOnOptionsChange: TNotifyEvent; FOnScrollHint: TJvScrollHintEvent; FSelection: TJvPreviewSelection; + FHintWindow: THintWindow; // [UH] + FHintHideTimer : TTimer; // [UH] procedure DoOptionsChange(Sender: TObject); procedure DoDeviceInfoChange(Sender: TObject); procedure DoScaleModeChange(Sender: TObject); @@ -300,6 +302,7 @@ procedure SetScrollBars(const Value: TScrollStyle); procedure SetHideScrollBars(const Value: Boolean); function IsPageMode: Boolean; + procedure DoHintHideTimer(Sender: TObject); // [UH] procedure SetSelection(const Value: TJvPreviewSelection); protected procedure Change; dynamic; @@ -451,32 +454,6 @@ Math, JvThemes, JvTypes; -var - HintWindow: THintWindow = nil; - -function GetHintWindow: THintWindow; -begin - if HintWindow = nil then - begin - HintWindow := HintWindowClass.Create(Application); - HintWindow.Visible := False; - end; - Result := HintWindow; -end; - -type - TDeactiveHintThread = class(TJvCustomThread) - private - FHintWindow: THintWindow; - FDelay: Integer; - protected - procedure Execute; override; - public - constructor Create(Delay: Integer; HintWindow: THintWindow); - end; - - // returns True if Inner is completely within Outer - function RectInRect(Inner, Outer: TRect): Boolean; function InRange(const AValue, AMin, AMax: Integer): Boolean; @@ -925,6 +902,10 @@ FScrollBars := ssBoth; FHideScrollBars := False; TabStop := True; + FHintWindow := Forms.HintWindowClass.Create(nil); // [UH] + FHintHideTimer := TTimer.Create(nil); // [UH] + FHintHideTimer.Enabled := False; + FHintHideTimer.OnTimer := DoHintHideTimer; end; destructor TJvCustomPreviewControl.Destroy; @@ -935,6 +916,8 @@ FOptions.Free; FPages.Free; FBuffer.Free; + FHintHideTimer.Free; // [UH] + FHintWindow.Free; // [UH] inherited Destroy; end; @@ -1372,8 +1355,7 @@ end; SB_ENDSCROLL: begin - TDeactiveHintThread.Create(500, HintWindow); - HintWindow := nil; + // [UH] TDeactiveHintThread removed Exit; end; end; @@ -1779,8 +1761,7 @@ Msg.Result := 0; WMVScroll(Msg); Refresh; - TDeactiveHintThread.Create(500, HintWindow); - HintWindow := nil; + // [UH] TDeactiveHintThread removed Result := True; end; end; @@ -1853,7 +1834,7 @@ FOnScrollHint(Self, NewPos, S); if S <> '' then begin - HW := GetHintWindow; + HW := FHintWindow; // [UH] if not HW.Visible then begin HW.Color := Application.HintColor; @@ -1869,6 +1850,10 @@ HW.ActivateHint(R, S); HW.Invalidate; HW.Update; + // [UH] start hide timer + FHintHideTimer.Enabled := False; + FHintHideTimer.Interval := Application.HintHidePause; + FHintHideTimer.Enabled := True; end; end; end; @@ -1925,29 +1910,10 @@ end; end; -//=== { TDeactiveHintThread } ================================================ - -constructor TDeactiveHintThread.Create(Delay: Integer; HintWindow: THintWindow); -begin - inherited Create(False); - FreeOnTerminate := True; - FHintWindow := HintWindow; - FDelay := Delay; - if FDelay = 0 then - FDelay := Application.HintHidePause; -end; - -procedure TDeactiveHintThread.Execute; +// [UH] TDeactiveHintThread replaced +procedure TJvCustomPreviewControl.DoHintHideTimer(Sender: TObject); begin - NameThread(ThreadName); - Sleep(FDelay); - if FHintWindow <> nil then - begin - FHintWindow.Visible := False; - FHintWindow.ActivateHint(Rect(0, 0, 0, 0), ''); - FHintWindow := nil; - end; - Terminate; + FHintWindow.ReleaseHandle(); end; procedure TJvCustomPreviewControl.SetSelection(const Value: TJvPreviewSelection); |
|
Demo in 0005814 |
|
This should be solved in SVN |
Date Modified | Username | Field | Change |
---|---|---|---|
2012-03-01 15:59 | uholeschak | New Issue | |
2012-03-01 15:59 | uholeschak | File Added: JvPrvwDoc_Hint.patch | |
2012-03-02 10:15 | obones | Relationship added | related to 0005814 |
2012-03-02 10:16 | obones | Note Added: 0019638 | |
2012-03-02 10:16 | obones | Status | new => acknowledged |
2012-03-02 10:58 | obones | Note Added: 0019639 | |
2012-03-02 10:58 | obones | Status | acknowledged => resolved |
2012-03-02 10:58 | obones | Fixed in Version | => Daily / SVN |
2012-03-02 10:58 | obones | Resolution | open => fixed |
2012-03-02 10:58 | obones | Assigned To | => obones |
2012-09-10 14:15 | obones | Fixed in Version | Daily / SVN => 3.46 |