Menus - criando em runtime |
Top Previous Next |
|
// Esta incomplete, mas o main esta aqui, Tirei do Biblia5
procedure TFormColorText.FormCreate(Sender: TObject); var PullDown, Item: TMenuItem; Position, I: Integer; begin // create the new pulldown menu PullDown := TMenuItem.Create (Self); PullDown.AutoHotkeys := maManual; PullDown.Caption := 'Size'; PullDown.OnClick := SizeClick; // compute the position and add it Position := MainMenu1.Items.IndexOf (Options1); MainMenu1.Items.Insert (Position + 1, PullDown); // create menu items for various sizes I := 8; while I <= 48 do begin // create the new item Item := TMenuItem.Create (Self); Item.Caption := IntToStr (I); // make it a radio item Item.GroupIndex := 1; Item.RadioItem := True; // handle click and insert Item.OnClick := SizeItemClick; PullDown.Insert (PullDown.Count, Item); I := I + 4; end; // add extra item at the end Item := TMenuItem.Create (Self); Item.Caption := '&More...'; // make it a radio item Item.GroupIndex := 1; Item.RadioItem := True; // handle it by showing the font selection dialog Item.OnClick := Font1Click; PullDown.Insert (PullDown.Count, Item); end; |