home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / edtrcdll / src / imewrp16.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.7 KB  |  101 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #include "stdafx.h"
  20. #include "imewrap.h"
  21. #include "edtiface.h"//for the callbacks
  22. #include "assert.h"
  23.  
  24. /*imewrap.h edtor client wrapper */
  25. /*Dynamic Library wrapper for loading on call*/
  26.  
  27. HINSTANCE           CIMEDll::s_dllinstance=NULL;
  28. unsigned int        CIMEDll::s_refcount=0;
  29. SENDIMEMESSAGE      CIMEDll::s_SendIMEMessage=NULL;
  30. SENDIMEMESSAGEEX    CIMEDll::s_SendIMEMessageEx=NULL;
  31. IMPGETIME           CIMEDll::s_IMPGetIME=NULL;
  32.  
  33.  
  34. CIMEDll::CIMEDll()
  35. {
  36.     HINSTANCE t_instance=LoadLibrary("WINNLS.DLL");
  37.     if (t_instance<=HINSTANCE_ERROR)
  38.     {
  39.         s_dllinstance=NULL;
  40.         s_refcount=0;
  41.         s_SendIMEMessage=NULL;
  42.         s_SendIMEMessageEx=NULL;
  43.         s_IMPGetIME=NULL;
  44.         return;
  45.     }
  46.     s_refcount++;
  47.     //retrieve all proc addresses and place them into holders
  48.     s_IMPGetIME= (IMPGETIME)GetProcAddress(t_instance,"IMPGetIME");
  49.     assert(s_IMPGetIME);
  50.  
  51.     s_SendIMEMessageEx= (SENDIMEMESSAGEEX)GetProcAddress(t_instance,"SendIMEMessageEx");
  52.     assert(s_SendIMEMessageEx);
  53.  
  54.     s_SendIMEMessage= (SENDIMEMESSAGE)GetProcAddress(t_instance,"SendIMEMessage");
  55.     assert(s_SendIMEMessage);
  56.     if (!s_SendIMEMessage||!s_SendIMEMessageEx||!s_IMPGetIME)
  57.         return;
  58.     s_dllinstance=t_instance;
  59. }
  60.  
  61. CIMEDll::~CIMEDll()
  62. {
  63.     if (s_dllinstance!=NULL)
  64.     {
  65.         FreeLibrary(s_dllinstance);
  66.         s_refcount--;
  67.     }
  68.     if (!s_refcount)
  69.         s_dllinstance=NULL;
  70. }
  71.  
  72.  
  73. BOOL
  74. __loadds CIMEDll::IMPGetIME(HWND hWnd,LPIMEPRO p_lpimepro)
  75. {
  76.     if (s_IMPGetIME)
  77.         return (*s_IMPGetIME)(hWnd,p_lpimepro);
  78.     else
  79.         return FALSE;
  80. }
  81.  
  82.  
  83. WORD
  84. __loadds CIMEDll::SendIMEMessage(HWND hWnd,LPARAM p_lparam)
  85. {
  86.     if (s_SendIMEMessage)
  87.         return (*s_SendIMEMessage)(hWnd,p_lparam);
  88.     else
  89.         return FALSE;
  90. }
  91.  
  92.  
  93. LRESULT
  94. __loadds CIMEDll::SendIMEMessageEx(HWND hWnd,LPARAM p_lparam)
  95. {
  96.     if (s_SendIMEMessageEx)
  97.         return (*s_SendIMEMessageEx)(hWnd,p_lparam);
  98.     else
  99.         return FALSE;
  100. }
  101.