BOOK1632.H
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:12k
源码类别:

Windows编程

开发平台:

Visual C++

  1. /*
  2.  * BOOK1632.H
  3.  *
  4.  * Macros and other definitions that assist in porting between Win16
  5.  * and Win32 applications.  Defines WIN32 to enable 32-bit versions.
  6.  *
  7.  * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  8.  *
  9.  * Kraig Brockschmidt, Microsoft
  10.  * Internet  :  kraigb@microsoft.com
  11.  * Compuserve:  INTERNET>kraigb@microsoft.com
  12.  */
  13. #ifndef _BOOK1632_H_
  14. #define _BOOK1632_H_
  15. #ifdef WIN32
  16. #ifndef COMMANDPARAMS
  17. #define COMMANDPARAMS(wID, wCode, hWndMsg)                          
  18.     WORD        wID     = LOWORD(wParam);                           
  19.     WORD        wCode   = HIWORD(wParam);                           
  20.     HWND        hWndMsg = (HWND)(UINT)lParam;
  21. #endif  //COMMANDPARAMS
  22. #ifndef SendCommand
  23. #define SendCommand(hWnd, wID, wCode, hControl)                     
  24.             SendMessage(hWnd, WM_COMMAND, MAKEWPARAM(wID, wCode)    
  25.                         , (LPARAM)hControl)
  26. #endif  //SendCommand
  27. #ifndef MENUSELECTPARAMS
  28. #define MENUSELECTPARAMS(wID, wFlags, hMenu)                        
  29.     WORD        wID     = LOWORD(wParam);                           
  30.     WORD        wFlags  = HIWORD(wParam);                           
  31.     HMENU       hMenu   = (HMENU)lParam;
  32. #endif  //MENUSELECTPARAMS
  33. #ifndef SendMenuSelect
  34. #define SendMenuSelect(hWnd, wID, wFlags, hMenu)                    
  35.             SendMessage(hWnd, WM_MENUSELECT                         
  36.                 , MAKEWPARAM((WORD)wID, (WORD)wFlags), (LPARAM)hMenu)
  37. #endif  //SendMenuSelect
  38. #ifndef SendScrollPosition
  39. #define SendScrollPosition(hWnd, iMsg, iPos)                        
  40.             SendMessage(hWnd, iMsg, MAKEWPARAM(SB_THUMBPOSITION, iPos), 0)
  41. #endif //SendScrollPosition
  42. #ifndef ScrollThumbPosition
  43. #define ScrollThumbPosition(w, l) HIWORD(w)
  44. #endif //ScrollThumbPosition
  45. #ifndef GETWINDOWINSTANCE
  46. #define GETWINDOWINSTANCE(h) (HINSTANCE)GetWindowLong(h, GWL_HINSTANCE)
  47. #endif  //GETWINDOWINSTANCE
  48. #ifndef GETWINDOWID
  49. #define GETWINDOWID(h) (UINT)GetWindowLong(h, GWW_ID)
  50. #endif  //GETWINDOWID
  51. #ifndef POINTFROMLPARAM
  52. #define POINTFROMLPARAM(p, l) {p.x=(LONG)(SHORT)LOWORD(l); 
  53.                                p.y=(LONG)(SHORT)HIWORD(l);}
  54. #endif  //POINTFROMLPARAM
  55. #ifndef MDISETMENU
  56. #define MDISETMENU(h, hM, hMW)  SendMessage(h, WM_MDISETMENU 
  57.                                     , (WPARAM)hM, (LPARAM)hMW);
  58. #endif  //MDISETMENU
  59. #ifndef MDIREFRESHMENU
  60. #define MDIREFRESHMENU(h) SendMessage(h, WM_MDIREFRESHMENU, 0, 0L)
  61. #endif  //MDIREFRESHMENU
  62. //Activated child window in WM_MDIACTIVATE
  63. #ifndef NEWMDIACTIVE
  64. #define NEWMDIACTIVE lParam
  65. #endif  //NEWMDIACTIVE
  66. #ifndef UNICODETOANSI
  67. #ifdef UNICODE
  68. #define UNICODETOANSI(s, d, cch) WideCharToMultiByte(CP_ACP 
  69.             , 0, s, -1, d, cch, NULL, NULL)
  70. #else  //ANSI
  71. #define UNICODETOANSI(s, d, cch) lstrcpy(d, (LPTSTR)s);
  72. #endif
  73. #endif //UNICODETOANSI
  74. #ifndef ANSITOUNICODE
  75. #ifdef UNICODE
  76. #define ANSITOUNICODE(s, d, cch) MultiByteToWideChar(CP_ACP 
  77.             , 0, s, -1, d, cch)
  78. #else //ANSI
  79. #define ANSITOUNICODE(s, d, cch) lstrcpy(d, (LPTSTR)s);
  80. #endif
  81. #endif  //ANSITOUNICODE
  82. #ifndef SETMESSAGEQUEUE
  83. #define SETMESSAGEQUEUE
  84. #endif
  85. #ifndef CHECKVER_COM
  86. #define CHECKVER_COM
  87. #endif  //CHECKVER_COM
  88. #ifndef CHECKVER_OLE
  89. #define CHECKVER_OLE
  90. #endif  //CHECKVER_OLE
  91. //****END WIN32
  92. #else
  93. //****START !WIN32
  94. #ifndef POINTS
  95. typedef POINT POINTS;
  96. #endif  //POINTS
  97. #ifndef LPPOINTS
  98. typedef POINTS FAR *LPPOINTS;
  99. #endif  //LPPOINTS
  100. #ifndef MAKEPOINTS
  101. #define MAKEPOINTS MAKEPOINT
  102. #endif  //MAKEPOINTS
  103. #ifndef COMMANDPARAMS
  104. #define COMMANDPARAMS(wID, wCode, hWndMsg)                          
  105.     WORD        wID     = LOWORD(wParam);                           
  106.     WORD        wCode   = HIWORD(lParam);                           
  107.     HWND        hWndMsg = (HWND)(UINT)lParam;
  108. #endif  //COMMANDPARAMS
  109. #ifndef SendCommand
  110. #define SendCommand(hWnd, wID, wCode, hControl)                     
  111.             SendMessage(hWnd, WM_COMMAND, wID                       
  112.                         , MAKELONG(hControl, wCode))
  113. #endif  //SendCommand
  114. #ifndef MENUSELECTPARAMS
  115. #define MENUSELECTPARAMS(wID, wFlags, hMenu)                        
  116.     WORD        wID     = LOWORD(wParam);                           
  117.     WORD        wFlags  = LOWORD(lParam);                           
  118.     HMENU       hMenu   = (HMENU)HIWORD(lParam);
  119. #endif  //MENUSELECTPARAMS
  120. #ifndef SendMenuSelect
  121. #define SendMenuSelect(hWnd, wID, wFlags, hMenu)                    
  122.             SendMessage(hWnd, WM_MENUSELECT, wID                    
  123.                         , MAKELONG((WORD)wFlags, (WORD)hMenu))
  124. #endif  //SendMenuSelect
  125. #ifndef SendScrollPosition
  126. #define SendScrollPosition(hWnd, iMsg, iPos)                        
  127.             SendMessage(hWnd, iMsg, SB_THUMBPOSITION, MAKELONG(iPos, 0))
  128. #endif //Send ScrollPosition
  129. #ifndef ScrollThumbPosition
  130. #define ScrollThumbPosition(w, l) LOWORD(l)
  131. #endif //ScrollThumbPosition
  132. #ifndef GETWINDOWINSTANCE
  133. #define GETWINDOWINSTANCE(h) (HINSTANCE)GetWindowWord(h, GWW_HINSTANCE)
  134. #endif  //GETWINDOWINSTANCE
  135. #ifndef GETWINDOWID
  136. #define GETWINDOWID(h) (UINT)GetWindowWord(h, GWW_ID)
  137. #endif  //GETWINDOWID
  138. #ifndef POINTFROMLPARAM
  139. #define POINTFROMLPARAM(p, l) {p.x=LOWORD(l); p.y=HIWORD(l);}
  140. #endif  //POINTFROMLPARAM
  141. #ifndef MDISETMENU
  142. #define MDISETMENU(h, hM, hMW)  SendMessage(h, WM_MDISETMENU 
  143.                      , (WPARAM)FALSE, (LPARAM)MAKELPARAM(hM, hMW))
  144. #endif  //MDISETMENU
  145. #ifndef MDIREFRESHMENU
  146. #define MDIREFRESHMENU(h) SendMessage(h, WM_MDISETMENU, TRUE, 0L)
  147. #endif  //MDIREFRESHMENU
  148. //Activated child window in WM_MDIACTIVATE
  149. #ifndef NEWMDIACTIVE
  150. #define NEWMDIACTIVE wParam
  151. #endif  //NEWMDIACTIVE
  152. //Things not present in Win3.1 SDK but present in Win32 SDK.
  153. #ifndef APIENTRY
  154. #define APIENTRY __export FAR PASCAL
  155. #endif  //APIENTRY
  156. #ifndef USHORT
  157. typedef unsigned short USHORT;
  158. #endif  //USHORT
  159. //These are so we can write ANSI/UNICODE portable code.
  160. #ifndef TCHAR
  161. typedef char TCHAR;
  162. #endif  //TCHAR
  163. #ifndef LPTSTR
  164. typedef TCHAR *LPTSTR;
  165. #endif  //LPTSTR
  166. #ifndef LPCTSTR
  167. typedef const TCHAR *LPCTSTR;
  168. #endif  //LPCTSTR
  169. #ifndef _tcsncpy
  170. #define _tcsncpy strncpy
  171. #endif  //_tcsncpy
  172. #ifndef _tcsstr
  173. #define _tcsstr strstr
  174. #endif  //_tcsstr
  175. #ifndef _tcsrchr
  176. #define _tcsrchr strrchr
  177. #endif  //_tcsrchr
  178. #ifndef _tcsncicmp
  179. #define _tcsncicmp  strnicmp
  180. #endif  //_tcsncicmp
  181. #ifndef _ttoi
  182. #define _ttoi   atoi
  183. #endif  //_ttoi
  184. #ifndef lstrcpyA
  185. #define lstrcpyA lstrcpy
  186. #endif  //lstrcpyA
  187. #ifndef lstrcmpiA
  188. #define lstrcmpiA lstrcmpi
  189. #endif  //lstrcmpiA
  190. #ifndef TEXT
  191. #define TEXT(a) a
  192. #endif  //TEXT
  193. #ifndef ReadFile
  194. #define ReadFile(h, b, c, x, y) _lread(h, b, c)
  195. #endif  //ReadFile
  196. #ifndef CloseHandle
  197. #define CloseHandle(h) _lclose(h)
  198. #endif  //CloseHandle
  199. #ifndef INVALID_HANDLE_VALUE
  200. #define INVALID_HANDLE_VALUE        HFILE_ERROR
  201. #endif  //INVALID_HANDLE_VALUE
  202. #ifndef MAX_PATH
  203. #define MAX_PATH   260
  204. #endif  //MAX_PATH
  205. #ifndef _MAX_PATH
  206. #define _MAX_PATH   MAX_PATH
  207. #endif  //_MAX_PATH
  208. #ifndef RegCreateKeyEx
  209. #define RegCreateKeyEx(h, sz, d, nl1, opt, acc, nl2, ph, nl3)   
  210.         RegCreateKey(h, sz, ph)
  211. #endif  //RegCreateKeyEx
  212. #ifndef RegSetValueEx
  213. #define RegSetValueEx(h, nl, d, rsz, psz, pch)  
  214.         RegSetValue(h, nl, rsz, (LPCSTR)psz, 0)
  215. #endif  //RegSetValueEx
  216. #ifndef wsprintfA
  217. #define wsprintfA wsprintf
  218. #endif  //wsprintfA
  219. #ifndef LoadLibraryA
  220. #define LoadLibraryA LoadLibrary
  221. #endif  //LoadLibraryA
  222. #ifndef MessageBoxA
  223. #define MessageBoxA MessageBox
  224. #endif  //MessageBoxA
  225. #ifndef SetForegroundWindow
  226. #define SetForegroundWindow(h) BringWindowToTop(h)
  227. #endif  //SetForegroundWindow
  228. #ifndef DeleteFile
  229. #define DeleteFile(f)                       
  230.             {                               
  231.             OFSTRUCT    of;                 
  232.             OpenFile(f, &of, OF_DELETE);    
  233.             }
  234. #endif  //DeleteFile
  235. #ifndef UNICODETOANSI
  236. #define UNICODETOANSI(s, d, cch) lstrcpy(d, (LPTSTR)s);
  237. #endif  //UNICODETOANSI
  238. #ifndef ANSITOUNICODE
  239. #define ANSITOUNICODE(s, d, cch) lstrcpy(d, (LPTSTR)s);
  240. #endif  //ANSITOUNICODE
  241. #ifndef SETMESSAGEQUEUE
  242. #define SETMESSAGEQUEUE                                  
  243.             {                                            
  244.             int cMsg=96;                                 
  245.             while (!SetMessageQueue(cMsg) && (cMsg-=8)); 
  246.             }
  247. #endif  //SETMESSAGEQUEUE
  248. #ifdef INC_OLE2
  249. #ifndef CoTaskMemFree
  250. #define CoTaskMemFree(pv)                                       
  251.             {                                                   
  252.             IMalloc *pIMalloc;                                  
  253.             if (SUCCEEDED(CoGetMalloc(MEMCTX_TASK, &pIMalloc))) 
  254.                 {                                               
  255.                 pIMalloc->Free(pv);                             
  256.                 pIMalloc->Release();                            
  257.                 }                                               
  258.             }
  259. #endif  //CoTaskMemFree
  260. #endif
  261. #ifndef CHECKVER_COM
  262. #define CHECKVER_COM                    
  263.             {                           
  264.             DWORD       dwVer;          
  265.                                         
  266.             dwVer=CoBuildVersion();     
  267.                                         
  268.             if (rmm!=HIWORD(dwVer))     
  269.                 return FALSE;           
  270.             }
  271. #endif  //CHECKVER_COM
  272. #ifndef CHECKVER_OLE
  273. #define CHECKVER_OLE                    
  274.             {                           
  275.             DWORD       dwVer;          
  276.                                         
  277.             dwVer=OleBuildVersion();    
  278.                                         
  279.             if (rmm!=HIWORD(dwVer))     
  280.                 return FALSE;           
  281.             }
  282. #endif  //CHECKVER_OLE
  283. //Stolen from Win32 so we can do OLE Controls on Win16
  284. #ifndef FVIRTKEY
  285. #define FVIRTKEY  TRUE
  286. #endif
  287. #ifndef FNOINVERT
  288. #define FNOINVERT 0x02
  289. #endif
  290. #ifndef FSHIFT
  291. #define FSHIFT    0x04
  292. #endif
  293. #ifndef FCONTROL
  294. #define FCONTROL  0x08
  295. #endif
  296. #ifndef FALT
  297. #define FALT      0x10
  298. #endif
  299. #ifndef ACCELL
  300. typedef struct tagACCEL
  301.     {
  302.     BYTE   fVirt;
  303.     WORD   key;
  304.     WORD   cmd;
  305.     } ACCEL, *LPACCEL;
  306. #endif
  307. /*
  308.  * Appeared in OLE2.02 on 16-bit, always in Win32 defined as 1.
  309.  * 0 is the only valid flag on OLE 2.01 and 2.00.
  310.  */
  311. #ifndef ROTFLAGS_REGISTRATIONKEEPSALIVE
  312. #define ROTFLAGS_REGISTRATIONKEEPSALIVE     0
  313. #endif  //ROTFLAGS_REGISTRATIONKEEPSALIVE
  314. #endif  //!WIN32
  315. //These definitions we need regardless of Win16 or Win32
  316. /*
  317.  * May not have these in which case they're irrelevant but
  318.  * we want things to still compile.
  319.  */
  320. #ifndef ACTIVEOBJECT_STRONG
  321. #define ACTIVEOBJECT_STRONG     0
  322. #endif  //ACTIVEOBJECT_STRONG
  323. //If this is not defined, it doesn't exist, so make it zero.
  324. #ifndef ACTIVEOBJECT_WEAK
  325. #define ACTIVEOBJECT_WEAK       0
  326. #endif  //ACTIVEOBJECT_WEAK
  327. typedef struct
  328.     {
  329.     short   left;
  330.     short   top;
  331.     short   right;
  332.     short   bottom;
  333.     } RECTS, FAR *LPRECTS;
  334. #define RECTSTORECT(rs, r) {(r).left=(rs).left;(r).top=(rs).top; 
  335.     (r).right=(rs).right;(r).bottom=(rs).bottom;};
  336. #define RECTTORECTS(r, rs) {(rs).left=(short)(r).left;   
  337.     (rs).top=(short)(r).top;(rs).right=(short)(r).right; 
  338.     (rs).bottom=(short)(r).bottom;};
  339. /*
  340.  * This is for ANSI compiles on Win32, where we HAVE to use
  341.  * a Unicode string literal (so the TEXT macro isn't good enough).
  342.  */
  343. #ifdef WIN32ANSI
  344. #define OLETEXT(x)  L ## x
  345. #else
  346. #define OLETEXT(x)  TEXT(x)
  347. #endif
  348. #endif  //_BOOK1632_H_