Solved

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

Posted on 2007-04-05
5
171 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 26

Expert Comment

by:EddieShipman
ID: 18859513
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
ID: 18859617
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
ID: 18860225
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
ID: 18860228
Or just typecast it to TForm, that should work as well.
0
 
LVL 1

Author Comment

by:peterkiers
ID: 18860860
Your the best, thank you.

Peter Kiers
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

710 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