home *** CD-ROM | disk | FTP | other *** search
- /*
- Xceed Binary Encoding Library - Encoding/Decoding Manager sample
- Copyright (c) 2001 Xceed Software Inc.
-
- [unMain.h]
-
- This sample demonstrate how to encode a file using different kinds of
- encoding methods, and decode and encoded file. It specifically uses:
- - The ProcessFile metho
- - The EndOfLineType, MaxLineLength, ContinueOnInvalidData,
- HeaderDataForkLength, HeaderResourceForkLength, HeaderFilename,
- EncodingFormat and DataFormating properties.
-
- This file is part of the Xceed Binary Encoding Library sample applications.
- The source code in this file is only intended as a supplement to the Xceed
- Binary Encoding Library's documentation, and is provided "as is", without
- warranty of any kind, either expressed or implied.
- */
-
- //---------------------------------------------------------------------------
- #ifndef unMainH
- #define unMainH
- //---------------------------------------------------------------------------
- #include <Classes.hpp>
- #include <Controls.hpp>
- #include <StdCtrls.hpp>
- #include <Forms.hpp>
- #include <ComCtrls.hpp>
- #include <ExtCtrls.hpp>
- #include "XceedBinaryEncodingLib_OCX.h"
- #include <Dialogs.hpp>
- #include <ShlObj.hpp>
- //---------------------------------------------------------------------------
-
- // The different encoding methods corresponding to the option buttons.
- // The same options are used while decoding and enconding.
- enum TEncodingMethod
- {
- emUUEncode = 0,
- emXXEncode = 1,
- emBase64 = 2,
- emHexaDecimal = 3,
- emQuotedPrintable = 4,
- emBinHex = 5
- };
-
-
- class TfrmManager : public TForm
- {
- __published: // IDE-managed Components
- TPageControl *pgMain;
- TTabSheet *tabEncode;
- TTabSheet *tabDecode;
- TLabel *Label1;
- TLabel *Label2;
- TLabel *Label3;
- TLabel *Label4;
- TLabel *Label5;
- TLabel *Label6;
- TEdit *edtSourceFileToEncode;
- TEdit *edtDestinationFile;
- TEdit *edtMaxLineLen;
- TEdit *edtDecodeFolder;
- TEdit *edtDecodedFilename;
- TButton *btBrowseForDecodeFolder;
- TButton *btBrowseForSource;
- TButton *btBrowseForDestination;
- TButton *btEncode;
- TButton *btAddFilesToDecode;
- TButton *btRemoveFiles;
- TButton *btClearList;
- TButton *btDecode;
- TRadioGroup *rgMethod;
- TRadioGroup *rgEndOfLineOptions;
- TGroupBox *grpEncodeOptions;
- TGroupBox *grpDecodeOptions;
- TListBox *lstMessages;
- TListBox *lstFilesToDecode;
- TCheckBox *chkContinueOnInvalidData;
- TOpenDialog *xOpenDialog;
- void __fastcall btEncodeClick(TObject *Sender);
- void __fastcall btClearListClick(TObject *Sender);
- void __fastcall chkContinueOnInvalidDataClick(TObject *Sender);
- void __fastcall edtMaxLineLenChange(TObject *Sender);
- void __fastcall rgEndOfLineOptionsClick(TObject *Sender);
- void __fastcall btRemoveFilesClick(TObject *Sender);
- void __fastcall edtSourceFileToEncodeExit(TObject *Sender);
- void __fastcall btBrowseForSourceClick(TObject *Sender);
- void __fastcall btBrowseForDestinationClick(TObject *Sender);
- void __fastcall rgMethodClick(TObject *Sender);
- void __fastcall btAddFilesToDecodeClick(TObject *Sender);
- void __fastcall btDecodeClick(TObject *Sender);
- void __fastcall btBrowseForDecodeFolderClick(TObject *Sender);
- private:
- // The valuse chosen by the user that will be used throughout this sample
- long m_lMaxLineLength;
- EXBEndOfLineType m_eEndOfLineType;
- bool m_bContinueOnInvalidData;
-
- // The encoding and decoding methods that will be used
- TEncodingMethod m_eEncodingMethod;
- TEncodingMethod m_eDecodingMethod;
-
- void SetDestinationFileExtension( TEncodingMethod eOldEncodingMethod,
- TEncodingMethod eNewEncodingMethod );
- void SetDestinationFilename();
- void AddEncodedFileToList( AnsiString sFilename );
-
- AnsiString ExtractFileExtension( AnsiString sFilename );
- AnsiString RemoveFileExtension ( AnsiString sFilename );
- AnsiString StdFileExtension ( TEncodingMethod eMethod );
-
- bool EncodeFile( AnsiString sSourceFilename,
- TEncodingMethod eMethod,
- EXBEndOfLineType eEndOfLineType,
- long lMaxLineLength,
- AnsiString sEncodedFilename );
-
- bool DecodeFile( TStringList* pslEncodedFile,
- int nNbEncodedFile,
- TEncodingMethod eMethod,
- bool bContinueOnInvalidData,
- AnsiString sDecodeFolder,
- AnsiString sDecodedFilename );
-
- static int __stdcall BrowseCallbackProc( HWND hWnd,
- UINT uMsg,
- LPARAM lParam,
- LPARAM lpData );
-
- bool BrowseFolder( HWND hWnd,
- AnsiString& sFolder,
- AnsiString sDesc );
-
- public: // User declarations
- __fastcall TfrmManager(TComponent* Owner);
- };
- //---------------------------------------------------------------------------
- extern PACKAGE TfrmManager *frmManager;
- //---------------------------------------------------------------------------
- #endif
-