afxwin1.inl 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092
  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. // Inlines for AFXWIN.H (part 1)
  11. #ifdef _AFXWIN_INLINE
  12. // Global helper functions
  13. _AFXWIN_INLINE CWinApp* AFXAPI AfxGetApp()
  14. { return afxCurrentWinApp; }
  15. _AFXWIN_INLINE HINSTANCE AFXAPI AfxGetInstanceHandle()
  16. { ASSERT(afxCurrentInstanceHandle != NULL);
  17. return afxCurrentInstanceHandle; }
  18. _AFXWIN_INLINE HINSTANCE AFXAPI AfxGetResourceHandle()
  19. { ASSERT(afxCurrentResourceHandle != NULL);
  20. return afxCurrentResourceHandle; }
  21. _AFXWIN_INLINE void AFXAPI AfxSetResourceHandle(HINSTANCE hInstResource)
  22. { ASSERT(hInstResource != NULL); afxCurrentResourceHandle = hInstResource; }
  23. _AFXWIN_INLINE LPCTSTR AFXAPI AfxGetAppName()
  24. { ASSERT(afxCurrentAppName != NULL); return afxCurrentAppName; }
  25. _AFXWIN_INLINE COleMessageFilter* AFXAPI AfxOleGetMessageFilter()
  26. { ASSERT_VALID(AfxGetThread()); return AfxGetThread()->m_pMessageFilter; }
  27. _AFXWIN_INLINE CWnd* AFXAPI AfxGetMainWnd()
  28. { CWinThread* pThread = AfxGetThread();
  29. return pThread != NULL ? pThread->GetMainWnd() : NULL; }
  30. #ifdef _AFXDLL
  31. // AFX_MAINTAIN_STATE functions
  32. _AFXWIN_INLINE AFX_MAINTAIN_STATE::AFX_MAINTAIN_STATE(AFX_MODULE_STATE* pNewState)
  33. { m_pPrevModuleState = AfxSetModuleState(pNewState); }
  34. // AFX_MAINTAIN_STATE2 functions
  35. _AFXWIN_INLINE AFX_MAINTAIN_STATE2::~AFX_MAINTAIN_STATE2()
  36. { m_pThreadState->m_pModuleState = m_pPrevModuleState; }
  37. #endif
  38. // CSize
  39. _AFXWIN_INLINE CSize::CSize()
  40. { /* random filled */ }
  41. _AFXWIN_INLINE CSize::CSize(int initCX, int initCY)
  42. { cx = initCX; cy = initCY; }
  43. _AFXWIN_INLINE CSize::CSize(SIZE initSize)
  44. { *(SIZE*)this = initSize; }
  45. _AFXWIN_INLINE CSize::CSize(POINT initPt)
  46. { *(POINT*)this = initPt; }
  47. _AFXWIN_INLINE CSize::CSize(DWORD dwSize)
  48. {
  49. cx = (short)LOWORD(dwSize);
  50. cy = (short)HIWORD(dwSize);
  51. }
  52. _AFXWIN_INLINE BOOL CSize::operator==(SIZE size) const
  53. { return (cx == size.cx && cy == size.cy); }
  54. _AFXWIN_INLINE BOOL CSize::operator!=(SIZE size) const
  55. { return (cx != size.cx || cy != size.cy); }
  56. _AFXWIN_INLINE void CSize::operator+=(SIZE size)
  57. { cx += size.cx; cy += size.cy; }
  58. _AFXWIN_INLINE void CSize::operator-=(SIZE size)
  59. { cx -= size.cx; cy -= size.cy; }
  60. _AFXWIN_INLINE CSize CSize::operator+(SIZE size) const
  61. { return CSize(cx + size.cx, cy + size.cy); }
  62. _AFXWIN_INLINE CSize CSize::operator-(SIZE size) const
  63. { return CSize(cx - size.cx, cy - size.cy); }
  64. _AFXWIN_INLINE CSize CSize::operator-() const
  65. { return CSize(-cx, -cy); }
  66. _AFXWIN_INLINE CPoint CSize::operator+(POINT point) const
  67. { return CPoint(cx + point.x, cy + point.y); }
  68. _AFXWIN_INLINE CPoint CSize::operator-(POINT point) const
  69. { return CPoint(cx - point.x, cy - point.y); }
  70. _AFXWIN_INLINE CRect CSize::operator+(const RECT* lpRect) const
  71. { return CRect(lpRect) + *this; }
  72. _AFXWIN_INLINE CRect CSize::operator-(const RECT* lpRect) const
  73. { return CRect(lpRect) - *this; }
  74. // CPoint
  75. _AFXWIN_INLINE CPoint::CPoint()
  76. { /* random filled */ }
  77. _AFXWIN_INLINE CPoint::CPoint(int initX, int initY)
  78. { x = initX; y = initY; }
  79. #if !defined(_AFX_CORE_IMPL) || !defined(_AFXDLL) || defined(MFC_DEBUG)
  80. _AFXWIN_INLINE CPoint::CPoint(POINT initPt)
  81. { *(POINT*)this = initPt; }
  82. #endif
  83. _AFXWIN_INLINE CPoint::CPoint(SIZE initSize)
  84. { *(SIZE*)this = initSize; }
  85. _AFXWIN_INLINE CPoint::CPoint(DWORD dwPoint)
  86. {
  87. x = (short)LOWORD(dwPoint);
  88. y = (short)HIWORD(dwPoint);
  89. }
  90. _AFXWIN_INLINE void CPoint::Offset(int xOffset, int yOffset)
  91. { x += xOffset; y += yOffset; }
  92. _AFXWIN_INLINE void CPoint::Offset(POINT point)
  93. { x += point.x; y += point.y; }
  94. _AFXWIN_INLINE void CPoint::Offset(SIZE size)
  95. { x += size.cx; y += size.cy; }
  96. _AFXWIN_INLINE BOOL CPoint::operator==(POINT point) const
  97. { return (x == point.x && y == point.y); }
  98. _AFXWIN_INLINE BOOL CPoint::operator!=(POINT point) const
  99. { return (x != point.x || y != point.y); }
  100. _AFXWIN_INLINE void CPoint::operator+=(SIZE size)
  101. { x += size.cx; y += size.cy; }
  102. _AFXWIN_INLINE void CPoint::operator-=(SIZE size)
  103. { x -= size.cx; y -= size.cy; }
  104. _AFXWIN_INLINE void CPoint::operator+=(POINT point)
  105. { x += point.x; y += point.y; }
  106. _AFXWIN_INLINE void CPoint::operator-=(POINT point)
  107. { x -= point.x; y -= point.y; }
  108. _AFXWIN_INLINE CPoint CPoint::operator+(SIZE size) const
  109. { return CPoint(x + size.cx, y + size.cy); }
  110. _AFXWIN_INLINE CPoint CPoint::operator-(SIZE size) const
  111. { return CPoint(x - size.cx, y - size.cy); }
  112. _AFXWIN_INLINE CPoint CPoint::operator-() const
  113. { return CPoint(-x, -y); }
  114. _AFXWIN_INLINE CPoint CPoint::operator+(POINT point) const
  115. { return CPoint(x + point.x, y + point.y); }
  116. _AFXWIN_INLINE CSize CPoint::operator-(POINT point) const
  117. { return CSize(x - point.x, y - point.y); }
  118. _AFXWIN_INLINE CRect CPoint::operator+(const RECT* lpRect) const
  119. { return CRect(lpRect) + *this; }
  120. _AFXWIN_INLINE CRect CPoint::operator-(const RECT* lpRect) const
  121. { return CRect(lpRect) - *this; }
  122. // CRect
  123. _AFXWIN_INLINE CRect::CRect()
  124. { /* random filled */ }
  125. _AFXWIN_INLINE CRect::CRect(int l, int t, int r, int b)
  126. { left = l; top = t; right = r; bottom = b; }
  127. _AFXWIN_INLINE CRect::CRect(const RECT& srcRect)
  128. { ::CopyRect(this, &srcRect); }
  129. _AFXWIN_INLINE CRect::CRect(LPCRECT lpSrcRect)
  130. { ::CopyRect(this, lpSrcRect); }
  131. _AFXWIN_INLINE CRect::CRect(POINT point, SIZE size)
  132. { right = (left = point.x) + size.cx; bottom = (top = point.y) + size.cy; }
  133. _AFXWIN_INLINE CRect::CRect(POINT topLeft, POINT bottomRight)
  134. { left = topLeft.x; top = topLeft.y;
  135. right = bottomRight.x; bottom = bottomRight.y; }
  136. _AFXWIN_INLINE int CRect::Width() const
  137. { return right - left; }
  138. _AFXWIN_INLINE int CRect::Height() const
  139. { return bottom - top; }
  140. _AFXWIN_INLINE CSize CRect::Size() const
  141. { return CSize(right - left, bottom - top); }
  142. _AFXWIN_INLINE CPoint& CRect::TopLeft()
  143. { return *((CPoint*)this); }
  144. _AFXWIN_INLINE CPoint& CRect::BottomRight()
  145. { return *((CPoint*)this+1); }
  146. _AFXWIN_INLINE const CPoint& CRect::TopLeft() const
  147. { return *((CPoint*)this); }
  148. _AFXWIN_INLINE const CPoint& CRect::BottomRight() const
  149. { return *((CPoint*)this+1); }
  150. _AFXWIN_INLINE CPoint CRect::CenterPoint() const
  151. { return CPoint((left+right)/2, (top+bottom)/2); }
  152. _AFXWIN_INLINE void CRect::SwapLeftRight()
  153. { SwapLeftRight(LPRECT(this)); }
  154. _AFXWIN_INLINE void CRect::SwapLeftRight(LPRECT lpRect)
  155. { LONG temp = lpRect->left; lpRect->left = lpRect->right; lpRect->right = temp; }
  156. _AFXWIN_INLINE CRect::operator LPRECT()
  157. { return this; }
  158. _AFXWIN_INLINE CRect::operator LPCRECT() const
  159. { return this; }
  160. _AFXWIN_INLINE BOOL CRect::IsRectEmpty() const
  161. { return ::IsRectEmpty(this); }
  162. _AFXWIN_INLINE BOOL CRect::IsRectNull() const
  163. { return (left == 0 && right == 0 && top == 0 && bottom == 0); }
  164. _AFXWIN_INLINE BOOL CRect::PtInRect(POINT point) const
  165. { return ::PtInRect(this, point); }
  166. _AFXWIN_INLINE void CRect::SetRect(int x1, int y1, int x2, int y2)
  167. { ::SetRect(this, x1, y1, x2, y2); }
  168. _AFXWIN_INLINE void CRect::SetRect(POINT topLeft, POINT bottomRight)
  169. { ::SetRect(this, topLeft.x, topLeft.y, bottomRight.x, bottomRight.y); }
  170. _AFXWIN_INLINE void CRect::SetRectEmpty()
  171. { ::SetRectEmpty(this); }
  172. _AFXWIN_INLINE void CRect::CopyRect(LPCRECT lpSrcRect)
  173. { ::CopyRect(this, lpSrcRect); }
  174. _AFXWIN_INLINE BOOL CRect::EqualRect(LPCRECT lpRect) const
  175. { return ::EqualRect(this, lpRect); }
  176. _AFXWIN_INLINE void CRect::InflateRect(int x, int y)
  177. { ::InflateRect(this, x, y); }
  178. _AFXWIN_INLINE void CRect::InflateRect(SIZE size)
  179. { ::InflateRect(this, size.cx, size.cy); }
  180. _AFXWIN_INLINE void CRect::DeflateRect(int x, int y)
  181. { ::InflateRect(this, -x, -y); }
  182. _AFXWIN_INLINE void CRect::DeflateRect(SIZE size)
  183. { ::InflateRect(this, -size.cx, -size.cy); }
  184. _AFXWIN_INLINE void CRect::OffsetRect(int x, int y)
  185. { ::OffsetRect(this, x, y); }
  186. _AFXWIN_INLINE void CRect::OffsetRect(POINT point)
  187. { ::OffsetRect(this, point.x, point.y); }
  188. _AFXWIN_INLINE void CRect::OffsetRect(SIZE size)
  189. { ::OffsetRect(this, size.cx, size.cy); }
  190. _AFXWIN_INLINE BOOL CRect::IntersectRect(LPCRECT lpRect1, LPCRECT lpRect2)
  191. { return ::IntersectRect(this, lpRect1, lpRect2);}
  192. _AFXWIN_INLINE BOOL CRect::UnionRect(LPCRECT lpRect1, LPCRECT lpRect2)
  193. { return ::UnionRect(this, lpRect1, lpRect2); }
  194. _AFXWIN_INLINE void CRect::operator=(const RECT& srcRect)
  195. { ::CopyRect(this, &srcRect); }
  196. _AFXWIN_INLINE BOOL CRect::operator==(const RECT& rect) const
  197. { return ::EqualRect(this, &rect); }
  198. _AFXWIN_INLINE BOOL CRect::operator!=(const RECT& rect) const
  199. { return !::EqualRect(this, &rect); }
  200. _AFXWIN_INLINE void CRect::operator+=(POINT point)
  201. { ::OffsetRect(this, point.x, point.y); }
  202. _AFXWIN_INLINE void CRect::operator+=(SIZE size)
  203. { ::OffsetRect(this, size.cx, size.cy); }
  204. _AFXWIN_INLINE void CRect::operator+=(LPCRECT lpRect)
  205. { InflateRect(lpRect); }
  206. _AFXWIN_INLINE void CRect::operator-=(POINT point)
  207. { ::OffsetRect(this, -point.x, -point.y); }
  208. _AFXWIN_INLINE void CRect::operator-=(SIZE size)
  209. { ::OffsetRect(this, -size.cx, -size.cy); }
  210. _AFXWIN_INLINE void CRect::operator-=(LPCRECT lpRect)
  211. { DeflateRect(lpRect); }
  212. _AFXWIN_INLINE void CRect::operator&=(const RECT& rect)
  213. { ::IntersectRect(this, this, &rect); }
  214. _AFXWIN_INLINE void CRect::operator|=(const RECT& rect)
  215. { ::UnionRect(this, this, &rect); }
  216. _AFXWIN_INLINE CRect CRect::operator+(POINT pt) const
  217. { CRect rect(*this); ::OffsetRect(&rect, pt.x, pt.y); return rect; }
  218. _AFXWIN_INLINE CRect CRect::operator-(POINT pt) const
  219. { CRect rect(*this); ::OffsetRect(&rect, -pt.x, -pt.y); return rect; }
  220. _AFXWIN_INLINE CRect CRect::operator+(SIZE size) const
  221. { CRect rect(*this); ::OffsetRect(&rect, size.cx, size.cy); return rect; }
  222. _AFXWIN_INLINE CRect CRect::operator-(SIZE size) const
  223. { CRect rect(*this); ::OffsetRect(&rect, -size.cx, -size.cy); return rect; }
  224. _AFXWIN_INLINE CRect CRect::operator+(LPCRECT lpRect) const
  225. { CRect rect(this); rect.InflateRect(lpRect); return rect; }
  226. _AFXWIN_INLINE CRect CRect::operator-(LPCRECT lpRect) const
  227. { CRect rect(this); rect.DeflateRect(lpRect); return rect; }
  228. _AFXWIN_INLINE CRect CRect::operator&(const RECT& rect2) const
  229. { CRect rect; ::IntersectRect(&rect, this, &rect2);
  230. return rect; }
  231. _AFXWIN_INLINE CRect CRect::operator|(const RECT& rect2) const
  232. { CRect rect; ::UnionRect(&rect, this, &rect2);
  233. return rect; }
  234. _AFXWIN_INLINE BOOL CRect::SubtractRect(LPCRECT lpRectSrc1, LPCRECT lpRectSrc2)
  235. { return ::SubtractRect(this, lpRectSrc1, lpRectSrc2); }
  236. // CArchive output helpers
  237. _AFXWIN_INLINE CArchive& AFXAPI operator<<(CArchive& ar, SIZE size)
  238. { ar.Write(&size, sizeof(SIZE)); return ar; }
  239. _AFXWIN_INLINE CArchive& AFXAPI operator<<(CArchive& ar, POINT point)
  240. { ar.Write(&point, sizeof(POINT)); return ar; }
  241. _AFXWIN_INLINE CArchive& AFXAPI operator<<(CArchive& ar, const RECT& rect)
  242. { ar.Write(&rect, sizeof(RECT)); return ar; }
  243. _AFXWIN_INLINE CArchive& AFXAPI operator>>(CArchive& ar, SIZE& size)
  244. { ar.Read(&size, sizeof(SIZE)); return ar; }
  245. _AFXWIN_INLINE CArchive& AFXAPI operator>>(CArchive& ar, POINT& point)
  246. { ar.Read(&point, sizeof(POINT)); return ar; }
  247. _AFXWIN_INLINE CArchive& AFXAPI operator>>(CArchive& ar, RECT& rect)
  248. { ar.Read(&rect, sizeof(RECT)); return ar; }
  249. // exception support
  250. _AFXWIN_INLINE CResourceException::CResourceException()
  251. : CSimpleException() { }
  252. _AFXWIN_INLINE CResourceException::CResourceException(BOOL bAutoDelete, UINT nResourceID)
  253. : CSimpleException(bAutoDelete) { m_nResourceID = nResourceID; }
  254. _AFXWIN_INLINE CResourceException::~CResourceException()
  255. { }
  256. _AFXWIN_INLINE CUserException::CUserException()
  257. : CSimpleException() { }
  258. _AFXWIN_INLINE CUserException::CUserException(BOOL bAutoDelete, UINT nResourceID)
  259. : CSimpleException(bAutoDelete) { m_nResourceID = nResourceID; }
  260. _AFXWIN_INLINE CUserException::~CUserException()
  261. { }
  262. // CGdiObject
  263. _AFXWIN_INLINE CGdiObject::operator HGDIOBJ() const
  264. { return this == NULL ? NULL : m_hObject; }
  265. _AFXWIN_INLINE HGDIOBJ CGdiObject::GetSafeHandle() const
  266. { return this == NULL ? NULL : m_hObject; }
  267. _AFXWIN_INLINE CGdiObject::CGdiObject()
  268. { m_hObject = NULL; }
  269. _AFXWIN_INLINE CGdiObject::~CGdiObject()
  270. { DeleteObject(); }
  271. _AFXWIN_INLINE int CGdiObject::GetObject(int nCount, LPVOID lpObject) const
  272. { ASSERT(m_hObject != NULL); return ::GetObject(m_hObject, nCount, lpObject); }
  273. _AFXWIN_INLINE BOOL CGdiObject::CreateStockObject(int nIndex)
  274. { return (m_hObject = ::GetStockObject(nIndex)) != NULL; }
  275. _AFXWIN_INLINE BOOL CGdiObject::UnrealizeObject()
  276. { ASSERT(m_hObject != NULL); return ::UnrealizeObject(m_hObject); }
  277. _AFXWIN_INLINE UINT CGdiObject::GetObjectType() const
  278. { return (UINT)::GetObjectType(m_hObject); }
  279. _AFXWIN_INLINE BOOL CGdiObject::operator==(const CGdiObject& obj) const
  280. { return ((HGDIOBJ) obj) == m_hObject; }
  281. _AFXWIN_INLINE BOOL CGdiObject::operator!=(const CGdiObject& obj) const
  282. { return ((HGDIOBJ) obj) != m_hObject; }
  283. // CPen
  284. _AFXWIN_INLINE CPen::operator HPEN() const
  285. { return (HPEN)(this == NULL ? NULL : m_hObject); }
  286. _AFXWIN_INLINE CPen* PASCAL CPen::FromHandle(HPEN hPen)
  287. { return (CPen*) CGdiObject::FromHandle(hPen); }
  288. _AFXWIN_INLINE CPen::CPen()
  289. { }
  290. _AFXWIN_INLINE CPen::~CPen()
  291. { }
  292. _AFXWIN_INLINE BOOL CPen::CreatePen(int nPenStyle, int nWidth, COLORREF crColor)
  293. { return Attach(::CreatePen(nPenStyle, nWidth, crColor)); }
  294. _AFXWIN_INLINE BOOL CPen::CreatePenIndirect(LPLOGPEN lpLogPen)
  295. { return Attach(::CreatePenIndirect(lpLogPen)); }
  296. _AFXWIN_INLINE BOOL CPen::CreatePen(int nPenStyle, int nWidth, const LOGBRUSH* pLogBrush,
  297. int nStyleCount, const DWORD* lpStyle)
  298. { return Attach(::ExtCreatePen(nPenStyle, nWidth, pLogBrush, nStyleCount,
  299. lpStyle)); }
  300. _AFXWIN_INLINE int CPen::GetExtLogPen(EXTLOGPEN* pLogPen)
  301. { ASSERT(m_hObject != NULL);
  302. return ::GetObject(m_hObject, sizeof(EXTLOGPEN), pLogPen); }
  303. _AFXWIN_INLINE int CPen::GetLogPen(LOGPEN* pLogPen)
  304. { ASSERT(m_hObject != NULL);
  305. return ::GetObject(m_hObject, sizeof(LOGPEN), pLogPen); }
  306. // CBrush
  307. _AFXWIN_INLINE CBrush::operator HBRUSH() const
  308. { return (HBRUSH)(this == NULL ? NULL : m_hObject); }
  309. _AFXWIN_INLINE CBrush* PASCAL CBrush::FromHandle(HBRUSH hBrush)
  310. { return (CBrush*) CGdiObject::FromHandle(hBrush); }
  311. _AFXWIN_INLINE CBrush::CBrush()
  312. { }
  313. _AFXWIN_INLINE CBrush::~CBrush()
  314. { }
  315. _AFXWIN_INLINE BOOL CBrush::CreateSolidBrush(COLORREF crColor)
  316. { return Attach(::CreateSolidBrush(crColor)); }
  317. _AFXWIN_INLINE BOOL CBrush::CreateHatchBrush(int nIndex, COLORREF crColor)
  318. { return Attach(::CreateHatchBrush(nIndex, crColor)); }
  319. _AFXWIN_INLINE BOOL CBrush::CreateBrushIndirect(const LOGBRUSH* lpLogBrush)
  320. { return Attach(::CreateBrushIndirect(lpLogBrush)); }
  321. _AFXWIN_INLINE BOOL CBrush::CreatePatternBrush(CBitmap* pBitmap)
  322. { return Attach(::CreatePatternBrush((HBITMAP)pBitmap->GetSafeHandle())); }
  323. _AFXWIN_INLINE BOOL CBrush::CreateDIBPatternBrush(const void* lpPackedDIB, UINT nUsage)
  324. { return Attach(::CreateDIBPatternBrushPt(lpPackedDIB, nUsage)); }
  325. _AFXWIN_INLINE BOOL CBrush::CreateSysColorBrush(int nIndex)
  326. { return Attach(::GetSysColorBrush(nIndex)); }
  327. _AFXWIN_INLINE int CBrush::GetLogBrush(LOGBRUSH* pLogBrush)
  328. { ASSERT(m_hObject != NULL);
  329. return ::GetObject(m_hObject, sizeof(LOGBRUSH), pLogBrush); }
  330. // CFont
  331. _AFXWIN_INLINE CFont::operator HFONT() const
  332. { return (HFONT)(this == NULL ? NULL : m_hObject); }
  333. _AFXWIN_INLINE CFont* PASCAL CFont::FromHandle(HFONT hFont)
  334. { return (CFont*) CGdiObject::FromHandle(hFont); }
  335. _AFXWIN_INLINE CFont::CFont()
  336. { }
  337. _AFXWIN_INLINE CFont::~CFont()
  338. { }
  339. _AFXWIN_INLINE BOOL CFont::CreateFontIndirect(const LOGFONT* lpLogFont)
  340. { return Attach(::CreateFontIndirect(lpLogFont)); }
  341. _AFXWIN_INLINE BOOL CFont::CreateFont(int nHeight, int nWidth, int nEscapement,
  342. int nOrientation, int nWeight, BYTE bItalic, BYTE bUnderline,
  343. BYTE cStrikeOut, BYTE nCharSet, BYTE nOutPrecision,
  344. BYTE nClipPrecision, BYTE nQuality, BYTE nPitchAndFamily,
  345. LPCTSTR lpszFacename)
  346. { return Attach(::CreateFont(nHeight, nWidth, nEscapement,
  347. nOrientation, nWeight, bItalic, bUnderline, cStrikeOut,
  348. nCharSet, nOutPrecision, nClipPrecision, nQuality,
  349. nPitchAndFamily, lpszFacename)); }
  350. _AFXWIN_INLINE int CFont::GetLogFont(LOGFONT* pLogFont)
  351. { ASSERT(m_hObject != NULL);
  352. return ::GetObject(m_hObject, sizeof(LOGFONT), pLogFont); }
  353. // CBitmap
  354. _AFXWIN_INLINE CBitmap::operator HBITMAP() const
  355. { return (HBITMAP)(this == NULL ? NULL : m_hObject); }
  356. _AFXWIN_INLINE CBitmap* PASCAL CBitmap::FromHandle(HBITMAP hBitmap)
  357. { return (CBitmap*) CGdiObject::FromHandle(hBitmap); }
  358. _AFXWIN_INLINE CBitmap::CBitmap()
  359. { }
  360. _AFXWIN_INLINE CBitmap::~CBitmap()
  361. { }
  362. _AFXWIN_INLINE BOOL CBitmap::CreateBitmap(int nWidth, int nHeight, UINT nPlanes,
  363. UINT nBitcount, const void* lpBits)
  364. { return Attach(::CreateBitmap(nWidth, nHeight, nPlanes, nBitcount, lpBits)); }
  365. _AFXWIN_INLINE BOOL CBitmap::CreateBitmapIndirect(LPBITMAP lpBitmap)
  366. { return Attach(::CreateBitmapIndirect(lpBitmap)); }
  367. _AFXWIN_INLINE DWORD CBitmap::SetBitmapBits(DWORD dwCount, const void* lpBits)
  368. { return ::SetBitmapBits((HBITMAP)m_hObject, dwCount, lpBits); }
  369. _AFXWIN_INLINE DWORD CBitmap::GetBitmapBits(DWORD dwCount, LPVOID lpBits) const
  370. { return ::GetBitmapBits((HBITMAP)m_hObject, dwCount, lpBits); }
  371. _AFXWIN_INLINE BOOL CBitmap::LoadBitmap(LPCTSTR lpszResourceName)
  372. { return Attach(::LoadBitmap(AfxFindResourceHandle(
  373. lpszResourceName, RT_BITMAP), lpszResourceName));}
  374. _AFXWIN_INLINE BOOL CBitmap::LoadMappedBitmap(UINT nIDBitmap, UINT nFlags,
  375. LPCOLORMAP lpColorMap, int nMapSize)
  376. { return Attach(::CreateMappedBitmap(AfxFindResourceHandle(
  377. MAKEINTRESOURCE(nIDBitmap), RT_BITMAP), nIDBitmap, (WORD)nFlags,
  378. lpColorMap, nMapSize)); }
  379. _AFXWIN_INLINE CSize CBitmap::SetBitmapDimension(int nWidth, int nHeight)
  380. {
  381. SIZE size;
  382. VERIFY(::SetBitmapDimensionEx((HBITMAP)m_hObject, nWidth, nHeight, &size));
  383. return size;
  384. }
  385. _AFXWIN_INLINE CSize CBitmap::GetBitmapDimension() const
  386. {
  387. SIZE size;
  388. VERIFY(::GetBitmapDimensionEx((HBITMAP)m_hObject, &size));
  389. return size;
  390. }
  391. _AFXWIN_INLINE BOOL CBitmap::LoadBitmap(UINT nIDResource)
  392. { return Attach(::LoadBitmap(AfxFindResourceHandle(
  393. MAKEINTRESOURCE(nIDResource), RT_BITMAP), MAKEINTRESOURCE(nIDResource))); }
  394. _AFXWIN_INLINE BOOL CBitmap::LoadOEMBitmap(UINT nIDBitmap)
  395. { return Attach(::LoadBitmap(NULL, MAKEINTRESOURCE(nIDBitmap))); }
  396. _AFXWIN_INLINE BOOL CBitmap::CreateCompatibleBitmap(CDC* pDC, int nWidth, int nHeight)
  397. { return Attach(::CreateCompatibleBitmap(pDC->m_hDC, nWidth, nHeight)); }
  398. _AFXWIN_INLINE BOOL CBitmap::CreateDiscardableBitmap(CDC* pDC, int nWidth, int nHeight)
  399. { return Attach(::CreateDiscardableBitmap(pDC->m_hDC, nWidth, nHeight)); }
  400. _AFXWIN_INLINE int CBitmap::GetBitmap(BITMAP* pBitMap)
  401. { ASSERT(m_hObject != NULL);
  402. return ::GetObject(m_hObject, sizeof(BITMAP), pBitMap); }
  403. // CPalette
  404. _AFXWIN_INLINE CPalette::operator HPALETTE() const
  405. { return (HPALETTE)(this == NULL ? NULL : m_hObject); }
  406. _AFXWIN_INLINE CPalette* PASCAL CPalette::FromHandle(HPALETTE hPalette)
  407. { return (CPalette*) CGdiObject::FromHandle(hPalette); }
  408. _AFXWIN_INLINE CPalette::CPalette()
  409. { }
  410. _AFXWIN_INLINE CPalette::~CPalette()
  411. { }
  412. _AFXWIN_INLINE BOOL CPalette::CreatePalette(LPLOGPALETTE lpLogPalette)
  413. { return Attach(::CreatePalette(lpLogPalette)); }
  414. _AFXWIN_INLINE BOOL CPalette::CreateHalftonePalette(CDC* pDC)
  415. { ASSERT(pDC != NULL && pDC->m_hDC != NULL); return Attach(
  416. ::CreateHalftonePalette(pDC->m_hDC)); }
  417. _AFXWIN_INLINE UINT CPalette::GetPaletteEntries(UINT nStartIndex, UINT nNumEntries,
  418. LPPALETTEENTRY lpPaletteColors) const
  419. { ASSERT(m_hObject != NULL); return ::GetPaletteEntries((HPALETTE)m_hObject, nStartIndex,
  420. nNumEntries, lpPaletteColors); }
  421. _AFXWIN_INLINE UINT CPalette::SetPaletteEntries(UINT nStartIndex, UINT nNumEntries,
  422. LPPALETTEENTRY lpPaletteColors)
  423. { ASSERT(m_hObject != NULL); return ::SetPaletteEntries((HPALETTE)m_hObject, nStartIndex,
  424. nNumEntries, lpPaletteColors); }
  425. _AFXWIN_INLINE void CPalette::AnimatePalette(UINT nStartIndex, UINT nNumEntries,
  426. LPPALETTEENTRY lpPaletteColors)
  427. { ASSERT(m_hObject != NULL); ::AnimatePalette((HPALETTE)m_hObject, nStartIndex, nNumEntries,
  428. lpPaletteColors); }
  429. _AFXWIN_INLINE UINT CPalette::GetNearestPaletteIndex(COLORREF crColor) const
  430. { ASSERT(m_hObject != NULL); return ::GetNearestPaletteIndex((HPALETTE)m_hObject, crColor); }
  431. _AFXWIN_INLINE BOOL CPalette::ResizePalette(UINT nNumEntries)
  432. { ASSERT(m_hObject != NULL); return ::ResizePalette((HPALETTE)m_hObject, nNumEntries); }
  433. _AFXWIN_INLINE int CPalette::GetEntryCount()
  434. { ASSERT(m_hObject != NULL); WORD nEntries;
  435. ::GetObject(m_hObject, sizeof(WORD), &nEntries); return (int)nEntries; }
  436. // CRgn
  437. _AFXWIN_INLINE CRgn::operator HRGN() const
  438. { return (HRGN)(this == NULL ? NULL : m_hObject); }
  439. _AFXWIN_INLINE CRgn* PASCAL CRgn::FromHandle(HRGN hRgn)
  440. { return (CRgn*) CGdiObject::FromHandle(hRgn); }
  441. _AFXWIN_INLINE CRgn::CRgn()
  442. { }
  443. _AFXWIN_INLINE CRgn::~CRgn()
  444. { }
  445. _AFXWIN_INLINE BOOL CRgn::CreateRectRgn(int x1, int y1, int x2, int y2)
  446. { return Attach(::CreateRectRgn(x1, y1, x2, y2)); }
  447. _AFXWIN_INLINE BOOL CRgn::CreateRectRgnIndirect(LPCRECT lpRect)
  448. { return Attach(::CreateRectRgnIndirect(lpRect)); }
  449. _AFXWIN_INLINE BOOL CRgn::CreateEllipticRgn(int x1, int y1, int x2, int y2)
  450. { return Attach(::CreateEllipticRgn(x1, y1, x2, y2)); }
  451. _AFXWIN_INLINE BOOL CRgn::CreateEllipticRgnIndirect(LPCRECT lpRect)
  452. { return Attach(::CreateEllipticRgnIndirect(lpRect)); }
  453. _AFXWIN_INLINE BOOL CRgn::CreatePolygonRgn(LPPOINT lpPoints, int nCount, int nMode)
  454. { return Attach(::CreatePolygonRgn(lpPoints, nCount, nMode)); }
  455. _AFXWIN_INLINE BOOL CRgn::CreatePolyPolygonRgn(LPPOINT lpPoints, LPINT lpPolyCounts, int nCount, int nPolyFillMode)
  456. { return Attach(::CreatePolyPolygonRgn(lpPoints, lpPolyCounts, nCount, nPolyFillMode)); }
  457. _AFXWIN_INLINE BOOL CRgn::CreateRoundRectRgn(int x1, int y1, int x2, int y2, int x3, int y3)
  458. { return Attach(::CreateRoundRectRgn(x1, y1, x2, y2, x3, y3)); }
  459. _AFXWIN_INLINE BOOL CRgn::CreateFromPath(CDC* pDC)
  460. { ASSERT(pDC != NULL); return Attach(::PathToRegion(pDC->m_hDC)); }
  461. _AFXWIN_INLINE BOOL CRgn::CreateFromData(const XFORM* lpXForm, int nCount, const RGNDATA* pRgnData)
  462. { return Attach(::ExtCreateRegion(lpXForm, nCount, pRgnData)); }
  463. _AFXWIN_INLINE int CRgn::GetRegionData(LPRGNDATA lpRgnData, int nDataSize) const
  464. { ASSERT(m_hObject != NULL); return (int)::GetRegionData((HRGN)m_hObject, nDataSize, lpRgnData); }
  465. _AFXWIN_INLINE void CRgn::SetRectRgn(int x1, int y1, int x2, int y2)
  466. { ASSERT(m_hObject != NULL); ::SetRectRgn((HRGN)m_hObject, x1, y1, x2, y2); }
  467. _AFXWIN_INLINE void CRgn::SetRectRgn(LPCRECT lpRect)
  468. { ASSERT(m_hObject != NULL); ::SetRectRgn((HRGN)m_hObject, lpRect->left, lpRect->top,
  469. lpRect->right, lpRect->bottom); }
  470. _AFXWIN_INLINE int CRgn::CombineRgn(CRgn* pRgn1, CRgn* pRgn2, int nCombineMode)
  471. { ASSERT(m_hObject != NULL); return ::CombineRgn((HRGN)m_hObject, (HRGN)pRgn1->GetSafeHandle(),
  472. (HRGN)pRgn2->GetSafeHandle(), nCombineMode); }
  473. _AFXWIN_INLINE int CRgn::CopyRgn(CRgn* pRgnSrc)
  474. { ASSERT(m_hObject != NULL); return ::CombineRgn((HRGN)m_hObject, (HRGN)pRgnSrc->GetSafeHandle(), NULL, RGN_COPY); }
  475. _AFXWIN_INLINE BOOL CRgn::EqualRgn(CRgn* pRgn) const
  476. { ASSERT(m_hObject != NULL); return ::EqualRgn((HRGN)m_hObject, (HRGN)pRgn->GetSafeHandle()); }
  477. _AFXWIN_INLINE int CRgn::OffsetRgn(int x, int y)
  478. { ASSERT(m_hObject != NULL); return ::OffsetRgn((HRGN)m_hObject, x, y); }
  479. _AFXWIN_INLINE int CRgn::OffsetRgn(POINT point)
  480. { ASSERT(m_hObject != NULL); return ::OffsetRgn((HRGN)m_hObject, point.x, point.y); }
  481. _AFXWIN_INLINE int CRgn::GetRgnBox(LPRECT lpRect) const
  482. { ASSERT(m_hObject != NULL); return ::GetRgnBox((HRGN)m_hObject, lpRect); }
  483. _AFXWIN_INLINE BOOL CRgn::PtInRegion(int x, int y) const
  484. { ASSERT(m_hObject != NULL); return ::PtInRegion((HRGN)m_hObject, x, y); }
  485. _AFXWIN_INLINE BOOL CRgn::PtInRegion(POINT point) const
  486. { ASSERT(m_hObject != NULL); return ::PtInRegion((HRGN)m_hObject, point.x, point.y); }
  487. _AFXWIN_INLINE BOOL CRgn::RectInRegion(LPCRECT lpRect) const
  488. { ASSERT(m_hObject != NULL); return ::RectInRegion((HRGN)m_hObject, lpRect); }
  489. // CDC
  490. _AFXWIN_INLINE CDC::operator HDC() const
  491. { return this == NULL ? NULL : m_hDC; }
  492. _AFXWIN_INLINE HDC CDC::GetSafeHdc() const
  493. { return this == NULL ? NULL : m_hDC; }
  494. _AFXWIN_INLINE CWnd* CDC::GetWindow() const
  495. { ASSERT(m_hDC != NULL); return CWnd::FromHandle(::WindowFromDC(m_hDC)); }
  496. _AFXWIN_INLINE BOOL CDC::IsPrinting() const
  497. { return m_bPrinting; }
  498. _AFXWIN_INLINE BOOL CDC::CreateDC(LPCTSTR lpszDriverName,
  499. LPCTSTR lpszDeviceName, LPCTSTR lpszOutput, const void* lpInitData)
  500. { return Attach(::CreateDC(lpszDriverName,
  501. lpszDeviceName, lpszOutput, (const DEVMODE*)lpInitData)); }
  502. _AFXWIN_INLINE BOOL CDC::CreateIC(LPCTSTR lpszDriverName,
  503. LPCTSTR lpszDeviceName, LPCTSTR lpszOutput, const void* lpInitData)
  504. { return Attach(::CreateIC(lpszDriverName,
  505. lpszDeviceName, lpszOutput, (const DEVMODE*) lpInitData)); }
  506. _AFXWIN_INLINE BOOL CDC::CreateCompatibleDC(CDC* pDC)
  507. { return Attach(::CreateCompatibleDC(pDC->GetSafeHdc())); }
  508. _AFXWIN_INLINE int CDC::ExcludeUpdateRgn(CWnd* pWnd)
  509. { ASSERT(m_hDC != NULL); return ::ExcludeUpdateRgn(m_hDC, pWnd->m_hWnd); }
  510. _AFXWIN_INLINE int CDC::GetDeviceCaps(int nIndex) const
  511. { ASSERT(m_hAttribDC != NULL); return ::GetDeviceCaps(m_hAttribDC, nIndex); }
  512. _AFXWIN_INLINE CPoint CDC::GetBrushOrg() const
  513. {
  514. ASSERT(m_hDC != NULL);
  515. POINT point;
  516. VERIFY(::GetBrushOrgEx(m_hDC, &point));
  517. return point;
  518. }
  519. _AFXWIN_INLINE CPoint CDC::SetBrushOrg(int x, int y)
  520. {
  521. ASSERT(m_hDC != NULL);
  522. POINT point;
  523. VERIFY(::SetBrushOrgEx(m_hDC, x, y, &point));
  524. return point;
  525. }
  526. _AFXWIN_INLINE CPoint CDC::SetBrushOrg(POINT point)
  527. {
  528. ASSERT(m_hDC != NULL);
  529. VERIFY(::SetBrushOrgEx(m_hDC, point.x, point.y, &point));
  530. return point;
  531. }
  532. _AFXWIN_INLINE int CDC::EnumObjects(int nObjectType,
  533. int (CALLBACK* lpfn)(LPVOID, LPARAM), LPARAM lpData)
  534. { ASSERT(m_hAttribDC != NULL); return ::EnumObjects(m_hAttribDC, nObjectType, (GOBJENUMPROC)lpfn, lpData); }
  535. _AFXWIN_INLINE CBitmap* CDC::SelectObject(CBitmap* pBitmap)
  536. { ASSERT(m_hDC != NULL); return (CBitmap*) SelectGdiObject(m_hDC, pBitmap->GetSafeHandle()); }
  537. _AFXWIN_INLINE CGdiObject* CDC::SelectObject(CGdiObject* pObject)
  538. { ASSERT(m_hDC != NULL); return SelectGdiObject(m_hDC, pObject->GetSafeHandle()); }
  539. _AFXWIN_INLINE HGDIOBJ CDC::SelectObject(HGDIOBJ hObject) // Safe for NULL handles
  540. { ASSERT(m_hDC == m_hAttribDC); // ASSERT a simple CDC object
  541. return (hObject != NULL) ? ::SelectObject(m_hDC, hObject) : NULL; }
  542. _AFXWIN_INLINE COLORREF CDC::GetNearestColor(COLORREF crColor) const
  543. { ASSERT(m_hAttribDC != NULL); return ::GetNearestColor(m_hAttribDC, crColor); }
  544. _AFXWIN_INLINE UINT CDC::RealizePalette()
  545. { ASSERT(m_hDC != NULL); return ::RealizePalette(m_hDC); }
  546. _AFXWIN_INLINE void CDC::UpdateColors()
  547. { ASSERT(m_hDC != NULL); ::UpdateColors(m_hDC); }
  548. _AFXWIN_INLINE COLORREF CDC::GetBkColor() const
  549. { ASSERT(m_hAttribDC != NULL); return ::GetBkColor(m_hAttribDC); }
  550. _AFXWIN_INLINE int CDC::GetBkMode() const
  551. { ASSERT(m_hAttribDC != NULL); return ::GetBkMode(m_hAttribDC); }
  552. _AFXWIN_INLINE int CDC::GetPolyFillMode() const
  553. { ASSERT(m_hAttribDC != NULL); return ::GetPolyFillMode(m_hAttribDC); }
  554. _AFXWIN_INLINE int CDC::GetROP2() const
  555. { ASSERT(m_hAttribDC != NULL); return ::GetROP2(m_hAttribDC); }
  556. _AFXWIN_INLINE int CDC::GetStretchBltMode() const
  557. { ASSERT(m_hAttribDC != NULL); return ::GetStretchBltMode(m_hAttribDC); }
  558. _AFXWIN_INLINE COLORREF CDC::GetTextColor() const
  559. { ASSERT(m_hAttribDC != NULL); return ::GetTextColor(m_hAttribDC); }
  560. _AFXWIN_INLINE int CDC::GetMapMode() const
  561. { ASSERT(m_hAttribDC != NULL); return ::GetMapMode(m_hAttribDC); }
  562. _AFXWIN_INLINE CPoint CDC::GetViewportOrg() const
  563. {
  564. ASSERT(m_hAttribDC != NULL);
  565. POINT point;
  566. VERIFY(::GetViewportOrgEx(m_hAttribDC, &point));
  567. return point;
  568. }
  569. _AFXWIN_INLINE CSize CDC::GetViewportExt() const
  570. {
  571. ASSERT(m_hAttribDC != NULL);
  572. SIZE size;
  573. VERIFY(::GetViewportExtEx(m_hAttribDC, &size));
  574. return size;
  575. }
  576. _AFXWIN_INLINE CPoint CDC::GetWindowOrg() const
  577. {
  578. ASSERT(m_hAttribDC != NULL);
  579. POINT point;
  580. VERIFY(::GetWindowOrgEx(m_hAttribDC, &point));
  581. return point;
  582. }
  583. _AFXWIN_INLINE CSize CDC::GetWindowExt() const
  584. {
  585. ASSERT(m_hAttribDC != NULL);
  586. SIZE size;
  587. VERIFY(::GetWindowExtEx(m_hAttribDC, &size));
  588. return size;
  589. }
  590. // non-virtual helpers calling virtual mapping functions
  591. _AFXWIN_INLINE CPoint CDC::SetViewportOrg(POINT point)
  592. { ASSERT(m_hDC != NULL); return SetViewportOrg(point.x, point.y); }
  593. _AFXWIN_INLINE CSize CDC::SetViewportExt(SIZE size)
  594. { ASSERT(m_hDC != NULL); return SetViewportExt(size.cx, size.cy); }
  595. _AFXWIN_INLINE CPoint CDC::SetWindowOrg(POINT point)
  596. { ASSERT(m_hDC != NULL); return SetWindowOrg(point.x, point.y); }
  597. _AFXWIN_INLINE CSize CDC::SetWindowExt(SIZE size)
  598. { ASSERT(m_hDC != NULL); return SetWindowExt(size.cx, size.cy); }
  599. _AFXWIN_INLINE void CDC::DPtoLP(LPPOINT lpPoints, int nCount) const
  600. { ASSERT(m_hAttribDC != NULL); VERIFY(::DPtoLP(m_hAttribDC, lpPoints, nCount)); }
  601. _AFXWIN_INLINE void CDC::DPtoLP(LPRECT lpRect) const
  602. { ASSERT(m_hAttribDC != NULL); VERIFY(::DPtoLP(m_hAttribDC, (LPPOINT)lpRect, 2)); }
  603. _AFXWIN_INLINE void CDC::LPtoDP(LPPOINT lpPoints, int nCount) const
  604. { ASSERT(m_hAttribDC != NULL); VERIFY(::LPtoDP(m_hAttribDC, lpPoints, nCount)); }
  605. _AFXWIN_INLINE void CDC::LPtoDP(LPRECT lpRect) const
  606. { ASSERT(m_hAttribDC != NULL); VERIFY(::LPtoDP(m_hAttribDC, (LPPOINT)lpRect, 2)); }
  607. _AFXWIN_INLINE BOOL CDC::FillRgn(CRgn* pRgn, CBrush* pBrush)
  608. { ASSERT(m_hDC != NULL); return ::FillRgn(m_hDC, (HRGN)pRgn->GetSafeHandle(), (HBRUSH)pBrush->GetSafeHandle()); }
  609. _AFXWIN_INLINE BOOL CDC::FrameRgn(CRgn* pRgn, CBrush* pBrush, int nWidth, int nHeight)
  610. { ASSERT(m_hDC != NULL); return ::FrameRgn(m_hDC, (HRGN)pRgn->GetSafeHandle(), (HBRUSH)pBrush->GetSafeHandle(),
  611. nWidth, nHeight); }
  612. _AFXWIN_INLINE BOOL CDC::InvertRgn(CRgn* pRgn)
  613. { ASSERT(m_hDC != NULL); return ::InvertRgn(m_hDC, (HRGN)pRgn->GetSafeHandle()); }
  614. _AFXWIN_INLINE BOOL CDC::PaintRgn(CRgn* pRgn)
  615. { ASSERT(m_hDC != NULL); return ::PaintRgn(m_hDC, (HRGN)pRgn->GetSafeHandle()); }
  616. _AFXWIN_INLINE BOOL CDC::PtVisible(int x, int y) const
  617. { ASSERT(m_hDC != NULL); return ::PtVisible(m_hDC, x, y); }
  618. _AFXWIN_INLINE BOOL CDC::PtVisible(POINT point) const
  619. { ASSERT(m_hDC != NULL); return PtVisible(point.x, point.y); } // call virtual
  620. _AFXWIN_INLINE BOOL CDC::RectVisible(LPCRECT lpRect) const
  621. { ASSERT(m_hDC != NULL); return ::RectVisible(m_hDC, lpRect); }
  622. _AFXWIN_INLINE CPoint CDC::GetCurrentPosition() const
  623. {
  624. ASSERT(m_hAttribDC != NULL);
  625. POINT point;
  626. VERIFY(::GetCurrentPositionEx(m_hAttribDC, &point));
  627. return point;
  628. }
  629. _AFXWIN_INLINE CPoint CDC::MoveTo(POINT point)
  630. { ASSERT(m_hDC != NULL); return MoveTo(point.x, point.y); }
  631. _AFXWIN_INLINE BOOL CDC::LineTo(POINT point)
  632. { ASSERT(m_hDC != NULL); return LineTo(point.x, point.y); }
  633. _AFXWIN_INLINE BOOL CDC::Arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
  634. { ASSERT(m_hDC != NULL); return ::Arc(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4); }
  635. _AFXWIN_INLINE BOOL CDC::Arc(LPCRECT lpRect, POINT ptStart, POINT ptEnd)
  636. { ASSERT(m_hDC != NULL); return ::Arc(m_hDC, lpRect->left, lpRect->top,
  637. lpRect->right, lpRect->bottom, ptStart.x, ptStart.y,
  638. ptEnd.x, ptEnd.y); }
  639. _AFXWIN_INLINE BOOL CDC::Polyline(LPPOINT lpPoints, int nCount)
  640. { ASSERT(m_hDC != NULL); return ::Polyline(m_hDC, lpPoints, nCount); }
  641. _AFXWIN_INLINE void CDC::FillRect(LPCRECT lpRect, CBrush* pBrush)
  642. { ASSERT(m_hDC != NULL); ::FillRect(m_hDC, lpRect, (HBRUSH)pBrush->GetSafeHandle()); }
  643. _AFXWIN_INLINE void CDC::FrameRect(LPCRECT lpRect, CBrush* pBrush)
  644. { ASSERT(m_hDC != NULL); ::FrameRect(m_hDC, lpRect, (HBRUSH)pBrush->GetSafeHandle()); }
  645. _AFXWIN_INLINE void CDC::InvertRect(LPCRECT lpRect)
  646. { ASSERT(m_hDC != NULL); ::InvertRect(m_hDC, lpRect); }
  647. _AFXWIN_INLINE BOOL CDC::DrawIcon(int x, int y, HICON hIcon)
  648. { ASSERT(m_hDC != NULL); return ::DrawIcon(m_hDC, x, y, hIcon); }
  649. _AFXWIN_INLINE BOOL CDC::DrawIcon(POINT point, HICON hIcon)
  650. { ASSERT(m_hDC != NULL); return ::DrawIcon(m_hDC, point.x, point.y, hIcon); }
  651. #if (WINVER >= 0x400)
  652. _AFXWIN_INLINE BOOL CDC::DrawState(CPoint pt, CSize size, HBITMAP hBitmap, UINT nFlags, HBRUSH hBrush)
  653. { ASSERT(m_hDC != NULL); return ::DrawState(m_hDC, hBrush,
  654. NULL, (LPARAM)hBitmap, 0, pt.x, pt.y, size.cx, size.cy, nFlags|DST_BITMAP); }
  655. _AFXWIN_INLINE BOOL CDC::DrawState(CPoint pt, CSize size, CBitmap* pBitmap, UINT nFlags, CBrush* pBrush)
  656. { ASSERT(m_hDC != NULL); return ::DrawState(m_hDC, (HBRUSH)pBrush->GetSafeHandle(),
  657. NULL, (LPARAM)pBitmap->GetSafeHandle(), 0, pt.x, pt.y, size.cx, size.cy, nFlags|DST_BITMAP); }
  658. _AFXWIN_INLINE BOOL CDC::DrawState(CPoint pt, CSize size, HICON hIcon, UINT nFlags, HBRUSH hBrush)
  659. { ASSERT(m_hDC != NULL); return ::DrawState(m_hDC, hBrush, NULL,
  660. (LPARAM)hIcon, 0, pt.x, pt.y, size.cx, size.cy, nFlags|DST_ICON); }
  661. _AFXWIN_INLINE BOOL CDC::DrawState(CPoint pt, CSize size, HICON hIcon, UINT nFlags, CBrush* pBrush)
  662. { ASSERT(m_hDC != NULL); return ::DrawState(m_hDC, (HBRUSH)pBrush->GetSafeHandle(), NULL,
  663. (LPARAM)hIcon, 0, pt.x, pt.y, size.cx, size.cy, nFlags|DST_ICON); }
  664. _AFXWIN_INLINE BOOL CDC::DrawState(CPoint pt, CSize size, LPCTSTR lpszText, UINT nFlags, BOOL bPrefixText, int nTextLen, HBRUSH hBrush)
  665. { ASSERT(m_hDC != NULL); return ::DrawState(m_hDC, hBrush,
  666. NULL, (LPARAM)lpszText, (WPARAM)nTextLen, pt.x, pt.y, size.cx, size.cy, nFlags|(bPrefixText ? DST_PREFIXTEXT : DST_TEXT)); }
  667. _AFXWIN_INLINE BOOL CDC::DrawState(CPoint pt, CSize size, LPCTSTR lpszText, UINT nFlags, BOOL bPrefixText, int nTextLen, CBrush* pBrush)
  668. { ASSERT(m_hDC != NULL); return ::DrawState(m_hDC, (HBRUSH)pBrush->GetSafeHandle(),
  669. NULL, (LPARAM)lpszText, (WPARAM)nTextLen, pt.x, pt.y, size.cx, size.cy, nFlags|(bPrefixText ? DST_PREFIXTEXT : DST_TEXT)); }
  670. _AFXWIN_INLINE BOOL CDC::DrawState(CPoint pt, CSize size, DRAWSTATEPROC lpDrawProc, LPARAM lData, UINT nFlags, HBRUSH hBrush)
  671. { ASSERT(m_hDC != NULL); return ::DrawState(m_hDC, hBrush,
  672. lpDrawProc, lData, 0, pt.x, pt.y, size.cx, size.cy, nFlags|DST_COMPLEX); }
  673. _AFXWIN_INLINE BOOL CDC::DrawState(CPoint pt, CSize size, DRAWSTATEPROC lpDrawProc, LPARAM lData, UINT nFlags, CBrush* pBrush)
  674. { ASSERT(m_hDC != NULL); return ::DrawState(m_hDC, (HBRUSH)pBrush->GetSafeHandle(),
  675. lpDrawProc, lData, 0, pt.x, pt.y, size.cx, size.cy, nFlags|DST_COMPLEX); }
  676. _AFXWIN_INLINE BOOL CDC::DrawEdge(LPRECT lpRect, UINT nEdge, UINT nFlags)
  677. { ASSERT(m_hDC != NULL); return ::DrawEdge(m_hDC, lpRect, nEdge, nFlags); }
  678. _AFXWIN_INLINE BOOL CDC::DrawFrameControl(LPRECT lpRect, UINT nType, UINT nState)
  679. { ASSERT(m_hDC != NULL); return ::DrawFrameControl(m_hDC, lpRect, nType, nState); }
  680. #endif
  681. _AFXWIN_INLINE BOOL CDC::Chord(int x1, int y1, int x2, int y2, int x3, int y3,
  682. int x4, int y4)
  683. { ASSERT(m_hDC != NULL); return ::Chord(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4); }
  684. _AFXWIN_INLINE BOOL CDC::Chord(LPCRECT lpRect, POINT ptStart, POINT ptEnd)
  685. { ASSERT(m_hDC != NULL); return ::Chord(m_hDC, lpRect->left, lpRect->top,
  686. lpRect->right, lpRect->bottom, ptStart.x, ptStart.y,
  687. ptEnd.x, ptEnd.y); }
  688. _AFXWIN_INLINE void CDC::DrawFocusRect(LPCRECT lpRect)
  689. { ASSERT(m_hDC != NULL); ::DrawFocusRect(m_hDC, lpRect); }
  690. _AFXWIN_INLINE BOOL CDC::Ellipse(int x1, int y1, int x2, int y2)
  691. { ASSERT(m_hDC != NULL); return ::Ellipse(m_hDC, x1, y1, x2, y2); }
  692. _AFXWIN_INLINE BOOL CDC::Ellipse(LPCRECT lpRect)
  693. { ASSERT(m_hDC != NULL); return ::Ellipse(m_hDC, lpRect->left, lpRect->top,
  694. lpRect->right, lpRect->bottom); }
  695. _AFXWIN_INLINE BOOL CDC::Pie(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
  696. { ASSERT(m_hDC != NULL); return ::Pie(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4); }
  697. _AFXWIN_INLINE BOOL CDC::Pie(LPCRECT lpRect, POINT ptStart, POINT ptEnd)
  698. { ASSERT(m_hDC != NULL); return ::Pie(m_hDC, lpRect->left, lpRect->top,
  699. lpRect->right, lpRect->bottom, ptStart.x, ptStart.y,
  700. ptEnd.x, ptEnd.y); }
  701. _AFXWIN_INLINE BOOL CDC::Polygon(LPPOINT lpPoints, int nCount)
  702. { ASSERT(m_hDC != NULL); return ::Polygon(m_hDC, lpPoints, nCount); }
  703. _AFXWIN_INLINE BOOL CDC::PolyPolygon(LPPOINT lpPoints, LPINT lpPolyCounts, int nCount)
  704. { ASSERT(m_hDC != NULL); return ::PolyPolygon(m_hDC, lpPoints, lpPolyCounts, nCount); }
  705. _AFXWIN_INLINE BOOL CDC::Rectangle(int x1, int y1, int x2, int y2)
  706. { ASSERT(m_hDC != NULL); return ::Rectangle(m_hDC, x1, y1, x2, y2); }
  707. _AFXWIN_INLINE BOOL CDC::Rectangle(LPCRECT lpRect)
  708. { ASSERT(m_hDC != NULL); return ::Rectangle(m_hDC, lpRect->left, lpRect->top,
  709. lpRect->right, lpRect->bottom); }
  710. _AFXWIN_INLINE BOOL CDC::RoundRect(int x1, int y1, int x2, int y2, int x3, int y3)
  711. { ASSERT(m_hDC != NULL); return ::RoundRect(m_hDC, x1, y1, x2, y2, x3, y3); }
  712. _AFXWIN_INLINE BOOL CDC::RoundRect(LPCRECT lpRect, POINT point)
  713. { ASSERT(m_hDC != NULL); return ::RoundRect(m_hDC, lpRect->left, lpRect->top,
  714. lpRect->right, lpRect->bottom, point.x, point.y); }
  715. _AFXWIN_INLINE BOOL CDC::PatBlt(int x, int y, int nWidth, int nHeight, DWORD dwRop)
  716. { ASSERT(m_hDC != NULL); return ::PatBlt(m_hDC, x, y, nWidth, nHeight, dwRop); }
  717. _AFXWIN_INLINE BOOL CDC::BitBlt(int x, int y, int nWidth, int nHeight, CDC* pSrcDC,
  718. int xSrc, int ySrc, DWORD dwRop)
  719. { ASSERT(m_hDC != NULL); return ::BitBlt(m_hDC, x, y, nWidth, nHeight,
  720. pSrcDC->GetSafeHdc(), xSrc, ySrc, dwRop); }
  721. _AFXWIN_INLINE BOOL CDC::StretchBlt(int x, int y, int nWidth, int nHeight, CDC* pSrcDC,
  722. int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, DWORD dwRop)
  723. { ASSERT(m_hDC != NULL); return ::StretchBlt(m_hDC, x, y, nWidth, nHeight,
  724. pSrcDC->GetSafeHdc(), xSrc, ySrc, nSrcWidth, nSrcHeight,
  725. dwRop); }
  726. _AFXWIN_INLINE COLORREF CDC::GetPixel(int x, int y) const
  727. { ASSERT(m_hDC != NULL); return ::GetPixel(m_hDC, x, y); }
  728. _AFXWIN_INLINE COLORREF CDC::GetPixel(POINT point) const
  729. { ASSERT(m_hDC != NULL); return ::GetPixel(m_hDC, point.x, point.y); }
  730. _AFXWIN_INLINE COLORREF CDC::SetPixel(int x, int y, COLORREF crColor)
  731. { ASSERT(m_hDC != NULL); return ::SetPixel(m_hDC, x, y, crColor); }
  732. _AFXWIN_INLINE COLORREF CDC::SetPixel(POINT point, COLORREF crColor)
  733. { ASSERT(m_hDC != NULL); return ::SetPixel(m_hDC, point.x, point.y, crColor); }
  734. _AFXWIN_INLINE BOOL CDC::FloodFill(int x, int y, COLORREF crColor)
  735. { ASSERT(m_hDC != NULL); return ::FloodFill(m_hDC, x, y, crColor); }
  736. _AFXWIN_INLINE BOOL CDC::ExtFloodFill(int x, int y, COLORREF crColor, UINT nFillType)
  737. { ASSERT(m_hDC != NULL); return ::ExtFloodFill(m_hDC, x, y, crColor, nFillType); }
  738. _AFXWIN_INLINE BOOL CDC::TextOut(int x, int y, LPCTSTR lpszString, int nCount)
  739. { ASSERT(m_hDC != NULL); return ::TextOut(m_hDC, x, y, lpszString, nCount); }
  740. _AFXWIN_INLINE BOOL CDC::TextOut(int x, int y, const CString& str)
  741. { ASSERT(m_hDC != NULL); return TextOut(x, y, (LPCTSTR)str, str.GetLength()); } // call virtual
  742. _AFXWIN_INLINE BOOL CDC::ExtTextOut(int x, int y, UINT nOptions, LPCRECT lpRect,
  743. LPCTSTR lpszString, UINT nCount, LPINT lpDxWidths)
  744. { ASSERT(m_hDC != NULL); return ::ExtTextOut(m_hDC, x, y, nOptions, lpRect,
  745. lpszString, nCount, lpDxWidths); }
  746. _AFXWIN_INLINE BOOL CDC::ExtTextOut(int x, int y, UINT nOptions, LPCRECT lpRect,
  747. const CString& str, LPINT lpDxWidths)
  748. { ASSERT(m_hDC != NULL); return ::ExtTextOut(m_hDC, x, y, nOptions, lpRect,
  749. str, str.GetLength(), lpDxWidths); }
  750. _AFXWIN_INLINE CSize CDC::TabbedTextOut(int x, int y, LPCTSTR lpszString, int nCount,
  751. int nTabPositions, LPINT lpnTabStopPositions, int nTabOrigin)
  752. { ASSERT(m_hDC != NULL); return ::TabbedTextOut(m_hDC, x, y, lpszString, nCount,
  753. nTabPositions, lpnTabStopPositions, nTabOrigin); }
  754. _AFXWIN_INLINE CSize CDC::TabbedTextOut(int x, int y, const CString& str,
  755. int nTabPositions, LPINT lpnTabStopPositions, int nTabOrigin)
  756. { ASSERT(m_hDC != NULL); return ::TabbedTextOut(m_hDC, x, y, str, str.GetLength(),
  757. nTabPositions, lpnTabStopPositions, nTabOrigin); }
  758. _AFXWIN_INLINE int CDC::DrawText(LPCTSTR lpszString, int nCount, LPRECT lpRect,
  759. UINT nFormat)
  760. { ASSERT(m_hDC != NULL);
  761. return ::DrawText(m_hDC, lpszString, nCount, lpRect, nFormat); }
  762. _AFXWIN_INLINE int CDC::DrawText(const CString& str, LPRECT lpRect, UINT nFormat)
  763. { ASSERT(m_hDC != NULL);
  764. // these flags would modify the string
  765. ASSERT((nFormat & (DT_END_ELLIPSIS | DT_MODIFYSTRING)) != (DT_END_ELLIPSIS | DT_MODIFYSTRING));
  766. ASSERT((nFormat & (DT_PATH_ELLIPSIS | DT_MODIFYSTRING)) != (DT_PATH_ELLIPSIS | DT_MODIFYSTRING));
  767. return DrawText((LPCTSTR)str, str.GetLength(), lpRect, nFormat); }
  768. _AFXWIN_INLINE CSize CDC::GetTextExtent(LPCTSTR lpszString, int nCount) const
  769. {
  770. ASSERT(m_hAttribDC != NULL);
  771. SIZE size;
  772. VERIFY(::GetTextExtentPoint32(m_hAttribDC, lpszString, nCount, &size));
  773. return size;
  774. }
  775. _AFXWIN_INLINE CSize CDC::GetTextExtent(const CString& str) const
  776. {
  777. ASSERT(m_hAttribDC != NULL);
  778. SIZE size;
  779. VERIFY(::GetTextExtentPoint32(m_hAttribDC, str, str.GetLength(), &size));
  780. return size;
  781. }
  782. _AFXWIN_INLINE CSize CDC::GetOutputTextExtent(LPCTSTR lpszString, int nCount) const
  783. {
  784. ASSERT(m_hDC != NULL);
  785. SIZE size;
  786. VERIFY(::GetTextExtentPoint32(m_hDC, lpszString, nCount, &size));
  787. return size;
  788. }
  789. _AFXWIN_INLINE CSize CDC::GetOutputTextExtent(const CString& str) const
  790. {
  791. ASSERT(m_hDC != NULL);
  792. SIZE size;
  793. VERIFY(::GetTextExtentPoint32(m_hDC, str, str.GetLength(), &size));
  794. return size;
  795. }
  796. _AFXWIN_INLINE CSize CDC::GetTabbedTextExtent(LPCTSTR lpszString, int nCount,
  797. int nTabPositions, LPINT lpnTabStopPositions) const
  798. { ASSERT(m_hAttribDC != NULL); return ::GetTabbedTextExtent(m_hAttribDC, lpszString, nCount,
  799. nTabPositions, lpnTabStopPositions); }
  800. _AFXWIN_INLINE CSize CDC::GetTabbedTextExtent(const CString& str,
  801. int nTabPositions, LPINT lpnTabStopPositions) const
  802. { ASSERT(m_hAttribDC != NULL); return ::GetTabbedTextExtent(m_hAttribDC,
  803. str, str.GetLength(), nTabPositions, lpnTabStopPositions); }
  804. _AFXWIN_INLINE CSize CDC::GetOutputTabbedTextExtent(LPCTSTR lpszString, int nCount,
  805. int nTabPositions, LPINT lpnTabStopPositions) const
  806. { ASSERT(m_hDC != NULL); return ::GetTabbedTextExtent(m_hDC, lpszString, nCount,
  807. nTabPositions, lpnTabStopPositions); }
  808. _AFXWIN_INLINE CSize CDC::GetOutputTabbedTextExtent(const CString& str,
  809. int nTabPositions, LPINT lpnTabStopPositions) const
  810. { ASSERT(m_hDC != NULL); return ::GetTabbedTextExtent(m_hDC,
  811. str, str.GetLength(), nTabPositions, lpnTabStopPositions); }
  812. _AFXWIN_INLINE BOOL CDC::GrayString(CBrush* pBrush,
  813. BOOL (CALLBACK* lpfnOutput)(HDC, LPARAM, int),
  814. LPARAM lpData, int nCount,
  815. int x, int y, int nWidth, int nHeight)
  816. { ASSERT(m_hDC != NULL); return ::GrayString(m_hDC, (HBRUSH)pBrush->GetSafeHandle(),
  817. (GRAYSTRINGPROC)lpfnOutput, lpData, nCount, x, y, nWidth, nHeight); }
  818. _AFXWIN_INLINE UINT CDC::GetTextAlign() const
  819. { ASSERT(m_hAttribDC != NULL); return ::GetTextAlign(m_hAttribDC); }
  820. _AFXWIN_INLINE int CDC::GetTextFace(int nCount, LPTSTR lpszFacename) const
  821. { ASSERT(m_hAttribDC != NULL); return ::GetTextFace(m_hAttribDC, nCount, lpszFacename); }
  822. _AFXWIN_INLINE int CDC::GetTextFace(CString& rString) const
  823. { ASSERT(m_hAttribDC != NULL); int nResult = ::GetTextFace(m_hAttribDC,
  824. 256, rString.GetBuffer(256)); rString.ReleaseBuffer();
  825. return nResult; }
  826. _AFXWIN_INLINE BOOL CDC::GetTextMetrics(LPTEXTMETRIC lpMetrics) const
  827. { ASSERT(m_hAttribDC != NULL); return ::GetTextMetrics(m_hAttribDC, lpMetrics); }
  828. _AFXWIN_INLINE BOOL CDC::GetOutputTextMetrics(LPTEXTMETRIC lpMetrics) const
  829. { ASSERT(m_hDC != NULL); return ::GetTextMetrics(m_hDC, lpMetrics); }
  830. _AFXWIN_INLINE int CDC::GetTextCharacterExtra() const
  831. { ASSERT(m_hAttribDC != NULL); return ::GetTextCharacterExtra(m_hAttribDC); }
  832. _AFXWIN_INLINE BOOL CDC::GetCharWidth(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer) const
  833. { ASSERT(m_hAttribDC != NULL); return ::GetCharWidth(m_hAttribDC, nFirstChar, nLastChar, lpBuffer); }
  834. _AFXWIN_INLINE BOOL CDC::GetOutputCharWidth(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer) const
  835. { ASSERT(m_hDC != NULL); return ::GetCharWidth(m_hDC, nFirstChar, nLastChar, lpBuffer); }
  836. _AFXWIN_INLINE CSize CDC::GetAspectRatioFilter() const
  837. {
  838. ASSERT(m_hAttribDC != NULL);
  839. SIZE size;
  840. VERIFY(::GetAspectRatioFilterEx(m_hAttribDC, &size));
  841. return size;
  842. }
  843. _AFXWIN_INLINE BOOL CDC::ScrollDC(int dx, int dy,
  844. LPCRECT lpRectScroll, LPCRECT lpRectClip,
  845. CRgn* pRgnUpdate, LPRECT lpRectUpdate)
  846. { ASSERT(m_hDC != NULL); return ::ScrollDC(m_hDC, dx, dy, lpRectScroll,
  847. lpRectClip, (HRGN)pRgnUpdate->GetSafeHandle(), lpRectUpdate); }
  848. // Printer Escape Functions
  849. _AFXWIN_INLINE int CDC::Escape(int nEscape, int nCount, LPCSTR lpszInData, LPVOID lpOutData)
  850. { ASSERT(m_hDC != NULL); return ::Escape(m_hDC, nEscape, nCount, lpszInData, lpOutData);}
  851. // CDC 3.1 Specific functions
  852. _AFXWIN_INLINE UINT CDC::SetBoundsRect(LPCRECT lpRectBounds, UINT flags)
  853. { ASSERT(m_hDC != NULL); return ::SetBoundsRect(m_hDC, lpRectBounds, flags); }
  854. _AFXWIN_INLINE UINT CDC::GetBoundsRect(LPRECT lpRectBounds, UINT flags)
  855. { ASSERT(m_hAttribDC != NULL); return ::GetBoundsRect(m_hAttribDC, lpRectBounds, flags); }
  856. _AFXWIN_INLINE BOOL CDC::ResetDC(const DEVMODE* lpDevMode)
  857. { ASSERT(m_hAttribDC != NULL); return ::ResetDC(m_hAttribDC, lpDevMode) != NULL; }
  858. _AFXWIN_INLINE UINT CDC::GetOutlineTextMetrics(UINT cbData, LPOUTLINETEXTMETRIC lpotm) const
  859. { ASSERT(m_hAttribDC != NULL); return ::GetOutlineTextMetrics(m_hAttribDC, cbData, lpotm); }
  860. _AFXWIN_INLINE BOOL CDC::GetCharABCWidths(UINT nFirstChar, UINT nLastChar, LPABC lpabc) const
  861. { ASSERT(m_hAttribDC != NULL); return ::GetCharABCWidths(m_hAttribDC, nFirstChar, nLastChar, lpabc); }
  862. _AFXWIN_INLINE DWORD CDC::GetFontData(DWORD dwTable, DWORD dwOffset, LPVOID lpData,
  863. DWORD cbData) const
  864. { ASSERT(m_hAttribDC != NULL); return ::GetFontData(m_hAttribDC, dwTable, dwOffset, lpData, cbData); }
  865. _AFXWIN_INLINE int CDC::GetKerningPairs(int nPairs, LPKERNINGPAIR lpkrnpair) const
  866. { ASSERT(m_hAttribDC != NULL); return ::GetKerningPairs(m_hAttribDC, nPairs, lpkrnpair); }
  867. _AFXWIN_INLINE DWORD CDC::GetGlyphOutline(UINT nChar, UINT nFormat, LPGLYPHMETRICS lpgm,
  868. DWORD cbBuffer, LPVOID lpBuffer, const MAT2* lpmat2) const
  869. { ASSERT(m_hAttribDC != NULL); return ::GetGlyphOutline(m_hAttribDC, nChar, nFormat,
  870. lpgm, cbBuffer, lpBuffer, lpmat2); }
  871. // Document handling functions
  872. _AFXWIN_INLINE int CDC::StartDoc(LPDOCINFO lpDocInfo)
  873. { ASSERT(m_hDC != NULL); return ::StartDoc(m_hDC, lpDocInfo); }
  874. _AFXWIN_INLINE int CDC::StartPage()
  875. { ASSERT(m_hDC != NULL); return ::StartPage(m_hDC); }
  876. _AFXWIN_INLINE int CDC::EndPage()
  877. { ASSERT(m_hDC != NULL); return ::EndPage(m_hDC); }
  878. _AFXWIN_INLINE int CDC::SetAbortProc(BOOL (CALLBACK* lpfn)(HDC, int))
  879. { ASSERT(m_hDC != NULL); return ::SetAbortProc(m_hDC, (ABORTPROC)lpfn); }
  880. _AFXWIN_INLINE int CDC::AbortDoc()
  881. { ASSERT(m_hDC != NULL); return ::AbortDoc(m_hDC); }
  882. _AFXWIN_INLINE int CDC::EndDoc()
  883. { ASSERT(m_hDC != NULL); return ::EndDoc(m_hDC); }
  884. _AFXWIN_INLINE BOOL CDC::MaskBlt(int x, int y, int nWidth, int nHeight, CDC* pSrcDC,
  885. int xSrc, int ySrc, CBitmap& maskBitmap, int xMask, int yMask, DWORD dwRop)
  886. { ASSERT(m_hDC != NULL); return ::MaskBlt(m_hDC, x, y, nWidth, nHeight, pSrcDC->GetSafeHdc(),
  887. xSrc, ySrc, (HBITMAP)maskBitmap.m_hObject, xMask, yMask, dwRop); }
  888. _AFXWIN_INLINE BOOL CDC::PlgBlt(LPPOINT lpPoint, CDC* pSrcDC, int xSrc, int ySrc,
  889. int nWidth, int nHeight, CBitmap& maskBitmap, int xMask, int yMask)
  890. { ASSERT(m_hDC != NULL); return ::PlgBlt(m_hDC, lpPoint, pSrcDC->GetSafeHdc(), xSrc, ySrc, nWidth,
  891. nHeight, (HBITMAP)maskBitmap.m_hObject, xMask, yMask); }
  892. _AFXWIN_INLINE BOOL CDC::SetPixelV(int x, int y, COLORREF crColor)
  893. { ASSERT(m_hDC != NULL); return ::SetPixelV(m_hDC, x, y, crColor); }
  894. _AFXWIN_INLINE BOOL CDC::SetPixelV(POINT point, COLORREF crColor)
  895. { ASSERT(m_hDC != NULL); return ::SetPixelV(m_hDC, point.x, point.y, crColor); }
  896. _AFXWIN_INLINE BOOL CDC::AngleArc(int x, int y, int nRadius,
  897. float fStartAngle, float fSweepAngle)
  898. { ASSERT(m_hDC != NULL); return ::AngleArc(m_hDC, x, y, nRadius, fStartAngle, fSweepAngle); }
  899. _AFXWIN_INLINE BOOL CDC::ArcTo(LPCRECT lpRect, POINT ptStart, POINT ptEnd)
  900. { ASSERT(m_hDC != NULL); return ArcTo(lpRect->left, lpRect->top, lpRect->right,
  901. lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y); }
  902. _AFXWIN_INLINE int CDC::GetArcDirection() const
  903. { ASSERT(m_hAttribDC != NULL); return ::GetArcDirection(m_hAttribDC); }
  904. _AFXWIN_INLINE BOOL CDC::PolyPolyline(const POINT* lpPoints, const DWORD* lpPolyPoints,
  905. int nCount)
  906. { ASSERT(m_hDC != NULL); return ::PolyPolyline(m_hDC, lpPoints, lpPolyPoints, nCount); }
  907. _AFXWIN_INLINE BOOL CDC::GetColorAdjustment(LPCOLORADJUSTMENT lpColorAdjust) const
  908. { ASSERT(m_hAttribDC != NULL); return ::GetColorAdjustment(m_hAttribDC, lpColorAdjust); }
  909. _AFXWIN_INLINE CPen* CDC::GetCurrentPen() const
  910. { ASSERT(m_hAttribDC != NULL); return CPen::FromHandle((HPEN)::GetCurrentObject(m_hAttribDC, OBJ_PEN)); }
  911. _AFXWIN_INLINE CBrush* CDC::GetCurrentBrush() const
  912. { ASSERT(m_hAttribDC != NULL); return CBrush::FromHandle((HBRUSH)::GetCurrentObject(m_hAttribDC, OBJ_BRUSH)); }
  913. _AFXWIN_INLINE CPalette* CDC::GetCurrentPalette() const
  914. { ASSERT(m_hAttribDC != NULL); return CPalette::FromHandle((HPALETTE)::GetCurrentObject(m_hAttribDC, OBJ_PAL)); }
  915. _AFXWIN_INLINE CFont* CDC::GetCurrentFont() const
  916. { ASSERT(m_hAttribDC != NULL); return CFont::FromHandle((HFONT)::GetCurrentObject(m_hAttribDC, OBJ_FONT)); }
  917. _AFXWIN_INLINE CBitmap* CDC::GetCurrentBitmap() const
  918. { ASSERT(m_hAttribDC != NULL); return CBitmap::FromHandle((HBITMAP)::GetCurrentObject(m_hAttribDC, OBJ_BITMAP)); }
  919. _AFXWIN_INLINE BOOL CDC::PolyBezier(const POINT* lpPoints, int nCount)
  920. { ASSERT(m_hDC != NULL); return ::PolyBezier(m_hDC, lpPoints, nCount); }
  921. _AFXWIN_INLINE int CDC::DrawEscape(int nEscape, int nInputSize, LPCSTR lpszInputData)
  922. { ASSERT(m_hDC != NULL); return ::DrawEscape(m_hDC, nEscape, nInputSize, lpszInputData); }
  923. _AFXWIN_INLINE int CDC::Escape(int nEscape, int nInputSize, LPCSTR lpszInputData,
  924. int nOutputSize, LPSTR lpszOutputData)
  925. { ASSERT(m_hDC != NULL); return ::ExtEscape(m_hDC, nEscape, nInputSize, lpszInputData,
  926. nOutputSize, lpszOutputData); }
  927. _AFXWIN_INLINE BOOL CDC::GetCharABCWidths(UINT nFirstChar, UINT nLastChar,
  928. LPABCFLOAT lpABCF) const
  929. { ASSERT(m_hAttribDC != NULL); return ::GetCharABCWidthsFloat(m_hAttribDC, nFirstChar, nLastChar, lpABCF); }
  930. _AFXWIN_INLINE BOOL CDC::GetCharWidth(UINT nFirstChar, UINT nLastChar,
  931. float* lpFloatBuffer) const
  932. { ASSERT(m_hAttribDC != NULL); return ::GetCharWidthFloat(m_hAttribDC, nFirstChar, nLastChar, lpFloatBuffer); }
  933. _AFXWIN_INLINE BOOL CDC::AbortPath()
  934. { ASSERT(m_hDC != NULL); return ::AbortPath(m_hDC); }
  935. _AFXWIN_INLINE BOOL CDC::BeginPath()
  936. { ASSERT(m_hDC != NULL); return ::BeginPath(m_hDC); }
  937. _AFXWIN_INLINE BOOL CDC::CloseFigure()
  938. { ASSERT(m_hDC != NULL); return ::CloseFigure(m_hDC); }
  939. _AFXWIN_INLINE BOOL CDC::EndPath()
  940. { ASSERT(m_hDC != NULL); return ::EndPath(m_hDC); }
  941. _AFXWIN_INLINE BOOL CDC::FillPath()
  942. { ASSERT(m_hDC != NULL); return ::FillPath(m_hDC); }
  943. _AFXWIN_INLINE BOOL CDC::FlattenPath()
  944. { ASSERT(m_hDC != NULL); return ::FlattenPath(m_hDC); }
  945. _AFXWIN_INLINE float CDC::GetMiterLimit() const
  946. { ASSERT(m_hDC != NULL); float fMiterLimit;
  947. VERIFY(::GetMiterLimit(m_hDC, &fMiterLimit)); return fMiterLimit; }
  948. _AFXWIN_INLINE int CDC::GetPath(LPPOINT lpPoints, LPBYTE lpTypes, int nCount) const
  949. { ASSERT(m_hDC != NULL); return ::GetPath(m_hDC, lpPoints, lpTypes, nCount); }
  950. _AFXWIN_INLINE BOOL CDC::SetMiterLimit(float fMiterLimit)
  951. { ASSERT(m_hDC != NULL); return ::SetMiterLimit(m_hDC, fMiterLimit, NULL); }
  952. _AFXWIN_INLINE BOOL CDC::StrokeAndFillPath()
  953. { ASSERT(m_hDC != NULL); return ::StrokeAndFillPath(m_hDC); }
  954. _AFXWIN_INLINE BOOL CDC::StrokePath()
  955. { ASSERT(m_hDC != NULL); return ::StrokePath(m_hDC); }
  956. _AFXWIN_INLINE BOOL CDC::WidenPath()
  957. { ASSERT(m_hDC != NULL); return ::WidenPath(m_hDC); }
  958. _AFXWIN_INLINE BOOL CDC::AddMetaFileComment(UINT nDataSize, const BYTE* pCommentData)
  959. { ASSERT(m_hDC != NULL); return ::GdiComment(m_hDC, nDataSize, pCommentData); }
  960. _AFXWIN_INLINE BOOL CDC::PlayMetaFile(HENHMETAFILE hEnhMF, LPCRECT lpBounds)
  961. { ASSERT(m_hDC != NULL); return ::PlayEnhMetaFile(m_hDC, hEnhMF, lpBounds); }
  962. // CMenu
  963. _AFXWIN_INLINE CMenu::CMenu()
  964. { m_hMenu = NULL; }
  965. _AFXWIN_INLINE CMenu::~CMenu()
  966. { DestroyMenu(); }
  967. _AFXWIN_INLINE BOOL CMenu::CreateMenu()
  968. { return Attach(::CreateMenu()); }
  969. _AFXWIN_INLINE BOOL CMenu::CreatePopupMenu()
  970. { return Attach(::CreatePopupMenu()); }
  971. _AFXWIN_INLINE CMenu::operator HMENU() const
  972. { ASSERT(this == NULL || m_hMenu == NULL || ::IsMenu(m_hMenu));
  973. return this == NULL ? NULL : m_hMenu; }
  974. _AFXWIN_INLINE CMenu::operator==(const CMenu& menu) const
  975. { return ((HMENU) menu) == m_hMenu; }
  976. _AFXWIN_INLINE CMenu::operator!=(const CMenu& menu) const
  977. { return ((HMENU) menu) != m_hMenu; }
  978. _AFXWIN_INLINE HMENU CMenu::GetSafeHmenu() const
  979. { ASSERT(this == NULL || m_hMenu == NULL || ::IsMenu(m_hMenu));
  980. return this == NULL ? NULL : m_hMenu; }
  981. _AFXWIN_INLINE BOOL CMenu::DeleteMenu(UINT nPosition, UINT nFlags)
  982. { ASSERT(::IsMenu(m_hMenu)); return ::DeleteMenu(m_hMenu, nPosition, nFlags); }
  983. _AFXWIN_INLINE BOOL CMenu::AppendMenu(UINT nFlags, UINT nIDNewItem, LPCTSTR lpszNewItem)
  984. { ASSERT(::IsMenu(m_hMenu)); return ::AppendMenu(m_hMenu, nFlags, nIDNewItem, lpszNewItem); }
  985. _AFXWIN_INLINE BOOL CMenu::AppendMenu(UINT nFlags, UINT nIDNewItem, const CBitmap* pBmp)
  986. { ASSERT(::IsMenu(m_hMenu)); return ::AppendMenu(m_hMenu, nFlags | MF_BITMAP, nIDNewItem,
  987. (LPCTSTR)pBmp->GetSafeHandle()); }
  988. _AFXWIN_INLINE UINT CMenu::CheckMenuItem(UINT nIDCheckItem, UINT nCheck)
  989. { ASSERT(::IsMenu(m_hMenu)); return (UINT)::CheckMenuItem(m_hMenu, nIDCheckItem, nCheck); }
  990. _AFXWIN_INLINE UINT CMenu::EnableMenuItem(UINT nIDEnableItem, UINT nEnable)
  991. { ASSERT(::IsMenu(m_hMenu)); return ::EnableMenuItem(m_hMenu, nIDEnableItem, nEnable); }
  992. _AFXWIN_INLINE BOOL CMenu::SetDefaultItem(UINT uItem, BOOL fByPos)
  993. { ASSERT(::IsMenu(m_hMenu)); return ::SetMenuDefaultItem(m_hMenu, uItem, fByPos); }
  994. _AFXWIN_INLINE UINT CMenu::GetDefaultItem(UINT gmdiFlags, BOOL fByPos)
  995. { ASSERT(::IsMenu(m_hMenu)); return ::GetMenuDefaultItem(m_hMenu, fByPos, gmdiFlags); }
  996. _AFXWIN_INLINE UINT CMenu::GetMenuItemCount() const
  997. { ASSERT(::IsMenu(m_hMenu)); return ::GetMenuItemCount(m_hMenu); }
  998. _AFXWIN_INLINE UINT CMenu::GetMenuItemID(int nPos) const
  999. { ASSERT(::IsMenu(m_hMenu)); return ::GetMenuItemID(m_hMenu, nPos); }
  1000. _AFXWIN_INLINE UINT CMenu::GetMenuState(UINT nID, UINT nFlags) const
  1001. { ASSERT(::IsMenu(m_hMenu)); return ::GetMenuState(m_hMenu, nID, nFlags); }
  1002. _AFXWIN_INLINE int CMenu::GetMenuString(UINT nIDItem, LPTSTR lpString, int nMaxCount, UINT nFlags) const
  1003. { ASSERT(::IsMenu(m_hMenu)); return ::GetMenuString(m_hMenu, nIDItem, lpString, nMaxCount, nFlags); }
  1004. _AFXWIN_INLINE int CMenu::GetMenuString(UINT nIDItem, CString& rString, UINT nFlags) const
  1005. { ASSERT(::IsMenu(m_hMenu)); int nResult = ::GetMenuString(m_hMenu, nIDItem,
  1006. rString.GetBuffer(256), 256, nFlags); rString.ReleaseBuffer();
  1007. return nResult; }
  1008. _AFXWIN_INLINE BOOL CMenu::GetMenuItemInfo(UINT nIDItem, LPMENUITEMINFO lpMenuItemInfo, BOOL fByPos)
  1009. { ASSERT(::IsMenu(m_hMenu)); ASSERT_POINTER(lpMenuItemInfo, MENUITEMINFO);
  1010. return ::GetMenuItemInfo(m_hMenu, nIDItem, fByPos, lpMenuItemInfo); }
  1011. _AFXWIN_INLINE CMenu* CMenu::GetSubMenu(int nPos) const
  1012. { ASSERT(::IsMenu(m_hMenu)); return CMenu::FromHandle(::GetSubMenu(m_hMenu, nPos)); }
  1013. _AFXWIN_INLINE BOOL CMenu::InsertMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem,
  1014. LPCTSTR lpszNewItem)
  1015. { ASSERT(::IsMenu(m_hMenu)); return ::InsertMenu(m_hMenu, nPosition, nFlags, nIDNewItem, lpszNewItem); }
  1016. _AFXWIN_INLINE BOOL CMenu::InsertMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem, const CBitmap* pBmp)
  1017. { ASSERT(::IsMenu(m_hMenu)); return ::InsertMenu(m_hMenu, nPosition, nFlags | MF_BITMAP, nIDNewItem,
  1018. (LPCTSTR)pBmp->GetSafeHandle()); }
  1019. _AFXWIN_INLINE BOOL CMenu::ModifyMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem, LPCTSTR lpszNewItem)
  1020. { ASSERT(::IsMenu(m_hMenu)); return ::ModifyMenu(m_hMenu, nPosition, nFlags, nIDNewItem, lpszNewItem); }
  1021. _AFXWIN_INLINE BOOL CMenu::ModifyMenu(UINT nPosition, UINT nFlags, UINT nIDNewItem, const CBitmap* pBmp)
  1022. { ASSERT(::IsMenu(m_hMenu)); return ::ModifyMenu(m_hMenu, nPosition, nFlags | MF_BITMAP, nIDNewItem,
  1023. (LPCTSTR)pBmp->GetSafeHandle()); }
  1024. _AFXWIN_INLINE BOOL CMenu::RemoveMenu(UINT nPosition, UINT nFlags)
  1025. { ASSERT(::IsMenu(m_hMenu)); return ::RemoveMenu(m_hMenu, nPosition, nFlags); }
  1026. _AFXWIN_INLINE BOOL CMenu::SetMenuItemBitmaps(UINT nPosition, UINT nFlags,
  1027. const CBitmap* pBmpUnchecked, const CBitmap* pBmpChecked)
  1028. { ASSERT(::IsMenu(m_hMenu)); return ::SetMenuItemBitmaps(m_hMenu, nPosition, nFlags,
  1029. (HBITMAP)pBmpUnchecked->GetSafeHandle(),
  1030. (HBITMAP)pBmpChecked->GetSafeHandle()); }
  1031. _AFXWIN_INLINE BOOL CMenu::LoadMenu(LPCTSTR lpszResourceName)
  1032. { return Attach(::LoadMenu(AfxFindResourceHandle(lpszResourceName,
  1033. RT_MENU), lpszResourceName)); }
  1034. _AFXWIN_INLINE BOOL CMenu::LoadMenu(UINT nIDResource)
  1035. { return Attach(::LoadMenu(AfxFindResourceHandle(
  1036. MAKEINTRESOURCE(nIDResource), RT_MENU), MAKEINTRESOURCE(nIDResource))); }
  1037. _AFXWIN_INLINE BOOL CMenu::LoadMenuIndirect(const void* lpMenuTemplate)
  1038. { return Attach(::LoadMenuIndirect(lpMenuTemplate)); }
  1039. // Win4
  1040. _AFXWIN_INLINE BOOL CMenu::SetMenuContextHelpId(DWORD dwContextHelpId)
  1041. { return ::SetMenuContextHelpId(m_hMenu, dwContextHelpId); }
  1042. _AFXWIN_INLINE DWORD CMenu::GetMenuContextHelpId() const
  1043. { return ::GetMenuContextHelpId(m_hMenu); }
  1044. _AFXWIN_INLINE BOOL CMenu::CheckMenuRadioItem(UINT nIDFirst, UINT nIDLast, UINT nIDItem, UINT nFlags)
  1045. { return ::CheckMenuRadioItem(m_hMenu, nIDFirst, nIDLast, nIDItem, nFlags); }
  1046. // CCmdUI
  1047. _AFXWIN_INLINE void CCmdUI::ContinueRouting()
  1048. { m_bContinueRouting = TRUE; }
  1049. /////////////////////////////////////////////////////////////////////////////
  1050. #endif //_AFXWIN_INLINE