VMS0100MZ.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include <windows.h>
  4. #define __PLUGIN_DLL_EXPORT__
  5. #include "VMS0100MZ.h"
  6. #include "VMS0400MF.h"
  7. #include "TestFormF.h"
  8. USEFORM("VMS0400MF.cpp", VMS0400M);
  9. #pragma hdrstop
  10. //---------------------------------------------------------------------------
  11. // Important note about DLL memory management when your DLL uses the
  12. // static version of the RunTime Library:
  13. //
  14. // If your DLL exports any functions that pass String objects (or structs/
  15. // classes containing nested Strings) as parameter or function results,
  16. // you will need to add the library MEMMGR.LIB to both the DLL project and
  17. // any other projects that use the DLL. You will also need to use MEMMGR.LIB
  18. // if any other projects which use the DLL will be performing new or delete
  19. // operations on any non-TObject-derived classes which are exported from the
  20. // DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling
  21. // EXE's to use the BORLNDMM.DLL as their memory manager. In these cases,
  22. // the file BORLNDMM.DLL should be deployed along with your DLL.
  23. //
  24. // To avoid using BORLNDMM.DLL, pass string information using "char *" or
  25. // ShortString parameters.
  26. //
  27. // If your DLL uses the dynamic version of the RTL, you do not need to
  28. // explicitly add MEMMGR.LIB as this will be done implicitly for you
  29. //---------------------------------------------------------------------------
  30. #pragma argsused
  31. #define STRICT
  32. #include <windows.h>
  33. #include <algorithm>
  34. using std::min;
  35. using std::max;
  36. #include "gdiplus.h"
  37. #include "GdiplusBase.h" //Ç×»ó ³Ö¾î µÐ´Ù.
  38. class CGdiPlusStarter
  39. {
  40. private:
  41. ULONG_PTR m_gpToken;
  42. public:
  43. bool m_bSuccess;
  44. CGdiPlusStarter()
  45. {
  46. ::CoInitialize(NULL);
  47. Gdiplus::GdiplusStartupInput gpsi;
  48. m_bSuccess = (Gdiplus::GdiplusStartup(&m_gpToken, &gpsi, NULL) == Gdiplus::Ok);
  49. dxInitialize();
  50. }
  51. ~CGdiPlusStarter()
  52. {
  53. dxInitialize();
  54. Gdiplus::GdiplusShutdown(m_gpToken);
  55. ::CoUninitialize();
  56. }
  57. };
  58. CGdiPlusStarter g_gps;
  59. PLUGIN_LIB void __stdcall ShowVmsForm(HWND Owner/*=NULL*/,
  60. HWND Parent/*=NULL*/,
  61. bool AIsMdiChild,
  62. bool bShowModal/*=false*/)
  63. {
  64. TVMS0400M *VMS0400M = NULL;
  65. try
  66. {
  67. VMS0400M = new TVMS0400M((TComponent*)Owner);
  68. if (Parent) VMS0400M->Parent = (TWinControl*)Parent;
  69. if (bShowModal)
  70. {
  71. VMS0400M->ShowModal();
  72. //delete VMS0400M;
  73. VMS0400M = NULL;
  74. }
  75. else
  76. {
  77. VMS0400M->Show();
  78. }
  79. }
  80. catch(...)
  81. {
  82. if (VMS0400M)
  83. {
  84. delete VMS0400M;
  85. VMS0400M = NULL;
  86. }
  87. }
  88. //return (HWND)VMS0400M->Handle;
  89. }
  90. PLUGIN_LIB void __stdcall ShowVmsForm2()
  91. {
  92. TTestForm *TestForm = NULL;
  93. try
  94. {
  95. TestForm = new TTestForm(NULL);
  96. TestForm->ShowModal();
  97. }
  98. catch(...)
  99. {
  100. if (TestForm)
  101. {
  102. delete TestForm;
  103. TestForm = NULL;
  104. }
  105. }
  106. }
  107. PLUGIN_LIB void __stdcall ShowVmsForm3()
  108. {
  109. TTestForm *TestForm = NULL;
  110. try
  111. {
  112. TestForm = new TTestForm(NULL);
  113. TestForm->Show();
  114. }
  115. catch(...)
  116. {
  117. if (TestForm)
  118. {
  119. delete TestForm;
  120. TestForm = NULL;
  121. }
  122. }
  123. }
  124. class SomeClass
  125. {
  126. public:
  127. SomeClass() {
  128. };
  129. ~SomeClass() {
  130. }
  131. public:
  132. };
  133. BOOL WINAPI DllMain(HINSTANCE, DWORD reason, LPVOID)
  134. //int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
  135. {
  136. static SomeClass *someClass = NULL;
  137. if (reason == DLL_PROCESS_ATTACH) {
  138. try {
  139. if (!someClass) {
  140. someClass = new SomeClass();
  141. }
  142. } catch(...) {}
  143. }
  144. else
  145. if (reason == DLL_PROCESS_DETACH) {
  146. try {
  147. if (someClass) {
  148. //delete someClass;
  149. //someClass = NULL;
  150. }
  151. } catch(...) {}
  152. }
  153. return 1;
  154. }
  155. //---------------------------------------------------------------------------