home *** CD-ROM | disk | FTP | other *** search
- {Custom Disk Control - for PicBuf's - PB_DiskControl32V1 is 'Formname'. For correct
- Operation the Control must be Displayed using the ShowModal Method:-
-
- If PB_DiskControl32V1.ShowModal = MrOK then
- begin
- ReturnedName := PB_DiskControl32V1.FileName; Filename stores the users selection
- end;
-
- This Causes the Control to be Displayed, and when the user selects the OK button the
- code within the Begin - End Block is Executed. Cancel button Simply Closes the form.
-
- Please Note that the 'Load' and 'Save' Combo Options are not used in this Demo. The
- Image 'Preview' function is enabled. All filenames and Settings of the options
- are written to a INI file on your disk, whenever the form is closed. The INI
- file can be found in your \windows directory, and will carry the name of this
- demo example - Print.INI.
-
- CopyRight Belmont Imaging 1996.
-
- Demo Program by:- Andrew Hutchison 100022,1047@Compuserve.com
-
- All rights reserved. No part of this program may be photocopied, reproduced,
- translated to another programming language or transported to any computer system
- without the prior written consent of Belmont Imaging.
-
- This Demo is provided for use by Media Architects in there Delphi Demo's only.
- The unit must not be re-used without the permission of Media Architects or Belmont
- Imaging. Copyright Belmont Imaging 1996. It is supplied AS-IS. Use at your
- own risk.}
-
- unit UPBDISK;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- FileCtrl, Grids, Outline, DirOutln, StdCtrls, Buttons, ExtCtrls,
- OleCtrls, ImageKnife32, ComCtrls, Spin, INIfiles,OLEAUTO;
-
- type
- TPB_DiskControl32V1 = class(TForm)
- PB_File_List: TFileListBox;
- PB_Selected_Extension: TFilterComboBox;
- PB_Selected_Drive: TDriveComboBox;
- PB_File_Name: TEdit;
- PB_Directory_list: TDirectoryListBox;
- PB_Directory_Label: TLabel;
- PB_Filename_Label: TLabel;
- PB_Dir_Label: TLabel;
- PB_Disk_OK_Icon: TBitBtn;
- PB_Disk_Cancel_Icon: TBitBtn;
- PB_Preview_Panel: TPanel;
- PB_Preview_Image: TPicbuf;
- PB_Preview: TCheckBox;
- PB_JPG_Options: TGroupBox;
- PB_JPG_VALUE: TSpinEdit;
- PB_Write_Options: TComboBox;
- PB_Fractel_Options: TGroupBox;
- PB_FIF_Height: TSpinEdit;
- PB_FIF_Width: TSpinEdit;
- PB_FIF_Options: TComboBox;
- PB_FIF_Scale: TComboBox;
- PB_Bevel_Frame: TBevel;
- PB_Commonpalette: TCheckBox;
- procedure PB_Disk_Cancel_IconClick(Sender: TObject);
- procedure PB_Disk_OK_IconClick(Sender: TObject);
- procedure PB_File_ListClick(Sender: TObject);
- procedure PB_PreviewClick(Sender: TObject);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure FormCreate(Sender: TObject);
- procedure PB_Preview_ImageChange(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
-
- FileName:String;{Make Filename Avaialable to Any Unit}
-
- end;
-
- var
- PB_DiskControl32V1: TPB_DiskControl32V1;
-
- {Does file name a have valid Picbuf file extension}
- function ValidPicbufFile(FileName:String):Boolean;
-
- implementation
-
- {$R *.DFM}
-
- {-------------------------------------------------------------------------------}
- {Cancel Button}
- procedure TPB_DiskControl32V1.PB_Disk_Cancel_IconClick(Sender: TObject);
- begin
- {Set Filename to FileList Directory and File Box Text}
- FileName := PB_File_List.Directory;
- if Length(Filename) > 3 then
- Filename := Filename + '\';
- FileName := FileName + PB_File_Name.Text;
- ModalResult := mrCancel;{Modal Result}
- end;
-
- {-------------------------------------------------------------------------------}
- {OK Button}
- procedure TPB_DiskControl32V1.PB_Disk_OK_IconClick(Sender: TObject);
- begin
- {Set Filename to FileList Directory and File Box Text}
- FileName := PB_File_List.Directory;
- if Length(Filename) > 3 then
- Filename := Filename + '\';
- FileName := FileName + PB_File_Name.Text;
- ModalResult := mrOK;{Modal Result}
- end;
-
- {-------------------------------------------------------------------------------}
- {Preview Image - Option Button}
- procedure TPB_DiskControl32V1.PB_File_ListClick(Sender: TObject);
- Var
- Temp : String;
- Valid_File: Boolean;
- begin
- try
- if not PB_Preview.Checked then Exit;{If not Checked Skip}
- if PB_File_List.Filename <> '' then{Is there a FileName}
- begin
- if ValidPicbufFile(PB_File_List.Filename) then {UUtil - Checks for Valid Extension}
- begin
- PB_Preview_Image.Filename:=(PB_file_list.filename);{Set Picbuf FileName}
- PB_Preview_Image.Load;{Load Image Method}
- end;
- end;
- except
- end;
- end;
-
- {-------------------------------------------------------------------------------}
- {Clear buffer if Preview NOT required}
- procedure TPB_DiskControl32V1.PB_PreviewClick(Sender: TObject);
- begin
- if not PB_Preview.Checked then
- PB_Preview_Image.Clear{Empty Buffer}
- else
- PB_DiskControl32V1.PB_File_ListClick(Sender);
- end;
-
- {-------------------------------------------------------------------------------}
- {On Exit Clear Image and Save Options to INI file}
- procedure TPB_DiskControl32V1.FormClose(Sender: TObject;var Action: TCloseAction);
- begin
- With Tinifile.Create(changefileext(extractfilename(Application.Exename),'.INI')) do
- try
- {'Section', Variable Name, Value to store }
- WriteInteger('FileOptions','Jpgcomp',PB_JPG_VALUE.Value);
- WriteInteger('FileOptions','ProgWrite',PB_Write_Options.Itemindex);
- WriteInteger('FileOptions','FifOption',PB_FIF_Options.ItemIndex);
- WriteInteger('FileOptions','FifScale',PB_FIF_Scale.ItemIndex);
- WriteInteger('FileOptions','FifHeight',PB_FIF_Height.Value);
- WriteInteger('FileOptions','FifWidth',PB_FIF_Width.Value);
- WriteBool('FileOptions','Preview',PB_Preview.Checked);
- WriteBool('FileOptions','Common',PB_Commonpalette.Checked);
- WriteString('FileOptions','LastFileLoaded',PB_Diskcontrol32v1.FileName);
- finally
- free;
- end;
- PB_Preview_Image.Clear;
- Application.Processmessages;
- end;
-
- {-------------------------------------------------------------------------------}
- {Read Values from .INI file and apply to controls - when Created}
- procedure TPB_DiskControl32V1.FormCreate(Sender: TObject);
- begin
- With Tinifile.Create(changefileext(extractfilename(Application.Exename),'.INI')) do
- try
- {'Section', Variable Name, Default Value}
- PB_JPG_VALUE.Value:=ReadInteger('FileOptions','Jpgcomp',100);
- PB_Write_Options.Itemindex := ReadInteger('FileOptions','ProgWrite',0);
- PB_FIF_Options.ItemIndex := ReadInteger('FileOptions','FifOption',0);
- PB_FIF_Scale.ItemIndex:= ReadInteger('FileOptions','FifScale',0);
- PB_FIF_Height.Value:= ReadInteger('FileOptions','FifHeight',200);
- PB_FIF_Width.Value:= ReadInteger('FileOptions','FifWidth',200);
- PB_Preview.Checked:=ReadBool('FileOptions','Preview',True);
- PB_Commonpalette.Checked:=ReadBool('FileOptions','Common',False);
- {Set FileName and Control and Main Menu Item to Last File Name}
- PB_Diskcontrol32v1.FileName := ReadString('FileOptions','LastFileLoaded','C:\*.*');
- PB_File_List.Filename := ReadString('FileOptions','LastFileLoaded','C:\*.*');
- finally
- free;
- end;
- end;
-
- {}
- procedure TPB_DiskControl32V1.PB_Preview_ImageChange(Sender: TObject);
- begin
- PB_Preview_Image.Hint:=PB_Preview_Image.InfoImage;
- end;
-
- {-------------------------------------------------------------------------------}
- {Does file name a have valid Picbuf file extension}
- function ValidPicbufFile(FileName:String):Boolean;
- Var
- Temp:String;
- begin
- Result:=False;{Default to NO}
- Temp := UpperCase(Filename);{Convert FileName to Upper Case}
- if Pos('.TGA', Temp ) > 0 then Result:= True;
- if Pos('.BMP', Temp ) > 0 then Result:= True;
- if Pos('.DIB', Temp ) > 0 then Result:= True;
- if Pos('.PCX', Temp ) > 0 then Result:= True;
- if Pos('.JPG', Temp ) > 0 then Result:= True;
- if Pos('.FIF', Temp ) > 0 then Result:= True;
- if Pos('.PNG', Temp ) > 0 then Result:= True;
- if Pos('.GIF', Temp ) > 0 then Result:= True;
- if Pos('.TIF', Temp ) > 0 then Result:= True;
- if Pos('.MSP', Temp ) > 0 then Result:= True;
- end;
-
- end.
-