//--------------------------------------------------------------------------- #include #include #include #include "TPMemory.h" #include "TPDocObject.h" #pragma hdrstop //--------------------------------------------------------------------------- // Important note about DLL memory management when your DLL uses the // static version of the RunTime Library: // // If your DLL exports any functions that pass String objects (or structs/ // classes containing nested Strings) as parameter or function results, // you will need to add the library MEMMGR.LIB to both the DLL project and // any other projects that use the DLL. You will also need to use MEMMGR.LIB // if any other projects which use the DLL will be performing new or delete // operations on any non-TObject-derived classes which are exported from the // DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling // EXE's to use the BORLNDMM.DLL as their memory manager. In these cases, // the file BORLNDMM.DLL should be deployed along with your DLL. // // To avoid using BORLNDMM.DLL, pass string information using "char *" or // ShortString parameters. // // If your DLL uses the dynamic version of the RTL, you do not need to // explicitly add MEMMGR.LIB as this will be done implicitly for you //--------------------------------------------------------------------------- #pragma argsused int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved) { return 1; } //--------------------------------------------------------------------------- bool __fastcall TextLoadFromFile(HANDLE hFile, WideString &Text, int version) { DWORD dwRead; int n; wchar_t *str = NULL; char *ansi_str = NULL; if(version<16){ if (!ReadFile(hFile, &n, sizeof(int), &dwRead, NULL)) return false; if (n > 0) { if ((ansi_str = new char[n + 1]) == NULL) goto fail; ansi_str[n] = 0; if (!ReadFile(hFile, ansi_str, n, &dwRead, NULL)) goto fail; Text = WideString(ansi_str); delete []ansi_str; // delete str; } return true; } else{ if (!ReadFile(hFile, &n, sizeof(int), &dwRead, NULL)) return false; if (n > 0) { if ((str = new wchar_t[n+1]) == NULL) goto fail; str[n] = '\0'; if (!ReadFile(hFile, str, n*sizeof(wchar_t), &dwRead, NULL)) goto fail; Text = WideString(str); delete []str; } return true; } fail: if (ansi_str) delete []ansi_str; if (str) delete [] str; return false; } //--------------------------------------------------------------------------- bool __fastcall ImageLoadFromFile(HANDLE hFile, TTexpiaBitmap *&Image) { DWORD dwRead; int w, h; WORD bpp; RGBQUAD rgb[256]; if (!ReadFile(hFile, &bpp, sizeof(WORD), &dwRead, NULL)) return NULL; if (bpp) { //MessageDlg(temp + " bpp true", mtInformation, TMsgDlgButtons()<Create(w, h, bpp, rgb)) goto fail; } else { if (!Image->Create(w, h, bpp)) goto fail; } //MessageDlg(temp+ " Image->Load before", mtInformation, TMsgDlgButtons()<LoadFromTexpiaFile(hFile, cmZLib)) goto fail; //MessageDlg("Image->Load after", mtInformation, TMsgDlgButtons()<= 8) if (!TextLoadFromFile(hSheafFile, str, version)) goto fail; str = ""; if (version >= 8) if (!TextLoadFromFile(hSheafFile, str, version)) goto fail; str = ""; if (version >= 8) if (!TextLoadFromFile(hSheafFile, str, version)) goto fail; str = ""; if (version >= 8) if (!TextLoadFromFile(hSheafFile, str, version)) goto fail; str = ""; if (version >= 12){ if (!ReadFile(hSheafFile, &StepNumber, sizeof(int), &dwRead, NULL)) goto fail;//for ¾ÆÀ̺ñ ¿ä±¸»çÇ×. } if (!ReadFile(hSheafFile, &n, sizeof(int), &dwRead, NULL)) goto fail; if(version >= 16){ //MessageDlg("¹öÀü 16ÀÌ»ó", mtInformation, TMsgDlgButtons()<0){ // primary ÀÇ À§Ä¡(¾î´À sheetÀÇ ¾î´À object)¶ÇÇÑ Àоî¿Â´Ù. if (!ReadFile(hSheafFile, &PrimaryThumbnailNum, sizeof(int), &dwRead, NULL)) goto fail; //To Do : ThumbnailÀ̹ÌÁö bitmap À̹ÌÁö¸¦ ¾ÐÃàÇØ¼­ Àоî¿Â´Ù. if (!LoadThumbnailImage(hSheafFile,TPBitmap)) goto fail; } else { //ThumbnailÀÌ ¾øÀ»¶§ //MessageDlg("¹öÀü 16ÀÌ»ó thum ¾øÀ½", mtInformation, TMsgDlgButtons()<= 11){ //MessageDlg("¹öÀü 11ÀÌ»ó", mtInformation, TMsgDlgButtons()<0){ // primary ÀÇ À§Ä¡(¾î´À sheetÀÇ ¾î´À object)¶ÇÇÑ Àоî¿Â´Ù. if (!ReadFile(hSheafFile, &PrimaryThumbnailNum, sizeof(int), &dwRead, NULL)) goto fail; //To Do : ThumbnailÀ̹ÌÁö bitmap À̹ÌÁö¸¦ ¾ÐÃàÇØ¼­ Àоî¿Â´Ù. if (!LoadThumbnailImage(hSheafFile,TPBitmap)) goto fail; //MessageDlg("¹öÀü 11ÀÌ»ó À̹ÌÁö Àб⠼º°ø", mtInformation, TMsgDlgButtons()<CreateDC())==NULL) goto fail; if ((dcDst = CreateCompatibleDC(dcSrc)) == NULL) goto fail; if ((ThumbnailBitmap=CreateCompatibleBitmap(dcSrc,TPBitmap->Width,TPBitmap->Height)) == NULL) goto fail; hOldBmp = (HBITMAP)SelectObject(dcDst,ThumbnailBitmap); BitBlt(dcDst, 0, 0, TPBitmap->Width, TPBitmap->Height, dcSrc, 0, 0, SRCCOPY); SelectObject(dcDst,hOldBmp); DeleteDC(dcDst); TPBitmap->DeleteDC(dcSrc); if (TPBitmap){delete TPBitmap; TPBitmap = NULL;} return ThumbnailBitmap; } catch(...) { if (TPBitmap){delete TPBitmap; TPBitmap = NULL;} if (hSheafFile!=INVALID_HANDLE_VALUE) CloseHandle(hSheafFile); return NULL; } fail: if (TPBitmap){delete TPBitmap; TPBitmap = NULL;} if (hSheafFile!=INVALID_HANDLE_VALUE) CloseHandle(hSheafFile); return NULL; } //---------------------------------------------------------------------------