Solved

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

Posted on 2007-04-05
5
167 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
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

860 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