TRzMenuController – UpdateMainMenuColor

Home Forums Konopka Signature VCL Controls (formerly Raize Components) TRzMenuController – UpdateMainMenuColor

Viewing 0 reply threads
  • Author
    Posts
    • #2566
      Marek J.
      Participant

        Currently in 7.0 the procedure UpdateMainMenuColor assume fix that controller must be defined on the form. It’s too rigid.
        I suggest the modification:

        procedure TRzMenuController.UpdateMainMenuColor;
        var
          MenuInfo: TMenuInfo;
          ownerForm: TCustomForm;  //mod
        begin
        
        //mod  if ( Owner <> nil ) and ( Owner is TCustomForm ) then
        //mod  begin
        //mod    if TCustomForm( Owner ).Menu = nil then
        //mod      Exit;
        //mod  end;
        
          ownerForm := GetParentForm(Owner as TControl);  //mod
          if not Assigned(ownerForm) then exit; //mod
        
          DeleteObject( FMainMenuBrushHandle );
        
          if FUseMenuColorForMainMenu then
            FMainMenuBrushHandle := CreateSolidBrush( ColorToRGB( FMenuColor ) )
          else
            FMainMenuBrushHandle := CreateSolidBrush( ColorToRGB( clBtnFace ) );
        
          FillChar( MenuInfo, SizeOf( MenuInfo ), 0 );
          MenuInfo.cbSize := SizeOf( MenuInfo );
          MenuInfo.hbrBack := FMainMenuBrushHandle;
          MenuInfo.fMask := MIM_BACKGROUND;
        
          //mod SetMenuInfo( TCustomForm( Owner ).Menu.Handle, MenuInfo );
          SetMenuInfo( ownerForm.Menu.Handle, MenuInfo ); //mod
        end;
    Viewing 0 reply threads
    • You must be logged in to reply to this topic.