Solved

a procedure in a component calls a main-menu-item on the main form

Posted on 2007-04-05
5
161 Views
Last Modified: 2010-04-05
Dear experts,

Sorry, to bother you again.

I have put this procedure in my component:

1.  procedure TMyDrawingPanel.CursorFlashTimer_OnTImer(sender: TObject);
2.  begin
3.  CursorFlashTimer.Enabled := False;
4.   try
5.  CursorVisible := not CursorVisible;
6.  finally
7. //   if (not CursorVisible) or (miFlashCursor.Checked) then CursorFlashTimer.Enabled := True;
8.   end;
9. end;

I get an error at line 7.

Because line 7 referse to a main-menu-item called miFlashCursor on the main form.

Is there a way to do this, that a procedure in a component calls a main-menu-item
that is on the main form.

Peter
0
Comment
Question by:peterkiers
  • 3
  • 2
5 Comments
 
LVL 26

Expert Comment

by:EddieShipman
Comment Utility
You will not always be able to be sure that that menu item even exists or even
named the same. The only thinkg you can do is to have the component store the
menu item that is being used to do this in another property and use that to "point"
to it.
0
 
LVL 1

Author Comment

by:peterkiers
Comment Utility
Yes the menu-item will always exist and always named the same.

Because I use my component only in my application
0
 
LVL 26

Expert Comment

by:EddieShipman
Comment Utility
If that is the case then you need to typecast the control's PARENT and then
access the menu item from there:

    if (not CursorVisible) or (TMyForm(Self.Parent).miFlashCursor.Checked) then
      CursorFlashTimer.Enabled := True;

Change TMyForm to the formthat your control is on.
0
 
LVL 26

Accepted Solution

by:
EddieShipman earned 500 total points
Comment Utility
Or just typecast it to TForm, that should work as well.
0
 
LVL 1

Author Comment

by:peterkiers
Comment Utility
Your the best, thank you.

Peter Kiers
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now