Recent

Author Topic: i have function named showelp but it is called from control.inc  (Read 711 times)

tanakian

  • New Member
  • *
  • Posts: 14
in my unit1.pas i have function named ShowHelp, however, when i call it from Form1 method, it calls one from control.inc: procedure TControl.ShowHelp;

is that correct?

jamie

  • Hero Member
  • *****
  • Posts: 6880
Re: i have function named showelp but it is called from control.inc
« Reply #1 on: March 17, 2025, 02:16:33 pm »
That is because you're calling it from the wrong place of code

Rename your function to something else to make it easier.
The only true wisdom is knowing you know nothing

cdbc

  • Hero Member
  • *****
  • Posts: 2108
    • http://www.cdbc.dk
Re: i have function named showelp but it is called from control.inc
« Reply #2 on: March 17, 2025, 02:20:22 pm »
"ViewHelp" springs to mind  :D
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

Thaddy

  • Hero Member
  • *****
  • Posts: 16826
  • Ceterum censeo Trump esse delendam
Re: i have function named showelp but it is called from control.inc
« Reply #3 on: March 17, 2025, 03:11:06 pm »
Specify it by prefixing with the unit name
Code: Pascal  [Select][+][-]
  1. unit1.ShowHelp()
That way your showhelp will be called instead of the method TControl.ShowHelp().

But as others suggested it may be better to choose a different name, although the above suggestion works fine.

If your ShowHelp is part of the form, i.e. if it is a method, declare it override.
TControl.ShowHelp is virtual.
Code: Pascal  [Select][+][-]
  1. type
  2.    TForm1 = class(TForm);
  3.    private
  4. ....
  5.    public
  6.        procedure showhelp;override;
  7.    end;
  8. implementation
  9.  
  10. procedure TForm1.ShowHelp;
  11. begin
  12.    Showmessage('form1 help');
  13. end;
That will also work and probably the best option.

See also
https://lazarus-ccr.sourceforge.io/docs/lcl/controls/tcontrol.showhelp.html
« Last Edit: March 17, 2025, 03:34:27 pm by Thaddy »
Changing servers. thaddy.com may be temporary unreachable but restored when the domain name transfer is done.

Thaddy

  • Hero Member
  • *****
  • Posts: 16826
  • Ceterum censeo Trump esse delendam
Re: i have function named showelp but it is called from control.inc
« Reply #4 on: March 18, 2025, 01:37:29 pm »
We already gave correct answers.
Changing servers. thaddy.com may be temporary unreachable but restored when the domain name transfer is done.

tanakian

  • New Member
  • *
  • Posts: 14
Re: i have function named showelp but it is called from control.inc
« Reply #5 on: March 18, 2025, 03:16:35 pm »
thank you everyone.

Thaddy

  • Hero Member
  • *****
  • Posts: 16826
  • Ceterum censeo Trump esse delendam
Re: i have function named showelp but it is called from control.inc
« Reply #6 on: March 18, 2025, 04:33:29 pm »
Did you understand it?
Changing servers. thaddy.com may be temporary unreachable but restored when the domain name transfer is done.

 

TinyPortal © 2005-2018