Windows NT 4.0 source code leak
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.

377 lines
9.7 KiB

4 years ago
  1. //==========================================================================//
  2. // Constants //
  3. //==========================================================================//
  4. #define ThreeDPad 2
  5. #define NOCHANGE -1
  6. #define MENUCLOSING (0xFFFF0000)
  7. #define WM_DLGSETFOCUS (WM_USER + 0x201)
  8. #define WM_DLGKILLFOCUS (WM_USER + 0x202)
  9. //==========================================================================//
  10. // Macros //
  11. //==========================================================================//
  12. #define PinInclusive(x, lo, hi) \
  13. (max (lo, min (x, hi)))
  14. #define PinExclusive(x, lo, hi) \
  15. (max ((lo) + 1, min (x, (hi) - 1)))
  16. #define BoolEqual(a, b) \
  17. ((a == 0) == (b == 0))
  18. //=============================//
  19. // Window Instance Accessors //
  20. //=============================//
  21. #define WindowParent(hWnd) \
  22. ((HWND) GetWindowLong (hWnd, GWL_HWNDPARENT))
  23. #define WindowID(hWnd) \
  24. GetWindowLong (hWnd, GWL_ID)
  25. #define WindowInstance(hWnd) \
  26. GetWindowWord (hWnd, GWW_HINSTANCE)
  27. #define WindowStyle(hWnd) \
  28. GetWindowLong (hWnd, GWL_STYLE)
  29. #define WindowSetStyle(hWnd, lStyle) \
  30. SetWindowLong (hWnd, GWL_STYLE, lStyle)
  31. #define WindowExStyle(hWnd) \
  32. GetWindowLong (hWnd, GWL_EXSTYLE)
  33. #define WindowSetID(hWnd, wID) \
  34. SetWindowLong (hWnd, GWL_ID, wID)
  35. // All modeless dialogs need to be dispatched separately in the WinMain
  36. // message loop, but only if the dialog exists.
  37. #define ModelessDispatch(hDlg, lpMsg) \
  38. (hDlg ? IsDialogMessage (hDlg, lpMsg) : FALSE)
  39. #define strclr(szString) \
  40. (szString [0] = TEXT('\0'))
  41. #define strempty(lpszString) \
  42. (!(lpszString) || !(lpszString[0]))
  43. #define pstrsame(lpsz1, lpsz2) \
  44. ((!lpsz1 && !lpsz2) || (lpsz1 && lpsz2 && strsame (lpsz1, lpsz2)))
  45. #define pstrsamei(lpsz1, lpsz2) \
  46. ((!lpsz1 && !lpsz2) || (lpsz1 && lpsz2 && strsamei (lpsz1, lpsz2)))
  47. #define StringLoad(wID, szText) \
  48. (LoadString (hInstance, wID, \
  49. szText, sizeof (szText) - sizeof(TCHAR)))
  50. #define WindowInvalidate(hWnd) \
  51. (InvalidateRect (hWnd, NULL, TRUE))
  52. #define WindowShow(hWnd, bShow) \
  53. (ShowWindow (hWnd, (bShow) ? SW_SHOW : SW_HIDE))
  54. #define MenuCheck(hMenu, wID, bCheck) \
  55. (CheckMenuItem (hMenu, wID, (bCheck) ? \
  56. (MF_BYCOMMAND | MF_CHECKED) : (MF_BYCOMMAND | MF_UNCHECKED)))
  57. #define DeleteFont(hFont) \
  58. (DeleteObject (hFont))
  59. #define DeleteBitmap(hBitmap) \
  60. (DeleteObject (hBitmap))
  61. #define DialogControl(hDlg, wControlID) \
  62. GetDlgItem (hDlg, wControlID)
  63. #define DialogSetInt(hDlg, wControlID, iValue) \
  64. (SetDlgItemInt (hDlg, wControlID, iValue, TRUE))
  65. #define DialogText(hDlg, wControlID, szText) \
  66. (GetDlgItemText (hDlg, wControlID, szText, sizeof (szText) / sizeof(TCHAR) - 1))
  67. #define DialogInt(hDlg, wControlID) \
  68. (GetDlgItemInt (hDlg, wControlID, NULL, TRUE))
  69. #define strsame(szText1, szText2) \
  70. (!lstrcmp (szText1, szText2))
  71. #define strsamei(szText1, szText2) \
  72. (!lstrcmpi (szText1, szText2))
  73. #define strnsame(szText1, szText2, iLen) \
  74. (!lstrncmp (szText1, szText2, iLen))
  75. #define CreateScreenDC() \
  76. CreateDC (TEXT("DISPLAY"), NULL, NULL, NULL)
  77. #define RectContract(lpRect, xAmt, yAmt) \
  78. { \
  79. (lpRect)->left += (xAmt) ; \
  80. (lpRect)->top += (yAmt) ; \
  81. (lpRect)->right -= (xAmt) ; \
  82. (lpRect)->bottom -= (yAmt) ; \
  83. }
  84. #define IsBW(hDC) \
  85. (DeviceNumColors (hDC) <= 2)
  86. #ifdef KEEP_PRINT
  87. #define IsPrinterDC(hDC) \
  88. (GetDeviceCaps (hDC, TECHNOLOGY) != DT_RASDISPLAY)
  89. #else
  90. #define IsPrinterDC(hDC) \
  91. (FALSE)
  92. #endif
  93. #define VertInchPixels(hDC, iNumerator, iDenominator) \
  94. ((iNumerator * GetDeviceCaps (hDC, LOGPIXELSY)) / iDenominator)
  95. #define HorzInchPixels(hDC, iNumerator, iDenominator) \
  96. ((iNumerator * GetDeviceCaps (hDC, LOGPIXELSX)) / iDenominator)
  97. #define VertPointPixels(hDC, iPoints) \
  98. ((iPoints * GetDeviceCaps (hDC, LOGPIXELSY)) / 72)
  99. #define SimulateButtonPush(hDlg, wControlID) \
  100. (PostMessage (hDlg, WM_COMMAND, \
  101. (WPARAM) MAKELONG (wControlID, BN_CLICKED), \
  102. (LPARAM) DialogControl (hDlg, wControlID)))
  103. // convert an unicode string to OEM string
  104. #define ConvertUnicodeStr(pOemStr, pUnicodeStr) \
  105. CharToOemBuff(pUnicodeStr, pOemStr, lstrlen(pUnicodeStr) + 1)
  106. #define CallWinHelp(ContextID) \
  107. WinHelp(hWndMain, pszHelpFile, HELP_CONTEXT, ContextID) ;
  108. //==========================================================================//
  109. // Exported Functions //
  110. //==========================================================================//
  111. void Fill (HDC hDC,
  112. DWORD rgbColor,
  113. LPRECT lpRect) ;
  114. void ScreenRectToClient (HWND hWnd,
  115. LPRECT lpRect) ;
  116. int TextWidth (HDC hDC, LPTSTR lpszText) ;
  117. void ThreeDConcave (HDC hDC,
  118. int x1, int y1,
  119. int x2, int y2,
  120. BOOL bFace) ;
  121. void ThreeDConvex (HDC hDC,
  122. int x1, int y1,
  123. int x2, int y2) ;
  124. void ThreeDConcave1 (HDC hDC,
  125. int x1, int y1,
  126. int x2, int y2) ;
  127. void ThreeDConvex1 (HDC hDC,
  128. int x1, int y1,
  129. int x2, int y2) ;
  130. int _cdecl mike (TCHAR *szFormat, ...) ;
  131. int _cdecl DlgErrorBox (HWND hDlg, UINT id, ...) ;
  132. int _cdecl mike1 (TCHAR *szFormat, ...) ;
  133. int _cdecl mike2 (TCHAR *szFormat, ...) ;
  134. int FontHeight (HDC hDC,
  135. BOOL bIncludeLeading) ;
  136. int TextAvgWidth (HDC hDC,
  137. int iNumChars) ;
  138. void WindowCenter (HWND hWnd) ;
  139. BOOL DialogMove (HDLG hDlg,
  140. WORD wControlID,
  141. int xPos,
  142. int yPos,
  143. int xWidth,
  144. int yHeight) ;
  145. int DialogWidth (HDLG hDlg,
  146. WORD wControlID) ;
  147. int DialogXPos (HDLG hDlg,
  148. WORD wControlID) ;
  149. int DialogYPos (HDLG hDlg,
  150. WORD wControlID) ;
  151. void DialogShow (HDLG hDlg,
  152. WORD wID,
  153. BOOL bShow) ;
  154. BOOL _cdecl DialogSetText (HDLG hDlg,
  155. WORD wControlID,
  156. WORD wStringID,
  157. ...) ;
  158. #if 0
  159. BOOL _cdecl DialogSetString (HDLG hDlg,
  160. WORD wControlID,
  161. LPTSTR lpszFormat,
  162. ...) ;
  163. #endif
  164. #define DialogSetString(hDlg, wControlID, lpszFormat) \
  165. SetDlgItemText (hDlg, wControlID, lpszFormat)
  166. LPTSTR LongToCommaString (LONG lNumber,
  167. LPTSTR lpszText) ;
  168. BOOL MenuSetPopup (HWND hWnd,
  169. int iPosition,
  170. WORD wControlID,
  171. LPTSTR lpszResourceID) ;
  172. void DialogEnable (HDLG hDlg,
  173. WORD wID,
  174. BOOL bEnable) ;
  175. LPTSTR FileCombine (LPTSTR lpszFileSpec,
  176. LPTSTR lpszFileDirectory,
  177. LPTSTR lpszFileName) ;
  178. LPTSTR ExtractFileName (LPTSTR pFileSpec) ;
  179. int CBAddInt (HWND hWndCB,
  180. int iValue) ;
  181. FLOAT DialogFloat (HDLG hDlg,
  182. WORD wControlID,
  183. BOOL *pbOK) ;
  184. LPTSTR StringAllocate (LPTSTR lpszText1) ;
  185. int DivRound (int iNumerator, int iDenominator) ;
  186. BOOL MenuEnableItem (HMENU hMenu,
  187. WORD wID,
  188. BOOL bEnable) ;
  189. void DrawBitmap (HDC hDC,
  190. HBITMAP hBitmap,
  191. int xPos,
  192. int yPos,
  193. LONG lROPCode) ;
  194. void BitmapDimemsion (HBITMAP hBitmap, int *pHeight, int *pWidth) ;
  195. void WindowResize (HWND hWnd,
  196. int xWidth,
  197. int yHeight) ;
  198. int WindowHeight (HWND hWnd) ;
  199. void WindowSetTopmost (HWND hWnd, BOOL bTopmost) ;
  200. void WindowEnableTitle (HWND hWnd, BOOL bTitle) ;
  201. void Line (HDC hDC,
  202. HPEN hPen,
  203. int x1, int y1,
  204. int x2, int y2) ;
  205. #define HLine(hDC, hPen, x1, x2, y) \
  206. Line (hDC, hPen, x1, y, x2, y) ;
  207. #define VLine(hDC, hPen, x, y1, y2) \
  208. Line (hDC, hPen, x, y1, x, y2) ;
  209. int DialogHeight (HDLG hDlg,
  210. WORD wControlID) ;
  211. void DialogSetFloat (HDLG hDlg,
  212. WORD wControlID,
  213. FLOAT eValue) ;
  214. void DialogSetInterval (HDLG hDlg,
  215. WORD wControlID,
  216. int IntervalMSec ) ;
  217. int MessageBoxResource (HWND hWndParent,
  218. WORD wTextID,
  219. WORD wTitleID,
  220. UINT uiStyle) ;
  221. void WindowPlacementToString (PWINDOWPLACEMENT pWP,
  222. LPTSTR lpszText) ;
  223. void StringToWindowPlacement (LPTSTR lpszText,
  224. PWINDOWPLACEMENT pWP) ;
  225. DWORD MenuIDToHelpID (DWORD MenuID) ;