// -------------------------------------------------------------------------- // ========================================================================== // File: TDx9_XFileBinary.CPP // Authors: BCB_Code_Generator v2.00, // Darren Dwyer (source code, documentation, demos, website), // Hugh Edwards (documentation, icons) // Description: This file contains the code for the TDx9_XFileBinary // Component // // "TDx9_XFile_Library v1.00" // (c) 2005 BCB-Tools.com Pty. Ltd., Sydney, Australia. // All Rights Reserved. // // Refer to the 'Licence.Txt' file for licencing & copyright information. // ========================================================================== // -------------------------------------------------------------------------- // #includes ... // -------------------------------------------------------------------------- #include #pragma hdrstop // -------------------------------------------------------------------------- #include "TDx9_XFileBinary.H" // -------------------------------------------------------------------------- #pragma link "TDx_Library_Defns" #pragma link "TDx_Library_Functions" #pragma link "TDx9_XFile_Library_Defns" #pragma link "TDx9_XFile_Library_Functions" // -------------------------------------------------------------------------- // Object Registration... // -------------------------------------------------------------------------- #if (__BORLANDC__ >= 0x0530) // BCB Version 3+ #pragma package(smart_init) #endif // -------------------------------------------------------------------------- static inline void ValidCtrCheck(TDx9_XFileBinary*) { new TDx9_XFileBinary(NULL); } // -------------------------------------------------------------------------- namespace Tdx9_xfilebinary { #if (__BORLANDC__ >= 0x0530) // BCB Version 3+ void __fastcall PACKAGE Register() #else void __fastcall Register() #endif { TComponentClass classes[1] = {__classid(TDx9_XFileBinary)}; RegisterComponents("", classes, 0); } } // -------------------------------------------------------------------------- // Constructor: TDx9_XFileBinary::TDx9_XFileBinary() // Description: The default constructor for the TDx9_XFileBinary object. // -------------------------------------------------------------------------- __fastcall TDx9_XFileBinary::TDx9_XFileBinary(TComponent* Owner) : TDx9_XFileObject(Owner) { fErrorValue = ; fCreated = false; } // -------------------------------------------------------------------------- // Destructor: TDx9_XFileBinary::~TDx9_XFileBinary() // Description: The destructor for the TDx9_XFileBinary object. // -------------------------------------------------------------------------- __fastcall TDx9_XFileBinary::~TDx9_XFileBinary() { // destroy internals if (Created) Destroy(); } // -------------------------------------------------------------------------- // Property: Created // Description: The Created property is true if the internal // LPIDIRECTXFILEBINARY used in this component has been // successfully created, otherwise Created is false. // // To create the internal LPIDIRECTXFILEBINARY, call the // TDx9_XFileBinary::Create() method. // -------------------------------------------------------------------------- bool __fastcall TDx9_XFileBinary::FGetCreated() { return fCreated; } // -------------------------------------------------------------------------- void __fastcall TDx9_XFileBinary::FSetCreated( bool pCreated ) { fCreated = (pCreated && (fLPIDIRECTXFILEBINARY==NULL)); } // -------------------------------------------------------------------------- // Property: ErrorValue // Description: The ErrorValue property contains the last error value // returned from a call to a TDx9_XFileBinary method or // fget/fset. eg. or DDERR_SURFACELOST or TDX_ERROR // -------------------------------------------------------------------------- HRESULT __fastcall TDx9_XFileBinary::FGetErrorValue() { return fErrorValue; } // -------------------------------------------------------------------------- void __fastcall TDx9_XFileBinary::FSetErrorValue( HRESULT pErrorValue ) { fErrorValue = pErrorValue; } // -------------------------------------------------------------------------- // Method: Create() // Description: The Create() method is used to automatically create the // internal LPIDIRECTXFILEBINARY interface used in the // TDx9_XFileBinary component and must be called before any // methods of the TDx9_XFileBinary component will function. // -------------------------------------------------------------------------- bool __fastcall TDx9_XFileBinary::Create() { fCreated = true; if (fCreated && FOnCreate) FOnCreate(this); return fCreated; } // -------------------------------------------------------------------------- // Method: Destroy() // Description: The Destroy() method is used to automatically destroy the // internal LPIDIRECTXFILEBINARY interface used in the // TDx9_XFileBinary component and should be called when the // internal interface is no longer required. // // Note: This method is called by the component's destructor. // -------------------------------------------------------------------------- bool __fastcall TDx9_XFileBinary::Destroy() { fCreated = false; if (FOnDestroy) FOnDestroy(this); return !fCreated; } // -------------------------------------------------------------------------- // Method: GetId() // Description: The GetId method is used to ... // Params: pGuid - // The Guid parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_XFileBinary::GetId( GUID* pGuid ) { // Original Function Definition // HRESULT GetId( // LPGUID pGuid // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetId()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPIDIRECTXFILEBINARY->GetId( (LPGUID) pGuid ); // Handle any Known Results if (fErrorValue!=) { // Failure. if (FOnError) FOnError( this, Name+"::GetId()", TDx9_XFile_Library_ErrorString(fErrorValue), TDx9_XFile_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetMimeType() // Description: The GetMimeType method is used to ... // Params: pMimeType - // The MimeType parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_XFileBinary::GetMimeType( AnsiString** pMimeType ) { // Original Function Definition // HRESULT GetMimeType( // LPCSTR *pszMimeType // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetMimeType()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPIDIRECTXFILEBINARY->GetMimeType( (LPCSTR*) pMimeType ); // Handle any Known Results if (fErrorValue!=) { // Failure. if (FOnError) FOnError( this, Name+"::GetMimeType()", TDx9_XFile_Library_ErrorString(fErrorValue), TDx9_XFile_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetName() // Description: The GetName method is used to ... // Params: pNameBuf - // The NameBuf parameter ... // pBufLen - // The BufLen parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_XFileBinary::GetName( AnsiString* pNameBuf, dword* pBufLen ) { // Original Function Definition // HRESULT GetName( // LPSTR pstrNameBuf, // LPDWORD pdwBufLen // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetName()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Translate Parameters before calling Original Function AnsiString TempNameBuf = pNameBuf; // Call Original Function fErrorValue = (uint) fLPIDIRECTXFILEBINARY->GetName( (LPSTR) TempNameBuf.c_str(), (LPDWORD) pBufLen ); // Handle any Known Results if (fErrorValue!=) { // Failure. if (FOnError) FOnError( this, Name+"::GetName()", TDx9_XFile_Library_ErrorString(fErrorValue), TDx9_XFile_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: GetSize() // Description: The GetSize method is used to ... // Params: pSize - // The Size parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_XFileBinary::GetSize( dword* pSize ) { // Original Function Definition // HRESULT GetSize( // DWORD *pcbSize // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::GetSize()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPIDIRECTXFILEBINARY->GetSize( (DWORD*) pSize ); // Handle any Known Results if (fErrorValue!=) { // Failure. if (FOnError) FOnError( this, Name+"::GetSize()", TDx9_XFile_Library_ErrorString(fErrorValue), TDx9_XFile_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Method: Read() // Description: The Read method is used to ... // Params: pData - // The Data parameter ... // pSize - // The Size parameter ... // pRead - // The Read parameter ... // -------------------------------------------------------------------------- bool __fastcall TDx9_XFileBinary::Read( void* pData, dword pSize, dword* pRead ) { // Original Function Definition // HRESULT Read( // LPVOID pvData, // DWORD cbSize, // LPDWORD pcbRead // ); // if the component internals are not already created, exit if (!fCreated) { fErrorValue = TDX_NOTCREATED; if (FOnError) FOnError( this, Name+"::Read()", "TDX_NOTCREATED", "The "+Name+" component has not been created successfully." ); return false; } // Call Original Function fErrorValue = (uint) fLPIDIRECTXFILEBINARY->Read( (LPVOID) pData, (DWORD) pSize, (LPDWORD) pRead ); // Handle any Known Results if (fErrorValue!=) { // Failure. if (FOnError) FOnError( this, Name+"::Read()", TDx9_XFile_Library_ErrorString(fErrorValue), TDx9_XFile_Library_ErrorMessage(fErrorValue) ); return false; } // Success! return true; } // -------------------------------------------------------------------------- // Internal Interface Access // -------------------------------------------------------------------------- LPIDIRECTXFILEBINARY __fastcall TDx9_XFileBinary::FGetInternal_LPIDIRECTXFILEBINARY() { return fLPIDIRECTXFILEBINARY; } // -------------------------------------------------------------------------- LPIDIRECTXFILEBINARY* __fastcall TDx9_XFileBinary::FGetInternal_LPIDIRECTXFILEBINARY_Ptr() { return &fLPIDIRECTXFILEBINARY; } // -------------------------------------------------------------------------- void __fastcall TDx9_XFileBinary::FSetInternal_LPIDIRECTXFILEBINARY( LPIDIRECTXFILEBINARY pLPIDIRECTXFILEBINARY ) { if (!fCreated) { fLPIDIRECTXFILEBINARY = pLPIDIRECTXFILEBINARY; fCreated = (fLPIDIRECTXFILEBINARY!=NULL); } } // -------------------------------------------------------------------------- void __fastcall TDx9_XFileBinary::Internal_LPIDIRECTXFILEBINARY_Update() { fCreated = (fLPIDIRECTXFILEBINARY!=NULL); } // --------------------------------------------------------------------------