FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
|
Herramientas | Buscar en Tema | Desplegado |
|
#1
|
|||
|
|||
Cordial Saludo,
Logré realizar el armado del Menú Ribbon, pero ahora tengo problemas de Access Violation cuando cierro el form (MDICHILD). A continuación pongo el código para ver si alguien me puede indicar en dónde estoy cometiendo un error. Cabe anotar que en el evento close del formulario libero los objetos. Los objeto globales son: Código:
crpOpPagina: TCustomRibbonPage; rtiOpTab: TRibbonTabItem; rgpOpciones: array of TRibbonGroup; aclOpLista: TActionList; actOpciones: array of TAction; Código:
var mniMenu: TMenuItem; i, j: integer; lBlItems: Boolean; begin //Creación del ActionList aclOpLista := TActionList.Create(self); aclOpLista.Name := 'OpcionesForma'; //Crear Página (TAB) Ribbon with FrmPrincipal.Ribbon1.Tabs.Add do begin Caption := 'Opciones Forma'; KeyTip := 'OpcionesForma'; end; crpOpPagina := FrmPrincipal.Ribbon1.Tabs[FrmPrincipal.Ribbon1.Tabs.Count - 1].Page; //Crear Grupos Ribbon for i := 0 to ComponentCount - 1 do begin if (Components[i].ClassName = 'TMenuItem') then begin if (TMenuItem(Components[i]).Caption <> '-') then begin if (Length(Trim(TMenuItem(Components[i]).Parent.Caption)) = 0) then begin SetLength(rgpOpciones, Length(rgpOpciones) + 1); rgpOpciones[Length(rgpOpciones)] := TRibbonGroup.Create(crpOpPagina.Parent); rgpOpciones[Length(rgpOpciones)].Caption := TMenuItem(Components[i]).Caption; rgpOpciones[Length(rgpOpciones)].Parent := crpOpPagina; rgpOpciones[Length(rgpOpciones)].ActionManager := FrmPrincipal.MnuPrincipal; rgpOpciones[Length(rgpOpciones)].KeyTip := TMenuItem(Components[i]).Caption; rgpOpciones[Length(rgpOpciones)].Enabled := true; rgpOpciones[Length(rgpOpciones)].Rows := 2; rgpOpciones[Length(rgpOpciones)].GroupAlign := gaVertical; with FrmPrincipal.MnuPrincipal.ActionBars.Add do begin lBlItems := False; ActionBar := rgpOpciones[Length(rgpOpciones)]; //Crear las Opciones para cada grupo for j := 0 to ComponentCount - 1 do begin if (Components[j].ClassName = 'TMenuItem') then begin mniMenu := TMenuItem(Components[j]); while (Length(Trim(mniMenu.Parent.Caption)) > 0) do begin if (mniMenu.Parent.Caption = TMenuItem(Components[i]).Caption) then begin SetLength(actOpciones, Length(actOpciones) + 1); actOpciones[Length(actOpciones)] := TAction.Create(aclOpLista); actOpciones[Length(actOpciones)].Name := mniMenu.Name; actOpciones[Length(actOpciones)].OnExecute := mniMenu.OnClick; with Items.Add do begin Action := actOpciones[Length(actOpciones)]; KeyTip := mniMenu.Caption; Caption := mniMenu.Caption; CommandStyle := csButton; (CommandProperties as TButtonProperties).ButtonSize := bsLarge; ImageIndex := 49; Enabled := mniMenu.Enabled; end; lBlItems := true; end; mniMenu := mniMenu.Parent; end; end; end; //--for j := 0 to ComponentCount - 1 do if (not lBlItems) then begin mniMenu := TMenuItem(Components[i]); SetLength(actOpciones, Length(actOpciones) + 1); actOpciones[Length(actOpciones)] := TAction.Create(aclOpLista); actOpciones[Length(actOpciones)].Name := mniMenu.Name; actOpciones[Length(actOpciones)].OnExecute := mniMenu.OnClick; with Items.Add do begin Action := actOpciones[Length(actOpciones)]; KeyTip := mniMenu.Caption; Caption := mniMenu.Caption; CommandStyle := csButton; (CommandProperties as TButtonProperties).ButtonSize := bsLarge; ImageIndex := 49; Enabled := mniMenu.Enabled; end; end; end; //--with FrmPrincipal.MnuPrincipal.ActionBars.Add do end; end; end; end; // crpOpPagina.Refresh; crpOpPagina.SetFocus; end; |
#2
|
|||
|
|||
Cordial Saludo,
Ya encontré el error. Debe ser causa del cansancio por tanto trabajo que tengo. En las referencias a los array me estoy pasando por uno los índices: Código:
//En vez de rgpOpciones[Length(rgpOpciones)] actOpciones[Length(actOpciones)] //debe ser rgpOpciones[Length(rgpOpciones) - 1] actOpciones[Length(actOpciones) - 1] Muchas gracias. |
#3
|
||||
|
||||
Movido de foro.
__________________
Germán Estévez => Web/Blog Guía de estilo, Guía alternativa Utiliza TAG's en tus mensajes. Contactar con el Clubdelphi P.D: Más tiempo dedicado a la pregunta=Mejores respuestas. |
|
|
Temas Similares | ||||
Tema | Autor | Foro | Respuestas | Último mensaje |
PopupMenu !!! | Ledian_Fdez | OOP | 6 | 08-11-2010 23:12:54 |
PopupMenu | cmfab | Varios | 1 | 01-11-2010 23:00:18 |
El PopupMenu | skinnerpro | OOP | 4 | 16-10-2007 01:47:30 |
popupMenu | jorodgar | Varios | 7 | 20-04-2005 17:16:22 |
PopupMenu & MenuItems (URGENTE !!!) | jymy788 | Varios | 2 | 31-08-2004 14:59:28 |
|