Re: Help for actionmanager and actionmainmenubar component.



"Cooper" <cooper@xxxxxxxxxxx> wrote in message
news:IkvWf.38964$nz4.37043@xxxxxxxxxxxxxxxxxxxxxxxx

i need help about ActionManager and ActionMainMenuBar component.
So, i have created a menu with this components and i need to
enable/disable some menu item (of this menu) at runtime.
Help me posting some example code for to do it?

The idea of actions is to reverse the logic that enables or disables
your controls. Instead of catching some event and recomputing the
control's state, you attach an action and _wait_. You wait until its
OnUpdate event is fired (which will happen automagically). In the
handler for that, you enable or disable _the action_ and all controls
that listen to it will follow.

So, let's say you have a menu item mnuFileClose that refers to an
action cmdFileClose. You write a handler for the action's OnUpdate
event which checks that a file is open - because otherwise, you can't
close it. (All names are approximate. I don't know how to tell if
there is a file open; you do.)

The sample code then becomes something like

procedure TFActiveMenuDemo.UpdateFileClose(Sender: TObject);
begin
(Sender as TAction).Enabled:=Assigned(ActiveDocument);
end;

The biggest trick is getting all the components (and the ActiveDocument
property) set up right so that it really becomes this easy.

Groetjes,
Maarten Wiltink


.



Relevant Pages

  • Re: Problem enabling a button in a toolbar
    ... automatically enables the toolbar buttons if there is a handler. ... >>I have a docking control bar that contains a dialog. ...
    (microsoft.public.vc.mfc)
  • Re: Multipage Pages will not show controls when enabled
    ... The controls on the multipage pages showed up ok for me in my testing. ... Any chance that it's a display problem--does the userform work ok on a different ... The Page enables, ... Private Sub cboIllumination_Change ...
    (microsoft.public.excel.programming)
  • Re: Cannot access .chm files through the network.
    ... To re-enable the controls in the help files stored in specific folders ... files in the Local Intranet zone. ... (2 enables files in the Trusted sites ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: Multipage Pages will not show controls when enabled
    ... "Dave Peterson" wrote: ... The controls on the multipage pages showed up ok for me in my testing. ... The Page enables, ... Private Sub cboIllumination_Change ...
    (microsoft.public.excel.programming)
  • Re: Multipage Pages will not show controls when enabled
    ... "Dave Peterson" wrote: ... The controls on the multipage pages showed up ok for me in my testing. ... The Page enables, ... Private Sub cboIllumination_Change ...
    (microsoft.public.excel.programming)