Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

209 lines
6.1 KiB

  1. /****************************************************************************
  2. DLLMAIN.CPP
  3. Owner: cslim
  4. Copyright (c) 1997-1999 Microsoft Corporation
  5. DLL Main entry function
  6. History:
  7. 14-JUL-1999 cslim Copied from IME98 source tree
  8. *****************************************************************************/
  9. #include "precomp.h"
  10. #include "dllmain.h"
  11. #include "ui.h"
  12. #include "hauto.h"
  13. #include "config.h"
  14. #include "winex.h"
  15. #include "hanja.h"
  16. #include "cpadsvr.h"
  17. #include "cimecb.h"
  18. #include "cicero.h"
  19. #include "debug.h"
  20. #if 1 // MultiMonitor support
  21. LPFNMONITORFROMWINDOW g_pfnMonitorFromWindow = NULL;
  22. LPFNMONITORFROMPOINT g_pfnMonitorFromPoint = NULL;
  23. LPFNMONITORFROMRECT g_pfnMonitorFromRect = NULL;
  24. LPFNGETMONITORINFO g_pfnGetMonitorInfo = NULL;
  25. #endif
  26. ///////////////////////////////////////////////////////////////////////////////
  27. PRIVATE BOOL APIInitialize();
  28. PRIVATE BOOL LoadMMonitorService();
  29. //PRIVATE BOOL DetachIme();
  30. BOOL vfDllDetachCalled = fFalse;
  31. ///////////////////////////////////////////////////////////////////////////////
  32. // D L L M A I N
  33. BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID pvReserved)
  34. {
  35. switch (dwReason)
  36. {
  37. case DLL_PROCESS_ATTACH:
  38. // init Debugger module
  39. #ifdef _DEBUG
  40. InitDebug();
  41. {
  42. TCHAR sz[128];
  43. GetModuleFileName( NULL, sz, 127 );
  44. DebugOutT(TEXT("IMEKR61.IME - DLL_PROCESS_ATTACH - "));
  45. DebugOutT(sz);
  46. DebugOutT(TEXT("\r\n"));
  47. }
  48. #endif
  49. ///////////////////////////////////////////////////////////////////
  50. // Initialize per process data
  51. vpInstData = &vInstData;
  52. vpInstData->hInst = hinstDLL;
  53. vpInstData->dwSystemInfoFlags = 0;
  54. ///////////////////////////////////////////////////////////////////
  55. // Default value of fISO10646
  56. // Default enable 11,172 Hangul.
  57. // CONFIRM: How to set default of this value for Win95???
  58. vpInstData->fISO10646 = fTrue;
  59. vpInstData->f16BitApps = fFalse;
  60. // Load IMM32
  61. StartIMM();
  62. // Initialize Shared memory
  63. CIMEData::InitSharedData();
  64. // Initialize proc
  65. APIInitialize();
  66. // Initialize UI
  67. RegisterImeUIClass(vpInstData->hInst);
  68. // init common control
  69. InitCommonControls();
  70. // Init UI TLS
  71. OnUIProcessAttach();
  72. // Init IME Pad
  73. CImePadSvr::OnProcessAttach((HINSTANCE)hinstDLL);
  74. break;
  75. case DLL_PROCESS_DETACH:
  76. vfDllDetachCalled = fTrue;
  77. // IImeCallBack
  78. CImeCallback::Destroy();
  79. // IME Pad
  80. CImePadSvr::OnProcessDetach();
  81. // UnInit UI TLS
  82. OnUIProcessDetach();
  83. // UI uninitialization
  84. UnregisterImeUIClass(vpInstData->hInst);
  85. // Close lex file if has opened ever.
  86. CloseLex();
  87. // Close shared memory
  88. CIMEData::CloseSharedMemory();
  89. // Unload IMM32
  90. EndIMM();
  91. #ifdef _DEBUG
  92. {
  93. TCHAR sz[128];
  94. GetModuleFileName(NULL, sz, 127);
  95. DebugOutT(TEXT("IMEKR.IME - DLL_PROCESS_DETACH - "));
  96. DebugOutT( sz );
  97. DebugOutT(TEXT("\r\nBye! See you again! *-<\r\nModule name: "));
  98. DebugOutT(sz);
  99. }
  100. // Comment out _CRT_INIT call due to AV in KERNEL32.DLL on Win9x.
  101. //_CRT_INIT(hinstDLL, dwReason, pvReserved);
  102. #endif // _DEBUG
  103. break;
  104. case DLL_THREAD_ATTACH:
  105. #ifdef _DEBUG
  106. DebugOutT(TEXT("DllMain() : DLL_THREAD_ATTACH"));
  107. #endif
  108. CImePadSvr::OnThreadAttach();
  109. break;
  110. case DLL_THREAD_DETACH:
  111. #ifdef _DEBUG
  112. DebugOutT(TEXT("DllMain() : DLL_THREAD_DETACH"));
  113. #endif
  114. CImePadSvr::OnThreadDetach();
  115. OnUIThreadDetach();
  116. break;
  117. }
  118. return fTrue;
  119. }
  120. /*----------------------------------------------------------------------------
  121. APIInitialize
  122. Init UI and detect 16 bit apps
  123. ----------------------------------------------------------------------------*/
  124. PRIVATE BOOL APIInitialize()
  125. {
  126. DWORD dwType = 1;
  127. #ifdef DEBUG
  128. DebugOutT(TEXT("APIInitialize()\r\n"));
  129. #endif
  130. // System support Unicode? Win98 and NT support Unicode IME
  131. vfUnicode = IsUnicodeUI();
  132. // Register private window messages
  133. InitPrivateUIMsg();
  134. // Load MultiMonitor procs
  135. LoadMMonitorService();
  136. return fTrue;
  137. }
  138. ///////////////////////////////////////////////////////////////////////////////
  139. BOOL LoadMMonitorService()
  140. {
  141. #if 1 // MultiMonitor support
  142. HMODULE hUser32;
  143. #endif
  144. #ifdef DEBUG
  145. OutputDebugString(TEXT("LoadMMonitorService: \r\n"));
  146. #endif
  147. #if 1 // MultiMonitor support
  148. //////////////////////////////////////////////////////////////////////////
  149. // Load Multimonitor functions
  150. //////////////////////////////////////////////////////////////////////////
  151. if ((hUser32 = GetModuleHandle(TEXT("USER32"))) &&
  152. (*(FARPROC*)&g_pfnMonitorFromWindow = GetProcAddress(hUser32,"MonitorFromWindow")) &&
  153. (*(FARPROC*)&g_pfnMonitorFromRect = GetProcAddress(hUser32,"MonitorFromRect")) &&
  154. (*(FARPROC*)&g_pfnMonitorFromPoint = GetProcAddress(hUser32,"MonitorFromPoint")) &&
  155. (*(FARPROC*)&g_pfnGetMonitorInfo = GetProcAddress(hUser32,"GetMonitorInfoA")))
  156. {
  157. return fTrue;
  158. }
  159. else
  160. {
  161. g_pfnMonitorFromWindow = NULL;
  162. g_pfnMonitorFromRect = NULL;
  163. g_pfnMonitorFromPoint = NULL;
  164. g_pfnGetMonitorInfo = NULL;
  165. return fFalse;
  166. }
  167. #endif
  168. }