home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 September / Chip_2002-09_cd1.bin / zkuste / vbasic / Data / Utils / XZipComp.exe / XceedEncoding.Cab / F112887_unMain.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-05-04  |  5.3 KB  |  142 lines

  1. /*
  2.   Xceed Binary Encoding Library - Encoding/Decoding Manager sample
  3.   Copyright (c) 2001 Xceed Software Inc.
  4.  
  5.   [unMain.h]
  6.  
  7.   This sample demonstrate how to encode a file using different kinds of
  8.   encoding methods, and decode and encoded file. It specifically uses:
  9.     - The ProcessFile metho
  10.     - The EndOfLineType, MaxLineLength, ContinueOnInvalidData,
  11.       HeaderDataForkLength, HeaderResourceForkLength, HeaderFilename,
  12.       EncodingFormat and DataFormating properties.
  13.  
  14.   This file is part of the Xceed Binary Encoding Library sample applications.
  15.   The source code in this file is only intended as a supplement to the Xceed
  16.   Binary Encoding Library's documentation, and is provided "as is", without
  17.   warranty of any kind, either expressed or implied.
  18. */
  19.  
  20. //---------------------------------------------------------------------------
  21. #ifndef unMainH
  22. #define unMainH
  23. //---------------------------------------------------------------------------
  24. #include <Classes.hpp>
  25. #include <Controls.hpp>
  26. #include <StdCtrls.hpp>
  27. #include <Forms.hpp>
  28. #include <ComCtrls.hpp>
  29. #include <ExtCtrls.hpp>
  30. #include "XceedBinaryEncodingLib_OCX.h"
  31. #include <Dialogs.hpp>
  32. #include <ShlObj.hpp>
  33. //---------------------------------------------------------------------------
  34.  
  35. // The different encoding methods corresponding to the option buttons.
  36. // The same options are used while decoding and enconding.
  37. enum TEncodingMethod
  38. {
  39.   emUUEncode        = 0,
  40.   emXXEncode        = 1,
  41.   emBase64          = 2,
  42.   emHexaDecimal     = 3,
  43.   emQuotedPrintable = 4,
  44.   emBinHex          = 5
  45. };
  46.  
  47.  
  48. class TfrmManager : public TForm
  49. {
  50. __published:    // IDE-managed Components
  51.   TPageControl  *pgMain;
  52.   TTabSheet     *tabEncode;
  53.   TTabSheet     *tabDecode;
  54.   TLabel        *Label1;
  55.   TLabel        *Label2;
  56.   TLabel        *Label3;
  57.   TLabel        *Label4;
  58.   TLabel        *Label5;
  59.   TLabel        *Label6;
  60.   TEdit         *edtSourceFileToEncode;
  61.   TEdit         *edtDestinationFile;
  62.   TEdit         *edtMaxLineLen;
  63.   TEdit         *edtDecodeFolder;
  64.   TEdit         *edtDecodedFilename;
  65.   TButton       *btBrowseForDecodeFolder;
  66.   TButton       *btBrowseForSource;
  67.   TButton       *btBrowseForDestination;
  68.   TButton       *btEncode;
  69.   TButton       *btAddFilesToDecode;
  70.   TButton       *btRemoveFiles;
  71.   TButton       *btClearList;
  72.   TButton       *btDecode;
  73.   TRadioGroup   *rgMethod;
  74.   TRadioGroup   *rgEndOfLineOptions;
  75.   TGroupBox     *grpEncodeOptions;
  76.   TGroupBox     *grpDecodeOptions;
  77.   TListBox      *lstMessages;
  78.   TListBox      *lstFilesToDecode;
  79.   TCheckBox     *chkContinueOnInvalidData;
  80.   TOpenDialog *xOpenDialog;
  81.   void __fastcall btEncodeClick(TObject *Sender);
  82.   void __fastcall btClearListClick(TObject *Sender);
  83.   void __fastcall chkContinueOnInvalidDataClick(TObject *Sender);
  84.   void __fastcall edtMaxLineLenChange(TObject *Sender);
  85.   void __fastcall rgEndOfLineOptionsClick(TObject *Sender);
  86.   void __fastcall btRemoveFilesClick(TObject *Sender);
  87.   void __fastcall edtSourceFileToEncodeExit(TObject *Sender);
  88.   void __fastcall btBrowseForSourceClick(TObject *Sender);
  89.   void __fastcall btBrowseForDestinationClick(TObject *Sender);
  90.   void __fastcall rgMethodClick(TObject *Sender);
  91.   void __fastcall btAddFilesToDecodeClick(TObject *Sender);
  92.   void __fastcall btDecodeClick(TObject *Sender);
  93.   void __fastcall btBrowseForDecodeFolderClick(TObject *Sender);
  94. private:
  95.   // The valuse chosen by the user that will be used throughout this sample
  96.   long              m_lMaxLineLength;
  97.   EXBEndOfLineType  m_eEndOfLineType;
  98.   bool              m_bContinueOnInvalidData;
  99.  
  100.   // The encoding and decoding methods that will be used
  101.   TEncodingMethod m_eEncodingMethod;
  102.   TEncodingMethod m_eDecodingMethod;
  103.  
  104.   void SetDestinationFileExtension( TEncodingMethod eOldEncodingMethod,
  105.                                     TEncodingMethod eNewEncodingMethod );
  106.   void SetDestinationFilename();
  107.   void AddEncodedFileToList( AnsiString sFilename );
  108.  
  109.   AnsiString ExtractFileExtension( AnsiString sFilename );
  110.   AnsiString RemoveFileExtension ( AnsiString sFilename );
  111.   AnsiString StdFileExtension    ( TEncodingMethod eMethod );
  112.  
  113.   bool EncodeFile( AnsiString       sSourceFilename,
  114.                    TEncodingMethod  eMethod,
  115.                    EXBEndOfLineType eEndOfLineType,
  116.                    long             lMaxLineLength,
  117.                    AnsiString       sEncodedFilename );
  118.  
  119.   bool DecodeFile( TStringList*     pslEncodedFile,
  120.                    int              nNbEncodedFile,
  121.                    TEncodingMethod  eMethod,
  122.                    bool             bContinueOnInvalidData,
  123.                    AnsiString       sDecodeFolder,
  124.                    AnsiString       sDecodedFilename );
  125.  
  126.   static int __stdcall BrowseCallbackProc( HWND   hWnd,
  127.                                            UINT   uMsg,
  128.                                            LPARAM lParam,
  129.                                            LPARAM lpData );
  130.  
  131.   bool BrowseFolder( HWND        hWnd,
  132.                      AnsiString& sFolder,
  133.                      AnsiString  sDesc );
  134.  
  135. public:        // User declarations
  136.   __fastcall TfrmManager(TComponent* Owner);
  137. };
  138. //---------------------------------------------------------------------------
  139. extern PACKAGE TfrmManager *frmManager;
  140. //---------------------------------------------------------------------------
  141. #endif
  142.