Hola,
El hilo lo puse aquí por la forma gráfica de crear la barra.
Para que se me entienda mi pregunta he creado un código pequeño que trabaja con una BD hecha en Acces muy pequeña y que ambos han de trabajar con el componente de TMS (Barra: OutLookBar)
Código Delphi
[-]
implementation
uses Formulario2;
type
UnArray = array[0..10] of string;
var
x:integer;
A:UnArray;
NuevoBar:TInspectorBar;
const
sqlSubGrupo1 = ' select DISTINCT SubGrupo from Elementos where Tipo = "Metal"';
sqlSubGrupo2 = ' select DISTINCT SubGrupo from Elementos where Tipo = "No Metal"';
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
var
i,j: integer;
begin
x:=0;
ADOQuery1.Active:= False;
ADOQuery1.Sql.text:= sqlSubGrupo1;
ADOQuery1.Active:= True;
with ADOQuery1 do
begin
first;
while not eof do
begin
A[x]:= FieldByName('SubGrupo').Value;
inc(x);
next;
end;
end;
NuevoBar := TInspectorBar.Create(Form2);
NuevoBar.Parent := Form2;
NuevoBar.Align:= alLeft;
for i:= 0 to x-1 do
begin
with NuevoBar.Panels.Add do
begin
NuevoBar.Panels[i].Caption:=A[i];
ItemHeight:= 20;
Style:= psSmallIcon;
Alignment:= taLeftJustify;
HoverCaption:= True;
ADOQuery1.Active:= False;
ADOQuery1.Sql.text := ' select Nombre from Elementos where SubGrupo = "'+ A[i]+'"';
ADOQuery1.Active:= True;
ADOQuery1.First;
for j := 0 to ADOQuery1.RecordCount - 1 do
begin
with Items.Add do
NuevoBar.Panels[i].Items[j].Caption:=ADOQuery1.Fields[0].Value;
ADOQuery1.Next;
end;
end;
NuevoBar.TopPanel:= NuevoBar.Panels.Count;
end;
NuevoBar.Style:= esOffice2003Blue;
Form2.Show;
NuevoBar.OnItemClick:=MiProc1;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
var
i,j: integer;
begin
Form2.Show;
x:=0;
ADOQuery1.Active:= False;
ADOQuery1.Sql.text:= sqlSubGrupo2;
ADOQuery1.Active:= True;
with ADOQuery1 do
begin
first;
while not eof do
begin
A[x]:= FieldByName('SubGrupo').Value;
inc(x);
next;
end;
end;
NuevoBar := TInspectorBar.Create(Form2);
NuevoBar.Parent := Form2;
NuevoBar.Align:= alLeft;
for i:= 0 to x-1 do
begin
with NuevoBar.Panels.Add do
begin
NuevoBar.Panels[i].Caption:=A[i];
ItemHeight:= 20;
Style:= psSmallIcon;
Alignment:= taLeftJustify;
HoverCaption:= True;
ADOQuery1.Active:= False;
ADOQuery1.Sql.text := ' select Nombre from Elementos where SubGrupo = "'+ A[i]+'"';
ADOQuery1.Active:= True;
ADOQuery1.First;
for j := 0 to ADOQuery1.RecordCount - 1 do
begin
with Items.Add do
NuevoBar.Panels[i].Items[j].Caption:=ADOQuery1.Fields[0].Value;
ADOQuery1.Next;
end;
end;
NuevoBar.TopPanel:= NuevoBar.Panels.Count;
end;
NuevoBar.Style:= esOffice2003Blue;
Form2.Show;
NuevoBar.OnItemClick:=MiProc2;
end;
procedure TForm1.MiProc1(Sender: TObject; AInspectorPanel: TInspectorPanel; AInspectorItem: TInspectorItem);
begin
if AInspectorPanel.Index = 0 then
begin
case AInspectorItem.Index of
0: ShowMessage(NuevoBar.Panels[0].Items[0].Caption);
1: ShowMessage(NuevoBar.Panels[0].Items[1].Caption);
2: ShowMessage(NuevoBar.Panels[0].Items[2].Caption);
end;
end;
end;
end.
La pregunta está en el procedure:
Al menos mi persona no conoce otra forma del TMS de crearle el Evento como se ve ahí, bueno lo que está escrito dentro funciona, pero la pregunta se basa en mi código que tiene 2 botones donde cada uno crea el Objeto TMS (Barra OutLook) en tiempo de ejecución con distintos Items (también podía haber sido con distintos Paneles, lo simplifiqué) que capturan de mi BD hecha en Access con 2 consultas diferentes para cada botón, la situación es que como se ve esta Procedure:
El código por dentro es Fijo en CASE, es decir, si supiera la cantidad exacta de los Items, no habría problema en colocarle el NÚMERO de CASOS, pero lo cierto es que si se dan cuenta y prueban el código, se crean DIFERENTES ÍTEMS según se clicke el botón de 'Metales' o 'No Metales'.
¿Cómo encarar esta parte de los Eventos (Case) de la Barra OutLook de TMS para cualquier x-cantidad de Ítemes?
¿Alguna otra sugerencia?
Mas tarde intentaré adjuntarles el archivo con código