www.pudn.com > yrsCapture.zip > showcfg.pas


{******************************************************************************} 
{*                                                                            *} 
{*               Adirondack Software & Graphics ShowCfg Unit                  *} 
{*         (C) Copyright Adirondack Software & Graphics 1996-1998             *} 
{*                                                                            *} 
{******************************************************************************} 
 
unit Showcfg;   
 
interface 
 
uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, Buttons, 
  StdCtrls, ExtCtrls, Dialogs, INIFiles, Spin, ComCtrls, JPeg, 
  NetGradient, mmlabel, URL, WizardTree, BrowseDr; 
 
type 
  TViewModifyDlg = class( TForm ) 
    Panel1: TPanel; 
    WizardTree1: TWizardTree; 
    URL1: TURL; 
    Panel3: TPanel; 
    btnNext: TButton; 
    OKBtn: TBitBtn; 
    CancelBtn: TBitBtn; 
    Panel2: TPanel; 
    PageControl1: TPageControl; 
    TabSheet1: TTabSheet; 
    NetGradient1: TNetGradient; 
    GroupBox4: TGroupBox; 
    Label2: TLabel; 
    SpeedButton1: TSpeedButton; 
    Label5: TLabel; 
    SpeedButton2: TSpeedButton; 
    DirField: TEdit; 
    FileDirField: TEdit; 
    GroupBox5: TGroupBox; 
    MMLabel1: TMMLabel; 
    MMLabel2: TMMLabel; 
    TabSheet2: TTabSheet; 
    GroupBox2: TGroupBox; 
    Label1: TLabel; 
    Label3: TLabel; 
    Label4: TLabel; 
    Label6: TLabel; 
    Label10: TLabel; 
    Scale: TComboBox; 
    PixelFormat: TComboBox; 
    ColorSpace: TComboBox; 
    Performance: TComboBox; 
    ProgressiveDisplay: TCheckBox; 
    IncrementalDisplay: TCheckBox; 
    Smoothing: TCheckBox; 
    Stretch: TCheckBox; 
    RadioGroup1: TRadioGroup; 
    JPGRadioButton: TRadioButton; 
    BMPRadioButton: TRadioButton; 
    WMFRadioButton: TRadioButton; 
    GroupBox3: TGroupBox; 
    CompressionQuality1: TSpinEdit; 
    NoneRadioButton: TRadioButton; 
    TabSheet3: TTabSheet; 
    Label7: TLabel; 
    GroupBox1: TGroupBox; 
    Label8: TLabel; 
    Label9: TLabel; 
    SpinButton1: TSpinButton; 
    DelayTimeField: TEdit; 
    NetGradient2: TNetGradient; 
    NetGradient3: TNetGradient; 
    btnBack: TButton; 
    BrowseDirectoryDlg1: TBrowseDirectoryDlg; 
    procedure SpinButton1DownClick( Sender: TObject ); 
    procedure SpinButton1UpClick( Sender: TObject ); 
    procedure DelayTimeFieldChange( Sender: TObject ); 
    procedure SpeedButton1Click( Sender: TObject ); 
    procedure SpeedButton2Click( Sender: TObject ); 
    procedure CompressionQuality1MouseDown( Sender: TObject; Button: TMouseButton; 
      Shift: TShiftState; X, Y: Integer ); 
    procedure SetJPEGOptions( Sender: TObject ); 
    procedure CompressionQuality1MouseUp( Sender: TObject; Button: TMouseButton; 
      Shift: TShiftState; X, Y: Integer ); 
    procedure FormCreate( Sender: TObject ); 
    procedure FormActivate( Sender: TObject ); 
    procedure FormClose( Sender: TObject; var Action: TCloseAction ); 
    procedure WizardTree1Change(Sender: TObject); 
    procedure btnBackClick(Sender: TObject); 
    procedure btnNextClick(Sender: TObject); 
    procedure MMLabel1Click(Sender: TObject); 
    procedure MMLabel2Click(Sender: TObject); 
    procedure PageControl1Change(Sender: TObject); 
  private 
    { Private declarations } 
  public 
    { Public declarations } 
    function Execute : boolean; 
  end; 
 
var 
  ViewModifyDlg: TViewModifyDlg; 
 
implementation 
 
uses Main, SysUtils, GlobalUt, xProcs; 
 
{$R *.DFM} 
 
{==============================================================================} 
function TViewModifyDlg.Execute : boolean; 
{==============================================================================} 
var 
  ApprehendIni: TIniFile; 
begin 
  ApprehendIni :=  TIniFile.Create( ChangeFileExt( Application.ExeName, '.INI' ) ); 
  with ApprehendIni do 
  begin 
      InstallPath := ReadString( 'Program Options','Program Directory', ExtractFilePath( Application.EXEName ) ); 
      FilePath := ReadString( 'Program Options','File Directory', ExtractFilePath( Application.EXEName ) + '\images' ); 
      DelayTime := ReadInteger( 'Program Options','Delay Time', 800 ); 
  end; 
  ApprehendIni.Free; 
  DirField.text := InstallPath; 
  ViewModifyDlg.BrowseDirectoryDlg1.Selection := InstallPath; 
  FileDirField.Text := FilePath; 
  DelayTimeField.Text := IntToStr( DelayTime ); 
  If ShowModal=mrOK then begin 
    InstallPath := DirField.Text; 
    FilePath := FileDirField.Text; 
    DelayTime := StrToInt( DelayTimeField.Text ); 
    // Write changes to INI file 
    ApprehendIni :=  TIniFile.Create( ChangeFileExt( Application.ExeName, '.INI' ) ); 
    with ApprehendIni do 
    begin 
       WriteString( 'Program Options','Program Directory', InstallPath ); 
       WriteString( 'Program Options','File Directory', FilePath ); 
       WriteInteger( 'Program Options','Delay Time', DelayTime ); 
    end; 
    ApprehendIni.Free; 
    DefaultDirectory := FilePath; 
    Result := True; 
    end 
  else Result := False; 
end; 
 
{==============================================================================} 
procedure TViewModifyDlg.SpinButton1DownClick( Sender: TObject ); 
{==============================================================================} 
begin 
   DelayTime := StrToInt( DelayTimeField.Text ); 
   Dec( DelayTime ); 
   DelayTimeField.Text := IntToStr( DelayTime ); 
end; 
 
{==============================================================================} 
procedure TViewModifyDlg.SpinButton1UpClick( Sender: TObject ); 
{==============================================================================} 
begin 
   DelayTime := StrToInt( DelayTimeField.Text ); 
   Inc( DelayTime ); 
   DelayTimeField.Text := IntToStr( DelayTime ); 
end; 
 
{==============================================================================} 
procedure TViewModifyDlg.DelayTimeFieldChange( Sender: TObject ); 
{==============================================================================} 
begin 
   { if edit is not blank then set delay } 
   if DelayTimeField.Text <> '' then begin 
   if DelayTime > 10000 then DelayTime := 10000 else 
      if DelayTime < 0 then DelayTime := 0; 
         DelayTimeField.Text := IntToStr( DelayTime ); 
   end; 
end; 
 
{==============================================================================} 
procedure TViewModifyDlg.SpeedButton1Click( Sender: TObject ); 
{==============================================================================} 
begin 
  BrowseDirectoryDlg1.Selection := DirField.Text; 
  if BrowseDirectoryDlg1.Execute then 
  DirField.Text := BrowseDirectoryDlg1.Selection; 
end; 
 
{==============================================================================} 
procedure TViewModifyDlg.SpeedButton2Click( Sender: TObject ); 
{==============================================================================} 
begin 
  BrowseDirectoryDlg1.Selection := FileDirField.Text; 
  if BrowseDirectoryDlg1.Execute then 
    FileDirField.Text := BrowseDirectoryDlg1.Selection; 
end; 
 
{==============================================================================} 
procedure TViewModifyDlg.CompressionQuality1MouseDown( Sender: TObject; 
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer ); 
{==============================================================================} 
var 
  Temp: Boolean; 
begin 
  Temp := TImage( MainForm.PageControl1.ActivePage.Controls[0] ).Picture.Graphic is TJPEGImage; 
  if Temp then 
    with TJPEGImage( TImage( MainForm.PageControl1.ActivePage.Controls[0] ).Picture.Graphic ) do 
      CompressionQuality:= CompressionQuality1.Value; 
end; 
 
{==============================================================================} 
procedure TViewModifyDlg.SetJPEGOptions( Sender: TObject ); 
{==============================================================================} 
var 
  Temp: Boolean; 
begin 
  Temp := TImage( MainForm.PageControl1.ActivePage.Controls[0] ).Picture.Graphic is TJPEGImage; 
  if Temp then 
    with TJPEGImage( TImage( MainForm.PageControl1.ActivePage.Controls[0] ).Picture.Graphic ) do 
    begin 
      PixelFormat := TJPEGPixelFormat( Self.PixelFormat.ItemIndex ); 
      Scale := TJPEGScale( Self.Scale.ItemIndex ); 
      Grayscale := Boolean( Colorspace.ItemIndex ); 
      Performance := TJPEGPerformance( Self.Performance.ItemIndex ); 
      ProgressiveDisplay := Self.ProgressiveDisplay.Checked; 
      Smoothing := Self.Smoothing.Checked; 
    end; 
  Scale.Enabled := Temp; 
  PixelFormat.Enabled := Temp; 
  Colorspace.Enabled := Temp; 
  Performance.Enabled := Temp; 
  Smoothing.Enabled := Temp; 
  ProgressiveDisplay.Enabled := Temp 
    and TJPEGImage( TImage( MainForm.PageControl1.ActivePage.Controls[0] ).Picture.Graphic ).ProgressiveEncoding; 
  TImage( MainForm.PageControl1.ActivePage.Controls[0] ).IncrementalDisplay := IncrementalDisplay.Checked; 
  TImage( MainForm.PageControl1.ActivePage.Controls[0] ).Stretch := Stretch.Checked; 
end; 
 
{==============================================================================} 
procedure TViewModifyDlg.CompressionQuality1MouseUp( Sender: TObject; 
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer ); 
{==============================================================================} 
Var 
  Temp: Boolean; 
begin 
  Temp := TImage( MainForm.PageControl1.ActivePage.Tag).Picture.Graphic is TJPEGImage; 
  if Temp then 
    with TJPEGImage( TImage( MainForm.PageControl1.ActivePage.Tag).Picture.Graphic ) do 
      CompressionQuality:= CompressionQuality1.Value; 
end; 
 
{==============================================================================} 
procedure TViewModifyDlg.FormCreate( Sender: TObject ); 
{==============================================================================} 
begin 
  Scale.ItemIndex := 0; 
  PixelFormat.ItemIndex := 0; 
  Colorspace.ItemIndex := 0; 
  Performance.ItemIndex := 0; 
  CompressionQuality1.Value := 100; 
end; 
 
{==============================================================================} 
procedure TViewModifyDlg.FormActivate( Sender: TObject ); 
{==============================================================================} 
begin 
  WizardTree1.ItemIndex := PageControl1.ActivePage.TabIndex; 
  case DefaultImageType of 
    0: JPGRadioButton.Checked := true; 
    1: BMPRadioButton.Checked := true; 
    2: WMFRadioButton.Checked := true; 
    3: NoneRadioButton.Checked := true; 
    else 
     NoneRadioButton.Checked := true; 
    end; 
end; 
 
{==============================================================================} 
procedure TViewModifyDlg.FormClose( Sender: TObject; 
  var Action: TCloseAction ); 
{==============================================================================} 
begin 
  with MainForm do begin 
  if JPGRadioButton.Checked then DefaultImageType := 0 else 
    if BMPRadioButton.Checked then DefaultImageType := 1 else 
      if WMFRadioButton.Checked then DefaultImageType := 2; 
        if NoneRadioButton.Checked then DefaultImageType := 3; 
  end; 
end; 
 
{==============================================================================} 
procedure TViewModifyDlg.WizardTree1Change(Sender: TObject); 
{==============================================================================} 
begin 
  PageControl1.ActivePage := PageControl1.Pages[ WizardTree1.ItemIndex ]; 
end; 
 
{==============================================================================} 
procedure TViewModifyDlg.btnBackClick(Sender: TObject); 
{==============================================================================} 
begin 
   PageControl1.SelectNextPage( False ); 
   WizardTree1.ItemIndex := PageControl1.ActivePage.TabIndex; 
end; 
 
{==============================================================================} 
procedure TViewModifyDlg.btnNextClick(Sender: TObject); 
{==============================================================================} 
begin 
   PageControl1.SelectNextPage( True ); 
   WizardTree1.ItemIndex := PageControl1.ActivePage.TabIndex; 
end; 
 
{==============================================================================} 
procedure TViewModifyDlg.MMLabel1Click(Sender: TObject); 
{==============================================================================} 
begin 
  URL1.URLType := utMailto; 
  URL1.URL := 'w2m@netheaven.com'; 
  URL1.Execute; 
end; 
 
{==============================================================================} 
procedure TViewModifyDlg.MMLabel2Click(Sender: TObject); 
{==============================================================================} 
begin 
  URL1.URLType := utHttp; 
  URL1.URL := 'www.software.adirondack.ny.us'; 
  URL1.Execute; 
end; 
 
{==============================================================================} 
procedure TViewModifyDlg.PageControl1Change(Sender: TObject); 
{==============================================================================} 
begin 
  WizardTree1.ItemIndex := PageControl1.ActivePage.TabIndex; 
end; 
 
end.