procedure TForm1.Timer1Timer(Sender: TObject);
var hWindow :HWnd;
cName : array[0..255] of char;
begin
if Form1.Active then begin
hWindow := Windows.GetFocus;
GetClassName(hWindow, cName, sizeof(cName));
if cName = 'AVL_AVView' then begin
if not ListView1.Focused then Windows.SetFocus(ListView1.Handle);
end;
end;
end;
//=============================================================================
// ファイル選択ダイアログでPDFファイルを選択して表示
//=============================================================================
procedure TForm1.Button1Click(Sender: TObject);
begin
with OpenDialog1 do begin
DefaultExt:='PDF';
Filter:='Acrobat PDFファイル|*.PDF';
Options:=[ofReadOnly];
if Execute then begin
Update;
AcroPDF1.LoadFile(FileName);
AcroPDF1.setShowToolbar(False);
Timer1.Enabled := True;
end;
end;
end;
//=============================================================================
// 表示方式の変更
//=============================================================================
procedure TForm1.Button2Click(Sender: TObject);
begin
if not AcroPDF1.Visible then exit;
if Sender=Button2 then AcroPDF1.setView('fit');
if Sender=Button3 then AcroPDF1.setView('fitwindow');
if Sender=Button4 then AcroPDF1.setView('fith');
if Sender=Button5 then AcroPDF1.setView('fitb');
if Sender=Button6 then AcroPDF1.setView('fitbh');
if Sender=Button7 then AcroPDF1.setView('fitbv');
if Sender=Button8 then AcroPDF1.setView('fitv');
Windows.SetFocus(AFocusControl.Handle);
end;
//=============================================================================
// フォーカス移動のためのタイマーイベント
// PDF文書は,読み込み表示の際,PDF文書にフォーカス移動してしまうのでその対策
//=============================================================================
procedure TForm1.Timer1Timer(Sender: TObject);
var
hWindow :HWnd;
cName : array[0..MAX_PATH - 1] of char;
begin
if Form1.Active then begin
hWindow := Windows.GetFocus;
GetClassName(hWindow, cName, sizeof(cName));
if cName = 'AVL_AVView' then begin
if not AFocusControl.Focused then Windows.SetFocus(AFocusControl.Handle);
end;
end;
end;