Peter Kiers
asked on
a procedure in a component calls a main-menu-item on the main form
Dear experts,
Sorry, to bother you again.
I have put this procedure in my component:
1. procedure TMyDrawingPanel.CursorFlas hTimer_OnT Imer(sende r: 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
Sorry, to bother you again.
I have put this procedure in my component:
1. procedure TMyDrawingPanel.CursorFlas
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
ASKER
Yes the menu-item will always exist and always named the same.
Because I use my component only in my application
Because I use my component only in my application
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).miFl ashCursor. Checked) then
CursorFlashTimer.Enabled := True;
Change TMyForm to the formthat your control is on.
access the menu item from there:
if (not CursorVisible) or (TMyForm(Self.Parent).miFl
CursorFlashTimer.Enabled := True;
Change TMyForm to the formthat your control is on.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Your the best, thank you.
Peter Kiers
Peter Kiers
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.