bazzer747 25 Posted June 24, 2020 Hi, I've been getting a lot of Access Violations in my applications recently and have now tracked down what I think is the cause. I only 'think' because what I've done seems to have reduced the AVs. I have used Hints/ShowHint on many buttons in the apps. I tracked some of the AVs down to where ShowHint was checked but there was no actual text in the Hint property. Now why this should cause an AV is beyond me, there should be an easy coding that just show a blank, or the ShowHint should not be checkable if Hint is empty, but then this is Delphi! What I'd like to know is - is there a quick and easy way to go through all the properties in an application and check if there is text in all the Hint property where the ShowHint is checked, or vice versa see if there is text whenever the ShowHint is not checked? Going through every form and every component would take forever... Share this post Link to post
Mahdi Safsafi 225 Posted June 24, 2020 I made a quick test that uses buttons with hints and empty hints ... and it worked just fine on Delphi 10.3. Perhaps the issue is on your Delphi (can you give more details about your version, are you using vcl-style ?,...). Quote What I'd like to know is - is there a quick and easy way to go through all the properties in an application and check if there is text in all the Hint property where the ShowHint is checked, or vice versa see if there is text whenever the ShowHint is not checked? Going through every form and every component would take forever... Something like this ? procedure CheckEmptyHint(AComponent: TComponent); var LComponent: TComponent; LControl: TControl; begin if (AComponent is TControl) then begin LControl := TControl(AComponent); if LControl.ShowHint and (LControl.Hint = EmptyStr) then Main.Memo1.Lines.Add(Format('%s has empty hint property.', [AComponent.Name])); end; for LComponent in AComponent do CheckEmptyHint(LComponent); end; // CheckEmptyHint(Application); 1 Share this post Link to post
Guest Posted June 24, 2020 Write your own search and destroy code, sorry i mean search and fix or report/log, it will be faster then waiting an answer with complete solution as there will not be, it will be runtime code, as standalone parser will be long story. Small function can do that, feed it a form or frame or even let it walk the Application itself. After writing it, please share with us. Share this post Link to post
Anders Melander 1815 Posted June 24, 2020 1 hour ago, bazzer747 said: What I'd like to know is - is there a quick and easy way to go through all the properties in an application and check if there is text in all the Hint property where the ShowHint is checked, or vice versa see if there is text whenever the ShowHint is not checked? Going through every form and every component would take forever... Don't do that. You're trying to eliminate the symptoms of a problem somewhere else in your application. Hint/ShowHint works just fine. If you manage to "hide" the problem by setting ShowHint=False then you will just have removed the only lead you currently have to the underlying problem. By the way, ShowHint does more than controlling if the control displays hints. It also controls if the child controls display hints - if Child.ParentShowHint=True. You usually set ShowHint=True on the form and then ParentShowHint=True on all child controls. Setting ParentShowHint=True just means that the parent ShowHint value propagates down to the child control. Anyway, what I would do is install MadExcept and configure it to "Instantly crash on buffer overrun". I'm guessing you have a stale pointer or a memory overwrite somewhere. 1 Share this post Link to post
John Kouraklis 94 Posted June 24, 2020 @Anders Melander Are you sure ShowHint is inherited from the parent control? Shouldn't it respect the HitTest property? Share this post Link to post
Anders Melander 1815 Posted June 24, 2020 1 minute ago, John Kouraklis said: Are you sure ShowHint is inherited from the parent control? Shouldn't it respect the HitTest property? Yes of course and it does but ShowHint controls if the control supplies hint text when the mouse hovers over the control. If it doesn't then it will try to get the hint from the parent control, etc. The help is pretty clear on how it works. 1 Share this post Link to post