Hola shoulder.
Para que no tengas dificultad en reproducir el ejemplo usé el documento
La cara oculta de Delphi 4 que podes descargar desde el
FTP de
Club Delphi.
Para el ejemplo usé el componente
TACroPdf pero no tiene relevancia cuál sea, ya que la idea es mostrarte como usar el
TComboBox para obtener el número de página a partir del ítem seleccionado.
Código Delphi
[-]
procedure TForm1.FormCreate(Sender: TObject);
begin
AcroPDF1.LoadFile('La_Cara_Oculta_De_Delphi_4.pdf');
with ComboBox1 do
begin
Clear;
AddItem('PRÓLOGO DEL AUTOR', TObject(19));
AddItem('PRÓLOGO A LA SEGUNDA EDICIÓN', TObject(23));
AddItem('ENTORNO Y HERRAMIENTAS', TObject(27));
AddItem('HERRAMIENTAS Y UTILIDADES', TObject(41));
AddItem('UNIDADES, PROYECTOS Y PAQUETES', TObject(57));
AddItem('SISTEMAS DE BASES DE DATOS', TObject(77));
AddItem('EL MOTOR DE DATOS DE BORLAND', TObject(103));
ItemIndex := 0;
end;
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
var
pag: Integer;
begin
if ComboBox1.ItemIndex <> -1 then
begin
pag := Integer(ComboBox1.Items.Objects[ComboBox1.ItemIndex]);
AcroPDF1.setCurrentPage(pag);
end;
end;
(*) A efecto explicativo, se podría haber escrito:
Código Delphi
[-]
if ComboBox1.ItemIndex <> -1 then
AcroPDF1.setCurrentPage(Integer(ComboBox1.Items.Objects[ComboBox1.ItemIndex]));
Muestra:
Saludos