Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

TElMenu/TElMenubar und Disabling of Items when Application is lost focus

Today it is very uncommon to disable the menu if the application lost focus.
So we add a property in ElMenuBar.pas to control this

TElMenuBar = class(TCustomElToolbar)
private
  FDisableOnDeactivate: Boolean;
published
  property DisableOnDeactivate: Boolean read FDisableOnDeactivate write FDisableOnDeactivate default False;

procedure TElMenuBarButton.Paint;
begin
  ...
if (Owner <> nil) and (TElMenuBar(Owner).FDisableOnDeactivate) then // DW
      begin
        if not (csDesigning in ComponentState) and (GetParentForm(Self) <> nil) then
        begin
          b := true;
          LForm := TForm(GetParentForm(Self));
          if Assigned(LForm) then
          begin
            b := LForm.Active or (LForm.FormStyle = fsMDIForm);
          end;
          if not b then
            FMenuItem.Enabled := false;
        end;
      end;

      TElMenuBarItem(FMenuItem).DrawMenuItem(Canvas, ClientRect, Focused, FInMenu);
      FMenuItem.Enabled := LOldEnabled;
    end;
end;
Tagged:

Comments

Sign In or Register to comment.