home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / MFC / src / wceimpl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  13.3 KB  |  430 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. /////////////////////////////////////////////////////////////////////////////
  12. //    WCEIMPL.H
  13. //
  14. // THIS FILE IS FOR MFCCE IMPLEMENTATION ONLY.
  15.  
  16. #ifndef __WCEIMPL_H__
  17. #define __WCEIMPL_H__
  18.  
  19. // Define libraries to be used in MFC and OLE DLLs.
  20. #if (_WIN32_WCE >= 201)
  21.     #pragma comment(lib, "corelibc.lib")
  22.     #pragma comment(linker, "/nodefaultlib:libc.lib")
  23.     #pragma comment(linker, "/nodefaultlib:libcd.lib")
  24.     #pragma comment(linker, "/nodefaultlib:libcmt.lib")
  25.     #pragma comment(linker, "/nodefaultlib:libcmtd.lib")
  26.     #pragma comment(linker, "/nodefaultlib:oldnames.lib")
  27. #else
  28. #ifdef _MT
  29.     #if defined(_DEBUG)
  30.         #pragma comment(lib, "libcmtd.lib")
  31.     #else
  32.         #pragma comment(lib, "libcmt.lib")
  33.     #endif
  34. #else
  35.     #error Please use the /MT switch (multithreaded C-runtime)
  36. #endif
  37. #endif
  38.  
  39.  
  40. #if defined(_AFX_OLE_IMPL)
  41.     #if defined(_DEBUG)
  42.         #pragma comment(lib, WCE_MFC_FILENAME(d.lib))
  43.     #else
  44.         #pragma comment(lib, WCE_MFC_FILENAME(.lib))
  45.     #endif
  46.     #pragma comment(lib, "uuid.lib")
  47. #endif
  48.  
  49. // New front-end compiler complains of empty statements (solitary ;'s)
  50. #pragma warning(disable: 4390)  // empty statements are okay
  51.  
  52. // ctlcore.cpp might contain an empty switch statement depending on pruning macros
  53. #pragma warning(disable: 4060)  // empty statements are okay
  54.  
  55. #pragma comment(lib, "coredll.lib")
  56. #pragma comment(lib, "commctrl.lib")
  57.  
  58. typedef struct tagNCCALCSIZE_PARAMS {
  59.     RECT       rgrc[3];
  60.     PWINDOWPOS lppos;
  61. } NCCALCSIZE_PARAMS, *LPNCCALCSIZE_PARAMS;
  62.  
  63. // Missing typedefs
  64. #ifndef _TIME_T_DEFINED
  65. typedef unsigned long time_t;
  66. #define _TIME_T_DEFINED 
  67. #endif
  68. typedef HANDLE  HDWP;
  69. typedef HANDLE  HDROP;
  70. typedef wchar_t _TUCHAR;
  71. typedef LPVOID  LPPRINTER_DEFAULTS;
  72. typedef LPVOID  LPCHOOSEFONT;
  73. #if (_WIN32_WCE < 210)
  74. typedef LPVOID  LPPAGESETUPDLG;
  75. #endif // _WIN32_WCE < 210
  76. typedef UINT    UWORD;
  77.  
  78. // Missing headers
  79. #include "prsht.h"    
  80.  
  81. // Missing string functions aliases
  82. #ifndef _istlead
  83. #define _istlead(ch) (FALSE)  
  84. #endif
  85. #ifndef _vsnwprintf
  86. #define _vsnwprintf(a,b,c,d) vswprintf(a,c,d)
  87. #endif
  88. #define lstrcmpA     strcmp
  89. #define lstrcatA     strcat
  90. #define _ttoi        _wtoi
  91. #define _itot        _itow
  92. #define _ltot        _ltow
  93. #define _ultot       _ultow
  94. #define lstrlenA     strlen
  95. #define lstrcpyA     strcpy
  96. #define lstrcpyn     _tcsncpy
  97. #define _tcstol      wcstol
  98. #define _tcstoul     wcstoul
  99. #define _tcstod      wcstod
  100. #define strtod       wcstod
  101. #define _tcsdec      _wcsdec
  102. #define _tcsinc      _wcsinc
  103. __inline wchar_t * __cdecl _wcsdec(const wchar_t * start, const wchar_t * current)
  104.     { return (wchar_t *) ( (start>=current) ? NULL : (current-1) ); }
  105. __inline wchar_t * __cdecl _wcsinc(const wchar_t * _pc) { return (wchar_t *)(_pc+1); }
  106. __inline size_t    __cdecl _tclen( const wchar_t *_cpc) { return 2; } // for UNICODE
  107.  
  108. // Missing definitions: not necessary equal to their Win32 values 
  109. // (the goal is to just have a clean compilation of MFC)
  110. #define BS_USERBUTTON             BS_PUSHBUTTON
  111. #define WS_THICKFRAME             WS_DLGFRAME
  112. #define WS_MAXIMIZE               0
  113. #define WS_MINIMIZE               0
  114. #define WS_EX_CONTROLPARENT       0x00010000L
  115. #define WS_EX_LEFTSCROLLBAR       0
  116. #ifndef WS_EX_TOOLWINDOW
  117. #define WS_EX_TOOLWINDOW          0
  118. #endif
  119. #define WS_EX_NOPARENTNOTIFY      0 
  120. #define WM_ENTERIDLE              0x0121
  121. #define WM_PRINT                  WM_PAINT
  122. #define WM_NCCREATE               (0x0081)
  123. #define WM_PARENTNOTIFY           0
  124. #define WM_NCDESTROY              (WM_APP-1)
  125. #ifndef SW_RESTORE
  126. #define SW_RESTORE                (SW_SHOWNORMAL)
  127. #endif
  128. #define SW_NORMAL                 (SW_SHOWNORMAL)
  129. #define SW_SHOWMINNOACTIVE          (SW_HIDE)
  130. #define MB_TYPEMASK               (0x0000000FL)
  131. #define MB_ICONMASK               (0x000000F0L)
  132. #define CTLCOLOR_SCROLLBAR        CTLCOLOR_EDIT
  133. #define PSM_CANCELTOCLOSE         (WM_USER + 107)
  134. #define ESB_ENABLE_BOTH           (0x0000)
  135. #define RDW_INVALIDATE            (0x0001)
  136. #define RDW_INTERNALPAINT         (0x0002)
  137. #define RDW_ERASE                 (0x0004)
  138. #define RDW_VALIDATE              (0x0008)
  139. #define RDW_NOINTERNALPAINT       (0x0010)
  140. #define RDW_NOERASE               (0x0020)
  141. #define RDW_NOCHILDREN            (0x0040)
  142. #define RDW_ALLCHILDREN           (0x0080)
  143. #define RDW_UPDATENOW             (0x0100)
  144. #define RDW_ERASENOW              (0x0200)
  145. #define RDW_FRAME                 (0x0400)
  146. #define RDW_NOFRAME               (0x0800)
  147. #ifndef DCX_CACHE
  148. #define DCX_CACHE                 (0x00000002L)
  149. #endif
  150. #define INTERNET_HANDLE_TYPE_GOPHER_FILE -1
  151. #define INTERNET_SERVICE_GOPHER   0
  152. #define WAIT_OBJECT_0             0x00000000L
  153. #define PRF_CHILDREN              0x00000010L
  154. #define PRF_CLIENT                0x00000004L
  155. #define HELP_HELPFILE             (0x0000L)
  156. #define MSGF_MENU                 2
  157. #define pshHelp                   0x040E
  158. #define SM_DBCSENABLED            42 
  159. #define MF_BITMAP                 0x00000004L
  160. #define MF_DISABLED               0
  161. #define FW_REGULAR                FW_NORMAL
  162. #define MB_TASKMODAL              0
  163. #define MB_SYSTEMMODAL            MB_APPLMODAL
  164. #define PDERR_DNDMMISMATCH          0x1009
  165. #define PDERR_DEFAULTDIFFERENT    0x100C
  166. #define IDB_HIST_SMALL_COLOR      8
  167. #define IDB_HIST_LARGE_COLOR      9
  168. #define DEFAULT_GUI_FONT          SYSTEM_FONT
  169. #define SFGAO_LINK                0x00010000L   
  170. #ifndef _MAX_FNAME
  171. #define _MAX_FNAME                 64
  172. #endif
  173. #ifndef SWP_NOREDRAW
  174. #define SWP_NOREDRAW               0
  175. #endif
  176. #ifndef SBS_SIZEBOX
  177. #define SBS_SIZEBOX               0
  178. #endif
  179. #ifndef SBS_SIZEGRIP
  180. #define SBS_SIZEGRIP              0
  181. #endif
  182. #define SC_SIZE                   (0xF000)
  183. #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
  184. #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
  185. #define HWND_TOPMOST              ((HWND)-1)
  186. #define HWND_NOTOPMOST               ((HWND)-2)
  187. #define HCBT_CREATEWND            (3)
  188. #define CC_SHOWHELP               0
  189. #define PS_DOT                    2
  190. #define PD_ALLPAGES               0
  191. #define PD_USEDEVMODECOPIES       0
  192. #define PD_NOSELECTION            0
  193. #define PD_HIDEPRINTTOFILE        0
  194. #define PD_NOPAGENUMS             0
  195. #define CF_METAFILEPICT           3
  196. #define CWP_ALL                   0x0000
  197. #define CWP_SKIPINVISIBLE         0x0001
  198. #define CWP_SKIPDISABLED          0x0002
  199. #define CWP_SKIPTRANSPARENT       0x0004
  200. #define MM_LOMETRIC               2
  201. #define MM_HIMETRIC               3
  202. #define MM_LOENGLISH              4
  203. #define MM_HIENGLISH              5
  204. #define MM_TWIPS                  6
  205. #define MM_ISOTROPIC              7
  206. #define MM_ANISOTROPIC            8
  207. #define OLEUI_FALSE               0
  208. #define OLEUI_SUCCESS             1     
  209. #define OLEUI_OK                  1    
  210. #define OLEUI_CANCEL              2     
  211. #define KF_EXTENDED               0x0100
  212. #define KF_DLGMODE                0x0800
  213. #define KF_MENUMODE               0x1000
  214. #define KF_ALTDOWN                0x2000
  215. #define KF_REPEAT                 0x4000
  216. #define KF_UP                     0x8000
  217. #define IDB_STD_SMALL_MONO        2     
  218. #define IDB_STD_LARGE_MONO        3     
  219. #define IDB_VIEW_SMALL_MONO       6    
  220. #define IDB_VIEW_LARGE_MONO       7  
  221. #define SPI_GETWORKAREA           48
  222. #define LBSELCHSTRING             TEXT("commdlg_LBSelChangedNotify")
  223. #define SHAREVISTRING             TEXT("commdlg_ShareViolation")
  224. #define FILEOKSTRING              TEXT("commdlg_FileNameOK")
  225. #define COLOROKSTRING             TEXT("commdlg_ColorOK")
  226. #define SETRGBSTRING              TEXT("commdlg_SetRGBColor")
  227. #define HELPMSGSTRING             TEXT("commdlg_help")
  228. #define FINDMSGSTRING             TEXT("commdlg_FindReplace")
  229. #define DRAGLISTMSGSTRING         TEXT("commctrl_DragListMsg")
  230.  
  231. // Provide zero values for unsupported GetOpenFileName flags
  232. #define OFN_ENABLESIZING 0
  233. #if defined(_WIN32_WCE_PSPC)
  234.     #define OFN_READONLY          0
  235.     #define OFN_ENABLEHOOK        0
  236.     #define OFN_ENABLETEMPLATE    0
  237.     #define OFN_ALLOWMULTISELECT  0
  238. #endif // _WIN32_WCE_PSPC
  239.  
  240. #if defined(_WIN32_WCE_PSPC)
  241.     #define BM_GETIMAGE           0x00F6
  242.     #define BM_SETIMAGE           0x00F7
  243. #endif // _WIN32_WCE_PSPC
  244.  
  245.  
  246. #ifndef WM_SETCURSOR
  247.     #define WM_SETCURSOR 0x0020
  248.     #define IDC_ARROW           MAKEINTRESOURCE(32512)
  249.     #define IDC_IBEAM           MAKEINTRESOURCE(32513)
  250.     #define IDC_WAIT            MAKEINTRESOURCE(32514)
  251.     #define IDC_CROSS           MAKEINTRESOURCE(32515)
  252.     #define IDC_UPARROW         MAKEINTRESOURCE(32516)
  253.     #define IDC_SIZE            MAKEINTRESOURCE(32646)
  254.     #define IDC_ICON            MAKEINTRESOURCE(32512)
  255.     #define IDC_SIZENWSE        MAKEINTRESOURCE(32642)
  256.     #define IDC_SIZENESW        MAKEINTRESOURCE(32643)
  257.     #define IDC_SIZEWE          MAKEINTRESOURCE(32644)
  258.     #define IDC_SIZENS          MAKEINTRESOURCE(32645)
  259.     #define IDC_SIZEALL         MAKEINTRESOURCE(32646)
  260.     #define IDC_NO              MAKEINTRESOURCE(32648)
  261.     #define IDC_APPSTARTING     MAKEINTRESOURCE(32650)
  262.     #define IDC_HELP            MAKEINTRESOURCE(32651)
  263.     #define IDC_HAND            MAKEINTRESOURCE(32649)
  264. #endif 
  265.  
  266.  
  267.  
  268. inline HINSTANCE wce_GetModuleHandleW(LPCWSTR lpModuleName)
  269. {
  270. #if (_WIN32_WCE >= 210)
  271.     return GetModuleHandleW(lpModuleName);
  272. #else // _WIN32_WCE
  273.     HINSTANCE hInst = LoadLibraryW(lpModuleName);
  274.     if(hInst)
  275.         FreeLibrary(hInst);
  276.     return hInst;
  277. #endif // _WIN32_WCE
  278. }
  279.  
  280. inline HICON wce_ExtractIcon(HINSTANCE hInst, LPCWSTR lpszExeFileName, UINT nIconIndex)
  281. {
  282.     return (HICON)::ExtractIconEx(lpszExeFileName, nIconIndex, NULL, NULL, 1);
  283. }
  284.  
  285. inline int wce_MulDiv(int nNumber, int nNumerator, int nDenominator)
  286. {
  287.     __int64 x;
  288.  
  289.     x = (__int64)nNumber * (__int64)nNumerator;
  290.     x /= (__int64)nDenominator;
  291.  
  292.     return (int)x;
  293. }
  294.  
  295. inline HINSTANCE wce_GetModuleHandleA(LPCSTR lpModuleName)
  296. {
  297.     HINSTANCE hInst;
  298.  
  299.     TCHAR *szwBuf = wce_AsciiToWide(lpModuleName);
  300.     hInst = wce_GetModuleHandleW(szwBuf);
  301.     delete[] szwBuf;
  302.  
  303.     return hInst;
  304. }
  305.  
  306. inline short wce_GetFileTitle(LPCTSTR lpszFile, LPTSTR lpszTitle, WORD cbBuf)
  307. {
  308.     return wce_GetFileTitleW(lpszFile, lpszTitle, cbBuf);
  309. }
  310.  
  311. #define GMEM_MOVEABLE             0
  312. #define GMEM_SHARE                0
  313. #define GMEM_FIXED                LMEM_FIXED
  314. #define GMEM_ZEROINIT             LMEM_ZEROINIT
  315. #define GMEM_INVALID_HANDLE       LMEM_INVALID_HANDLE
  316. #define GMEM_LOCKCOUNT            LMEM_LOCKCOUNT
  317. #define GPTR                      LPTR
  318.  
  319. inline HGLOBAL wce_GlobalAlloc(UINT uFlags, DWORD dwBytes)
  320. {
  321.     UINT uLocalFlags = (uFlags & GMEM_ZEROINIT)? 0 : LMEM_ZEROINIT;
  322.     return (HGLOBAL)::LocalAlloc(uLocalFlags, (UINT)dwBytes);
  323. }
  324.  
  325. inline HGLOBAL wce_GlobalFree(HGLOBAL hMem)
  326. {
  327.     return ::LocalFree((HLOCAL)hMem);
  328. }
  329.  
  330. inline HGLOBAL wce_GlobalReAlloc(HGLOBAL hMem, DWORD dwBytes, UINT uFlags)
  331. {
  332.     UINT uLocalFlags = (uFlags & GMEM_ZEROINIT)? 0 : LMEM_ZEROINIT;
  333.     return (HGLOBAL)::LocalReAlloc((HLOCAL)hMem, uLocalFlags, (UINT)dwBytes);
  334. }
  335.  
  336. inline DWORD wce_GlobalSize(HGLOBAL hMem)
  337. {
  338.     return (DWORD)::LocalSize((HLOCAL)hMem);
  339. }
  340.  
  341. inline LPVOID wce_GlobalLock(HGLOBAL hMem)
  342. {
  343.     return LocalLock((HLOCAL)hMem);
  344. }
  345.  
  346. inline BOOL wce_GlobalUnlock(HGLOBAL hMem)
  347. {
  348.     return LocalUnlock((HLOCAL)hMem);
  349. }
  350.  
  351. inline HGLOBAL wce_GlobalHandle(LPCVOID pMem)
  352. {
  353.     return (HGLOBAL)LocalHandle(pMem);
  354. }
  355.  
  356. inline UINT wce_GlobalFlags(HGLOBAL hMem)
  357. {
  358.     return LocalFlags((HLOCAL)hMem);
  359. }
  360.  
  361. inline DWORD wce_GetVersion()
  362. {
  363.     return 4;
  364. }
  365.  
  366. inline void* wce_calloc(size_t num, size_t size)
  367. {
  368.     void *ptr = malloc(num*size);
  369.     if(ptr)
  370.         memset(ptr, 0, num*size);
  371.     return ptr;
  372. }
  373.  
  374. inline void* wce__expand(void* pvMemBlock, size_t iSize)
  375. {
  376.     return realloc(pvMemBlock, iSize);
  377. }
  378.  
  379. extern "C" void  __cdecl exit(int);       
  380. inline void wce_abort()
  381. {
  382.     exit(3);                                                                     
  383. }
  384.  
  385. inline unsigned long wce__beginthreadex(void *security, unsigned stack_size, 
  386.                                   unsigned (__stdcall *start_address)(void *),
  387.                                   void *arglist, unsigned initflag, 
  388.                                   unsigned *thrdaddr)
  389. {
  390.     return (unsigned long)CreateThread((LPSECURITY_ATTRIBUTES)security, 
  391.                                         (DWORD)stack_size,
  392.                                         (LPTHREAD_START_ROUTINE)start_address, 
  393.                                         (LPVOID)arglist, 
  394.                                         (DWORD)initflag | CREATE_SUSPENDED, 
  395.                                         (LPDWORD)thrdaddr);
  396. }
  397.  
  398. inline void wce__endthreadex(unsigned nExitCode)
  399. {
  400.     ExitThread((DWORD)nExitCode);
  401. }
  402.  
  403. inline BOOL wce_GetCursorPos(LPPOINT lpPoint)
  404. {
  405. #if (_WIN32_WCE >= 210)
  406.     return ::GetCursorPos(lpPoint);
  407. #else // _WIN32_WCE
  408.     return ::GetCaretPos(lpPoint);
  409. #endif // _WIN32_WCE
  410. }
  411.  
  412. inline HDWP wce_BeginDeferWindowPos(int nNumWindows)
  413. {
  414.     return (HDWP)1; // a fake handle
  415. }
  416.  
  417. inline HDWP wce_DeferWindowPos(HDWP hWinPosInfo, HWND hWnd, HWND hWndInsertAfter, 
  418.                         int x, int y, int cx, int cy, UINT uFlags)
  419. {
  420.     ::SetWindowPos(hWnd, hWndInsertAfter, x, y, cx, cy,    uFlags);
  421.     return (HDWP)1; // a fake handle
  422. }
  423.  
  424. inline BOOL wce_EndDeferWindowPos(HDWP hWinPosInfo)
  425. {    
  426.     return TRUE;
  427. }
  428.  
  429. #endif  // __WCEIMPL_H__
  430.