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.

328 lines
7.4 KiB

  1. //******************************************************************************
  2. // File: \wacker\tdll\Keyextrn.h Created: 6/2/98 By: Dwayne M. Newsome
  3. //
  4. // Copyright 1998 by Hilgraeve Inc. --- Monroe, MI
  5. // All rights reserved
  6. //
  7. // Description:
  8. // This file provides some external C functions to allow the Emu_Key_Macro
  9. // and Emu_Key_Macro_List classes to be accessed from the C world.
  10. //
  11. // $Revision: 2 $
  12. // $Date: 11/07/00 11:54a $
  13. // $Id: keyextrn.cpp 1.3 1998/09/10 16:10:17 bld Exp $
  14. //
  15. //******************************************************************************
  16. #include <windows.h>
  17. #pragma hdrstop
  18. #include "stdtyp.h"
  19. #ifdef INCL_KEY_MACROS
  20. #include "keymlist.h"
  21. #include "keymacro.h"
  22. extern "C"
  23. {
  24. #include "session.h"
  25. #include "assert.h"
  26. #include "keyutil.h"
  27. #include "mc.h"
  28. }
  29. //
  30. // make sure these functions have C linkage
  31. //
  32. extern "C"
  33. {
  34. int keysAddMacro( const keyMacro * pKeyMacro );
  35. int keysGetKeyCount( void );
  36. int keysGetMacro( int aIndex, keyMacro * pKeyMacro );
  37. int keysFindMacro( const keyMacro * pKeyMacro );
  38. int keysLoadMacroList( HSESSION hSession );
  39. int keysLoadSummaryList( HWND listBox );
  40. int keysRemoveMacro( keyMacro * pKeyMacro );
  41. int keysSaveMacroList( HSESSION hSession );
  42. int keysUpdateMacro( int aIndex, const keyMacro * pKeyMacro );
  43. }
  44. //******************************************************************************
  45. // Method:
  46. // keysAddMacro
  47. //
  48. // Description:
  49. // Adds the specified macro to the list of macros
  50. //
  51. // Arguments:
  52. // pmacro - The macro to be added
  53. //
  54. // Returns:
  55. // 0 if all is ok, -1 if max macros exist, > 0 if duplicate found.
  56. //
  57. // Throws:
  58. // None
  59. //
  60. // Author: Dwayne M. Newsome, 06/09/1998
  61. //
  62. //
  63. int keysAddMacro( const keyMacro * pKeyMacro )
  64. {
  65. Emu_Key_Macro lKeyMacro;
  66. lKeyMacro = pKeyMacro;
  67. return gMacroManager.addMacro( lKeyMacro );
  68. }
  69. //******************************************************************************
  70. // Method:
  71. // keysGetKeyCount
  72. //
  73. // Description:
  74. // returns the number of macros in the list
  75. //
  76. // Arguments:
  77. // void
  78. //
  79. // Returns:
  80. // macro count
  81. //
  82. // Throws:
  83. // None
  84. //
  85. // Author: Dwayne M. Newsome, 6/4/98
  86. //
  87. //
  88. int keysGetKeyCount( void )
  89. {
  90. return gMacroManager.numberOfMacros();
  91. }
  92. //******************************************************************************
  93. // Method:
  94. // keysGetMacro
  95. //
  96. // Description:
  97. // Gets the macro at the specified index and fills in the keyMacro struct
  98. //
  99. // Arguments:
  100. // aIndex - Index of key macro
  101. // pMacro - Key Macro structure to fill in
  102. //
  103. // Returns:
  104. // 0 for failure, non zero success
  105. //
  106. // Throws:
  107. // None
  108. //
  109. // Author: Dwayne M. Newsome, 6/5/98
  110. //
  111. //
  112. int keysGetMacro( int aIndex, keyMacro * pKeyMacro )
  113. {
  114. Emu_Key_Macro lKeyMacro;
  115. lKeyMacro = gMacroManager[ aIndex ];
  116. pKeyMacro->keyName = lKeyMacro.mKey;
  117. pKeyMacro->macroLen = lKeyMacro.mMacroLen;
  118. pKeyMacro->editMode = 0;
  119. pKeyMacro->altKeyValue = 0;
  120. pKeyMacro->altKeyCount = 0;
  121. pKeyMacro->keyCount = 0;
  122. pKeyMacro->insertMode = 0;
  123. pKeyMacro->lpWndProc = 0;
  124. if (lKeyMacro.mMacroLen)
  125. MemCopy( pKeyMacro->keyMacro, lKeyMacro.mKeyMacro,
  126. lKeyMacro.mMacroLen * sizeof(KEYDEF) );
  127. return 1;
  128. }
  129. //******************************************************************************
  130. // Method:
  131. // keysFindMacro
  132. //
  133. // Description:
  134. // Looks for the specified macro in the list and returns the index of the
  135. // macro.
  136. //
  137. // Arguments:
  138. // pKeyMacro - The macro to find
  139. //
  140. // Returns:
  141. // -1 for failue or the index of the specified macro
  142. //
  143. // Throws:
  144. // None
  145. //
  146. // Author: Dwayne M. Newsome, 06/09/1998
  147. //
  148. //
  149. int keysFindMacro( const keyMacro * pKeyMacro )
  150. {
  151. return gMacroManager.find( pKeyMacro->keyName );
  152. }
  153. //******************************************************************************
  154. // Method:
  155. // keysLoadMacroList
  156. //
  157. // Description:
  158. // Loads the macro list from the session file
  159. //
  160. // Arguments:
  161. // hSession - Session handle
  162. //
  163. // Returns:
  164. // 0 if all is ok, -1 for an error
  165. //
  166. // Throws:
  167. // None
  168. //
  169. // Author: Dwayne M. Newsome, 6/4/98
  170. //
  171. //
  172. int keysLoadMacroList( HSESSION hSession )
  173. {
  174. int lResult = gMacroManager.load( hSession );
  175. return lResult;
  176. }
  177. //******************************************************************************
  178. // Method:
  179. // keysLoadSummaryList
  180. //
  181. // Description:
  182. // Loads the key summary list box with all key definitions
  183. //
  184. // Arguments:
  185. // listBox - List box handle of the list box to fill
  186. //
  187. // Returns:
  188. // 0 if an error occurs
  189. //
  190. // Throws:
  191. // None
  192. //
  193. // Author: Dwayne M. Newsome, 6/4/98
  194. //
  195. //
  196. int keysLoadSummaryList( HWND listBox )
  197. {
  198. Emu_Key_Macro lMacro;
  199. int listIndex;
  200. SendMessage( listBox, LB_RESETCONTENT, 0, 0 );
  201. for ( int i = 0; i < gMacroManager.numberOfMacros(); i++ )
  202. {
  203. lMacro = gMacroManager[i];
  204. TCHAR lKeyName[2048];
  205. TCHAR lBuffer[2048];
  206. memset( lBuffer, TEXT('\0'), sizeof(lBuffer)/sizeof(TCHAR) );
  207. keysGetDisplayString( &lMacro.mKey, 1, lKeyName, sizeof(lKeyName) );
  208. strcat( lBuffer, lKeyName );
  209. strcat( lBuffer, TEXT("\t") );
  210. keysGetDisplayString( lMacro.mKeyMacro, lMacro.mMacroLen, lKeyName, sizeof(lKeyName) );
  211. strcat( lBuffer, lKeyName );
  212. listIndex = SendMessage( listBox, LB_ADDSTRING, 0, (LPARAM)lBuffer );
  213. assert( listIndex != LB_ERR );
  214. SendMessage( listBox, LB_SETITEMDATA, listIndex, i );
  215. }
  216. return 1;
  217. }
  218. //******************************************************************************
  219. // Method:
  220. // keysRemoveMacro
  221. //
  222. // Description:
  223. // Removes the specified macro from the macro list
  224. //
  225. // Arguments:
  226. // pMacro - Macro to be removed
  227. //
  228. // Returns:
  229. // 0 if an error occurs, non zero if macro is removed.
  230. //
  231. // Throws:
  232. // None
  233. //
  234. // Author: Dwayne M. Newsome, 6/5/98
  235. //
  236. //
  237. int keysRemoveMacro( keyMacro * pMacro )
  238. {
  239. return gMacroManager.removeMacro( pMacro->keyName );
  240. }
  241. //******************************************************************************
  242. // Method:
  243. // keysSaveMacroList
  244. //
  245. // Description:
  246. // Saves the macro list to the session file
  247. //
  248. // Arguments:
  249. // hSession - Session handle
  250. //
  251. // Returns:
  252. // 0 if all is ok, -1 for an error
  253. //
  254. // Throws:
  255. // None
  256. //
  257. // Author: Dwayne M. Newsome, 6/4/98
  258. //
  259. //
  260. int keysSaveMacroList( HSESSION hSession )
  261. {
  262. return gMacroManager.save( hSession );
  263. }
  264. //******************************************************************************
  265. // Method:
  266. // keysUpdateMacro
  267. //
  268. // Description:
  269. // Updates the macro at the specified index and fills in the keyMacro struct
  270. //
  271. // Arguments:
  272. // aIndex - Index of key macro
  273. // pMacro - Key Macro structure to use to update
  274. //
  275. // Returns:
  276. // 0 for failure, non zero success
  277. //
  278. // Throws:
  279. // None
  280. //
  281. // Author: Dwayne M. Newsome, 6/5/98
  282. //
  283. //
  284. int keysUpdateMacro( int aIndex, const keyMacro * pKeyMacro )
  285. {
  286. gMacroManager[aIndex] = pKeyMacro;
  287. return 1;
  288. }
  289. #endif