Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

651 lines
21 KiB

  1. //---------------------------------------------------------------------------
  2. // BorderFill.cpp - implements the drawing API for bgtype = BorderFill
  3. //---------------------------------------------------------------------------
  4. #include "stdafx.h"
  5. #include "Render.h"
  6. #include "Utils.h"
  7. #include "gradient.h"
  8. #include "tmutils.h"
  9. #include "rgn.h"
  10. #include "BorderFill.h"
  11. #include "CacheList.h"
  12. #include "gradient.h"
  13. #include "drawhelp.h"
  14. //---------------------------------------------------------------------------
  15. HRESULT CBorderFill::PackProperties(CRenderObj *pRender, BOOL fNoDraw, int iPartId, int iStateId)
  16. {
  17. memset(this, 0, sizeof(CBorderFill)); // allowed because we have no vtable
  18. _eBgType = BT_BORDERFILL;
  19. //---- save off partid, stateid for debugging ----
  20. _iSourcePartId = iPartId;
  21. _iSourceStateId = iStateId;
  22. if (fNoDraw)
  23. {
  24. //---- this is used to fake a bgtype=none object ----
  25. _fNoDraw = TRUE;
  26. }
  27. else
  28. {
  29. //---- get border type ----
  30. if (FAILED(pRender->GetEnumValue(iPartId, iStateId, TMT_BORDERTYPE, (int *)&_eBorderType)))
  31. _eBorderType = BT_RECT; // TODO: Make Zero the default when no bordertype is specified.
  32. //---- get border color ----
  33. if (FAILED(pRender->GetColor(iPartId, iStateId, TMT_BORDERCOLOR, &_crBorder)))
  34. _crBorder = RGB(0, 0, 0);
  35. //---- get border size ----
  36. if (FAILED(pRender->GetInt(iPartId, iStateId, TMT_BORDERSIZE, &_iBorderSize)))
  37. _iBorderSize = 1; // TODO: Make Zero the default when no bordersize is specified.
  38. if (_eBorderType == BT_ROUNDRECT)
  39. {
  40. //---- get round rect width ----
  41. if (FAILED(pRender->GetInt(iPartId, iStateId, TMT_ROUNDCORNERWIDTH, &_iRoundCornerWidth)))
  42. _iRoundCornerWidth = 80;
  43. //---- get round rect height ----
  44. if (FAILED(pRender->GetInt(iPartId, iStateId, TMT_ROUNDCORNERHEIGHT, &_iRoundCornerHeight)))
  45. _iRoundCornerHeight = 80;
  46. }
  47. //---- get fill type ----
  48. if (FAILED(pRender->GetEnumValue(iPartId, iStateId, TMT_FILLTYPE, (int *)&_eFillType)))
  49. _eFillType = FT_SOLID;
  50. if (_eFillType == FT_SOLID)
  51. {
  52. //---- get fill color ----
  53. if (FAILED(pRender->GetColor(iPartId, iStateId, TMT_FILLCOLOR, &_crFill)))
  54. _crFill = RGB(255, 255, 255);
  55. }
  56. else if (_eFillType == FT_TILEIMAGE)
  57. {
  58. _iDibOffset = pRender->GetValueIndex(iPartId, iStateId, TMT_DIBDATA);
  59. if (_iDibOffset == -1) // not found
  60. _iDibOffset = 0;
  61. }
  62. else // one of the graident filltypes
  63. {
  64. _iGradientPartCount = 0;
  65. GRADIENTPART gpParts[5]; // max is 5 for now
  66. for (int i=0; i < ARRAYSIZE(gpParts); i++)
  67. {
  68. COLORREF crPart;
  69. if (FAILED(pRender->GetColor(iPartId, iStateId, TMT_GRADIENTCOLOR1+i, &crPart)))
  70. break;
  71. int iPartRatio;
  72. if (FAILED(pRender->GetInt(iPartId, iStateId, TMT_GRADIENTRATIO1+i, &iPartRatio)))
  73. iPartRatio = 0;
  74. _crGradientColors[_iGradientPartCount] = crPart;
  75. _iGradientRatios[_iGradientPartCount] = iPartRatio;
  76. _iGradientPartCount++;
  77. }
  78. }
  79. //---- ContentMargins ----
  80. if (FAILED(pRender->GetMargins(NULL, iPartId, iStateId, TMT_CONTENTMARGINS, NULL,
  81. &_ContentMargins)))
  82. {
  83. _ContentMargins.cxLeftWidth = _iBorderSize;
  84. _ContentMargins.cxRightWidth = _iBorderSize;
  85. _ContentMargins.cyTopHeight = _iBorderSize;
  86. _ContentMargins.cyBottomHeight = _iBorderSize;
  87. }
  88. }
  89. return S_OK;
  90. }
  91. //---------------------------------------------------------------------------
  92. BOOL CBorderFill::KeyProperty(int iPropId)
  93. {
  94. BOOL fKey = FALSE;
  95. switch (iPropId)
  96. {
  97. case TMT_BGTYPE:
  98. case TMT_BORDERSIZE:
  99. case TMT_ROUNDCORNERWIDTH:
  100. case TMT_ROUNDCORNERHEIGHT:
  101. case TMT_GRADIENTRATIO1:
  102. case TMT_GRADIENTRATIO2:
  103. case TMT_GRADIENTRATIO3:
  104. case TMT_GRADIENTRATIO4:
  105. case TMT_GRADIENTRATIO5:
  106. //case TMT_IMAGEFILE: // borrowed from imagefile
  107. case TMT_CONTENTMARGINS:
  108. case TMT_BORDERCOLOR:
  109. case TMT_FILLCOLOR:
  110. case TMT_GRADIENTCOLOR1:
  111. case TMT_GRADIENTCOLOR2:
  112. case TMT_GRADIENTCOLOR3:
  113. case TMT_GRADIENTCOLOR4:
  114. case TMT_GRADIENTCOLOR5:
  115. case TMT_BORDERTYPE:
  116. case TMT_FILLTYPE:
  117. fKey = TRUE;
  118. break;
  119. }
  120. return fKey;
  121. }
  122. //---------------------------------------------------------------------------
  123. void CBorderFill::DumpProperties(CSimpleFile *pFile, BYTE *pbThemeData, BOOL fFullInfo)
  124. {
  125. if (fFullInfo)
  126. pFile->OutLine(L"Dump of CBorderFill at offset=0x%x", (BYTE *)this - pbThemeData);
  127. else
  128. pFile->OutLine(L"Dump of CBorderFill");
  129. pFile->OutLine(L" _eBgType=%d, _fNoDraw=%d", _eBgType, _fNoDraw);
  130. pFile->OutLine(L" _eBorderType=%d, _iBorderSize=%d, _crBorder=0x%08x",
  131. _eBorderType, _iBorderSize, _crBorder);
  132. pFile->OutLine(L" _iRoundCornerWidth=%d, _iRoundCornerHeight=%d",
  133. _iRoundCornerWidth, _iRoundCornerHeight);
  134. if (fFullInfo)
  135. {
  136. pFile->OutLine(L" _eFillType=%d, _iDibOffset=%d, _crFill=0x%08x",
  137. _eFillType, _iDibOffset, _crFill);
  138. }
  139. else
  140. {
  141. pFile->OutLine(L" _eFillType=%d, _crFill=0x%08x",
  142. _eFillType, _crFill);
  143. }
  144. pFile->OutLine(L" _ContentMargins=%d, %d, %d, %d",
  145. _ContentMargins.cxLeftWidth, _ContentMargins.cxRightWidth,
  146. _ContentMargins.cyTopHeight, _ContentMargins.cyBottomHeight);
  147. pFile->OutLine(L" _iGradientPartCount=%d", _iGradientPartCount);
  148. for (int i=0; i < _iGradientPartCount; i++)
  149. {
  150. pFile->OutLine(L" _crGradientColors[%d]=0x%08x, _iGradientRatios[%d]=%d",
  151. i, _iGradientRatios[i], i, _iGradientRatios[i]);
  152. }
  153. }
  154. //---------------------------------------------------------------------------
  155. HRESULT CBorderFill::DrawComplexBackground(CRenderObj *pRender, HDC hdcOrig,
  156. const RECT *pRect, BOOL fGettingRegion, BOOL fBorder, BOOL fContent,
  157. OPTIONAL const RECT *pClipRect)
  158. {
  159. CSaveClipRegion scrOrig;
  160. HRESULT hr = S_OK;
  161. bool fGradient = false;
  162. int iWidth;
  163. int iHeight;
  164. //---- pen & brush should proceed hdc so auto-delete happens in correct order ----
  165. CAutoGDI<HPEN> hPen;
  166. CAutoGDI<HBRUSH> hBrush;
  167. CAutoDC hdc(hdcOrig);
  168. CMemoryDC memoryDC;
  169. //---- draw border first (along with simple fills) ----
  170. BOOL fHavePath = FALSE;
  171. int width = WIDTH(*pRect);
  172. int height = HEIGHT(*pRect);
  173. if (pClipRect) // use GDI clipping for complex cases
  174. {
  175. //---- get previous clipping region (for restoring at end) ----
  176. hr = scrOrig.Save(hdc);
  177. if (FAILED(hr))
  178. goto exit;
  179. //---- add "pClipRect" to the GDI clipping region ----
  180. int iRetVal = IntersectClipRect(hdc, pClipRect->left, pClipRect->top,
  181. pClipRect->right, pClipRect->bottom);
  182. if (iRetVal == ERROR)
  183. {
  184. hr = MakeErrorLast();
  185. goto exit;
  186. }
  187. }
  188. if ((fBorder) && (_iBorderSize))
  189. {
  190. hPen = CreatePen(PS_SOLID | PS_INSIDEFRAME, _iBorderSize, _crBorder);
  191. if (! hPen)
  192. {
  193. hr = MakeErrorLast();
  194. goto exit;
  195. }
  196. }
  197. if (fContent)
  198. {
  199. if (_eFillType == FT_SOLID)
  200. {
  201. hBrush = CreateSolidBrush(_crFill);
  202. if (! hBrush)
  203. {
  204. hr = MakeErrorLast();
  205. goto exit;
  206. }
  207. }
  208. else if (_eFillType == FT_TILEIMAGE)
  209. {
  210. ASSERT(FALSE); // this fill type not supported
  211. }
  212. else
  213. fGradient = true;
  214. }
  215. if (fGettingRegion)
  216. fGradient = false;
  217. if (! hBrush) // no brush wanted
  218. hBrush = (HBRUSH)GetStockObject(NULL_BRUSH);
  219. if (! hPen) // no pen wanted
  220. hPen = (HPEN)GetStockObject(NULL_PEN);
  221. hdc.SelectPen(hPen);
  222. hdc.SelectBrush(hBrush);
  223. if (_eBorderType == BT_RECT)
  224. {
  225. if (_iBorderSize > 0)
  226. {
  227. //---- no need to create a path for region in this case ----
  228. Rectangle(hdc, pRect->left, pRect->top, pRect->right, pRect->bottom);
  229. }
  230. else
  231. {
  232. FillRect(hdc, pRect, hBrush);
  233. }
  234. }
  235. else if (_eBorderType == BT_ROUNDRECT)
  236. {
  237. int iEllipHeight = (_iRoundCornerHeight*height)/100;
  238. int iEllipWidth = (_iRoundCornerWidth*width)/100;
  239. RoundRect(hdc, pRect->left, pRect->top, pRect->right, pRect->bottom,
  240. iEllipHeight, iEllipWidth);
  241. if (fGradient) // create a path of the border
  242. {
  243. BeginPath(hdc);
  244. RoundRect(hdc, pRect->left, pRect->top, pRect->right, pRect->bottom,
  245. iEllipHeight, iEllipWidth);
  246. EndPath(hdc);
  247. fHavePath = TRUE;
  248. }
  249. }
  250. else // if (_eBorderType == BT_ELLIPSE)
  251. {
  252. Ellipse(hdc, pRect->left, pRect->top, pRect->right, pRect->bottom);
  253. if (fGradient) // create a path of the border
  254. {
  255. BeginPath(hdc);
  256. Ellipse(hdc, pRect->left, pRect->top, pRect->right, pRect->bottom);
  257. EndPath(hdc);
  258. fHavePath = TRUE;
  259. }
  260. }
  261. if (! fGradient) // we're done
  262. goto exit;
  263. //---- draw gradient fill within the border drawn above ----
  264. //---- shrink rect to subtract border ----
  265. RECT rect;
  266. SetRect(&rect, pRect->left, pRect->top, pRect->right, pRect->bottom);
  267. rect.left += _iBorderSize;
  268. rect.top += _iBorderSize;
  269. rect.right -= _iBorderSize;
  270. rect.bottom -= _iBorderSize;
  271. iWidth = WIDTH(rect);
  272. iHeight = HEIGHT(rect);
  273. hr = memoryDC.OpenDC(hdc, iWidth, iHeight);
  274. if (FAILED(hr))
  275. goto exit;
  276. //---- paint our bounding rect into dcBitmap with our gradient ----
  277. RECT rect2;
  278. SetRect(&rect2, 0, 0, iWidth, iHeight);
  279. GRADIENTPART gpParts[5]; // max is 5 for now
  280. //---- get gradient colors & ratios ----
  281. for (int i=0; i < _iGradientPartCount; i++)
  282. {
  283. COLORREF crPart = _crGradientColors[i];
  284. gpParts[i].Color.bRed = RED(crPart);
  285. gpParts[i].Color.bGreen = GREEN(crPart);
  286. gpParts[i].Color.bBlue = BLUE(crPart);
  287. gpParts[i].Color.bAlpha = 255;
  288. gpParts[i].Ratio = (BYTE)_iGradientRatios[i];
  289. };
  290. if (_eFillType == FT_RADIALGRADIENT)
  291. {
  292. PaintGradientRadialRect(memoryDC, rect2, _iGradientPartCount, gpParts);
  293. }
  294. else if (_eFillType == FT_VERTGRADIENT)
  295. {
  296. PaintVertGradient(memoryDC, rect2, _iGradientPartCount, gpParts);
  297. }
  298. else // if (_eFillType == FT_HORZGRADIENT)
  299. {
  300. PaintHorzGradient(memoryDC, rect2, _iGradientPartCount, gpParts);
  301. }
  302. if (fHavePath)
  303. {
  304. CSaveClipRegion scrCurrent;
  305. hr = scrCurrent.Save(hdc); // save current clip region
  306. if (FAILED(hr))
  307. goto exit;
  308. //---- select our shape as the clipping region in normal hdc ----
  309. SelectClipPath(hdc, RGN_AND);
  310. //---- blt our gradient into the shape-clipped rect into the normal hdc ----
  311. BitBlt(hdc, rect.left, rect.top, iWidth, iHeight, memoryDC, 0, 0, SRCCOPY);
  312. scrCurrent.Restore(hdc); // restore current clip region
  313. }
  314. else
  315. {
  316. //---- blt our gradient into the shape-clipped rect into the normal hdc ----
  317. BitBlt(hdc, rect.left, rect.top, iWidth, iHeight, memoryDC, 0, 0, SRCCOPY);
  318. }
  319. exit:
  320. scrOrig.Restore(hdc); // restore clipping region
  321. return hr;
  322. }
  323. //---------------------------------------------------------------------------
  324. HRESULT CBorderFill::DrawBackground(CRenderObj *pRender, HDC hdcOrig,
  325. const RECT *pRect, OPTIONAL const DTBGOPTS *pOptions)
  326. {
  327. HRESULT hr = S_OK;
  328. //---- options ----
  329. DWORD dwOptionFlags = 0;
  330. BOOL fBorder = TRUE;
  331. BOOL fContent = TRUE;
  332. BOOL fGettingRegion = FALSE;
  333. const RECT *pClipRect = NULL;
  334. if (pOptions)
  335. {
  336. dwOptionFlags = pOptions->dwFlags;
  337. if (dwOptionFlags & DTBG_CLIPRECT)
  338. pClipRect = &pOptions->rcClip;
  339. if (dwOptionFlags & DTBG_OMITBORDER)
  340. fBorder = FALSE;
  341. if (dwOptionFlags & DTBG_OMITCONTENT)
  342. fContent = FALSE;
  343. if (dwOptionFlags & DTBG_COMPUTINGREGION)
  344. fGettingRegion = TRUE;
  345. }
  346. //---- optimize for perf-sensitive paths thru here ----
  347. if (_fNoDraw)
  348. {
  349. //---- nothing to do ----
  350. }
  351. else if ((_eFillType == FT_SOLID) && (_eBorderType == BT_RECT)) // solid rectangle
  352. {
  353. if (! _iBorderSize) // no border case
  354. {
  355. if (fContent)
  356. {
  357. //---- clip, if needed ----
  358. RECT rcContent = *pRect;
  359. if (pClipRect)
  360. IntersectRect(&rcContent, &rcContent, pClipRect);
  361. //---- fastest solid rect ----
  362. COLORREF crOld = SetBkColor(hdcOrig, _crFill);
  363. ExtTextOut(hdcOrig, 0, 0, ETO_OPAQUE, &rcContent, NULL, 0, NULL);
  364. //---- restore old color ----
  365. SetBkColor(hdcOrig, crOld);
  366. }
  367. }
  368. else // border case
  369. {
  370. COLORREF crOld = GetBkColor(hdcOrig);
  371. //---- draw clipped borders ----
  372. if (fBorder)
  373. {
  374. RECT rcLine;
  375. SetBkColor(hdcOrig, _crBorder);
  376. //---- draw LEFT line ----
  377. SetRect(&rcLine, pRect->left, pRect->top, pRect->left+_iBorderSize,
  378. pRect->bottom);
  379. if (pClipRect)
  380. IntersectRect(&rcLine, &rcLine, pClipRect);
  381. ExtTextOut(hdcOrig, 0, 0, ETO_OPAQUE, &rcLine, NULL, 0, NULL);
  382. //---- draw RIGHT line ----
  383. SetRect(&rcLine, pRect->right-_iBorderSize, pRect->top, pRect->right,
  384. pRect->bottom);
  385. if (pClipRect)
  386. IntersectRect(&rcLine, &rcLine, pClipRect);
  387. ExtTextOut(hdcOrig, 0, 0, ETO_OPAQUE, &rcLine, NULL, 0, NULL);
  388. //---- draw TOP line ----
  389. SetRect(&rcLine, pRect->left, pRect->top, pRect->right,
  390. pRect->top+_iBorderSize);
  391. if (pClipRect)
  392. IntersectRect(&rcLine, &rcLine, pClipRect);
  393. ExtTextOut(hdcOrig, 0, 0, ETO_OPAQUE, &rcLine, NULL, 0, NULL);
  394. //---- draw BOTTOM line ----
  395. SetRect(&rcLine, pRect->left, pRect->bottom-_iBorderSize, pRect->right,
  396. pRect->bottom);
  397. if (pClipRect)
  398. IntersectRect(&rcLine, &rcLine, pClipRect);
  399. ExtTextOut(hdcOrig, 0, 0, ETO_OPAQUE, &rcLine, NULL, 0, NULL);
  400. }
  401. //---- remove borders from rect to draw content ----
  402. if (fContent)
  403. {
  404. RECT rcContent = *pRect;
  405. rcContent.left += _iBorderSize;
  406. rcContent.right -= _iBorderSize;
  407. rcContent.top += _iBorderSize;
  408. rcContent.bottom -= _iBorderSize;
  409. if (pClipRect)
  410. IntersectRect(&rcContent, &rcContent, pClipRect);
  411. //---- fastest solid rect ----
  412. SetBkColor(hdcOrig, _crFill);
  413. ExtTextOut(hdcOrig, 0, 0, ETO_OPAQUE, &rcContent, NULL, 0, NULL);
  414. }
  415. //---- restore old color ----
  416. SetBkColor(hdcOrig, crOld);
  417. }
  418. }
  419. else // all other cases
  420. {
  421. hr = DrawComplexBackground(pRender, hdcOrig, pRect, fGettingRegion,
  422. fBorder, fContent, pClipRect);
  423. }
  424. return hr;
  425. }
  426. //---------------------------------------------------------------------------
  427. HRESULT CBorderFill::GetBackgroundRegion(CRenderObj *pRender, OPTIONAL HDC hdc,
  428. const RECT *pRect, HRGN *pRegion)
  429. {
  430. HRESULT hr;
  431. //---- see if it even has a transparent part ----
  432. if (! IsBackgroundPartiallyTransparent())
  433. {
  434. //---- return the bounding rect as the region ----
  435. HRGN hrgn = CreateRectRgn(pRect->left, pRect->top,
  436. pRect->right, pRect->bottom);
  437. if (! hrgn)
  438. return MakeErrorLast();
  439. *pRegion = hrgn;
  440. return S_OK;
  441. }
  442. //---- create a memory dc/bitmap to draw info ----
  443. CMemoryDC hdcMemory;
  444. //---- use maximum drawing values as size of DC ----
  445. hr = hdcMemory.OpenDC(NULL, RECTWIDTH(pRect), RECTHEIGHT(pRect));
  446. if (FAILED(hr))
  447. return hr;
  448. BOOL fOK = BeginPath(hdcMemory);
  449. if (! fOK)
  450. return MakeErrorLast();
  451. DTBGOPTS Opts = {sizeof(Opts), DTBG_COMPUTINGREGION};
  452. hr = DrawBackground(pRender, hdcMemory, pRect, &Opts);
  453. if (FAILED(hr))
  454. return hr;
  455. fOK = EndPath(hdcMemory);
  456. if (! fOK)
  457. return MakeErrorLast();
  458. HRGN hrgn = PathToRegion(hdcMemory);
  459. if (! hrgn)
  460. return MakeErrorLast();
  461. *pRegion = hrgn;
  462. return S_OK;
  463. }
  464. //---------------------------------------------------------------------------
  465. BOOL CBorderFill::IsBackgroundPartiallyTransparent()
  466. {
  467. return ((_eBorderType != BT_RECT) || _fNoDraw);
  468. }
  469. //---------------------------------------------------------------------------
  470. HRESULT CBorderFill::HitTestBackground(CRenderObj *pRender, OPTIONAL HDC hdc,
  471. DWORD dwHTFlags, const RECT *pRect, HRGN hrgn, POINT ptTest, OUT WORD *pwHitCode)
  472. {
  473. MARGINS margins;
  474. GetContentMargins(pRender, hdc, &margins);
  475. *pwHitCode = HitTestRect( dwHTFlags, pRect, margins, ptTest );
  476. return S_OK;
  477. }
  478. //---------------------------------------------------------------------------
  479. void CBorderFill::GetContentMargins(CRenderObj *pRender, OPTIONAL HDC hdc, MARGINS *pMargins)
  480. {
  481. *pMargins = _ContentMargins;
  482. //---- adjust for DPI scaling ----
  483. #if 0
  484. int iDcDpi;
  485. if (DpiDiff(hdc, &iDcDpi)))
  486. {
  487. pMargins->cxLeftWidth = DpiScale(pMargins->cxLeftWidth, iDcDpi);
  488. pMargins->cxRightWidth = DpiScale(pMargins->cxRightWidth, iDcDpi);
  489. pMargins->cyTopHeight = DpiScale(pMargins->cyTopHeight, iDcDpi);
  490. pMargins->cyBottomHeight = DpiScale(pMargins->cyBottomHeight, iDcDpi);
  491. }
  492. #endif
  493. }
  494. //---------------------------------------------------------------------------
  495. HRESULT CBorderFill::GetBackgroundContentRect(CRenderObj *pRender, OPTIONAL HDC hdc,
  496. const RECT *pBoundingRect, RECT *pContentRect)
  497. {
  498. MARGINS margins;
  499. GetContentMargins(pRender, hdc, &margins);
  500. pContentRect->left = pBoundingRect->left + margins.cxLeftWidth;
  501. pContentRect->top = pBoundingRect->top + margins.cyTopHeight;
  502. pContentRect->right = pBoundingRect->right - margins.cxRightWidth;
  503. pContentRect->bottom = pBoundingRect->bottom - margins.cyBottomHeight;
  504. return S_OK;
  505. }
  506. //---------------------------------------------------------------------------
  507. HRESULT CBorderFill::GetBackgroundExtent(CRenderObj *pRender, OPTIONAL HDC hdc,
  508. const RECT *pContentRect, RECT *pExtentRect)
  509. {
  510. MARGINS margins;
  511. GetContentMargins(pRender, hdc, &margins);
  512. pExtentRect->left = pContentRect->left - margins.cxLeftWidth;
  513. pExtentRect->top = pContentRect->top-+ margins.cyTopHeight;
  514. pExtentRect->right = pContentRect->right + margins.cxRightWidth;
  515. pExtentRect->bottom = pContentRect->bottom + margins.cyBottomHeight;
  516. return S_OK;
  517. }
  518. //---------------------------------------------------------------------------
  519. HRESULT CBorderFill::GetPartSize(HDC hdc, THEMESIZE eSize, SIZE *psz)
  520. {
  521. HRESULT hr = S_OK;
  522. if (eSize == TS_MIN)
  523. {
  524. psz->cx = max(1, _iBorderSize*2);
  525. psz->cy = max(1, _iBorderSize*2);
  526. }
  527. else if (eSize == TS_TRUE)
  528. {
  529. psz->cx = _iBorderSize*2 + 1;
  530. psz->cy = _iBorderSize*2 + 1;
  531. }
  532. else
  533. {
  534. hr = MakeError32(E_INVALIDARG);
  535. }
  536. return hr;
  537. }
  538. //---------------------------------------------------------------------------