-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInit_ColorDlg.html
More file actions
105 lines (93 loc) · 4.83 KB
/
Copy pathInit_ColorDlg.html
File metadata and controls
105 lines (93 loc) · 4.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8"/>
<title>dlg_color_superlong.cpp</title>
<link href="../../third-party/google-code-prettify/prettify-CppCoverage.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../../third-party/google-code-prettify/prettify.js"></script>
</head>
<body onload="prettyPrint()">
<h4></h4>
<pre class="prettyprint lang-cpp linenums">
VOID IconAdd(LPARAM lp, PCBUSERDATA pUserData,int *CtrlID, int *StrID, WORD CtrlNum)
<span style = "background-color:#dfd">{
LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lp;</span>
size_t pcch;
HBITMAP hbmIcon;
HBITMAP hbmMask;
BITMAP bitmap;
long CX_BITMAP;
long CY_BITMAP;
//½¾êR{{bNXàe\¦sS LJW.20200815 RM#129440
//WCHAR svColorMode[32] = L"";
<span style = "background-color:#dfd"> WCHAR svColorMode[SMALL_BUFF_SZ] = L"";</span>
TEXTMETRIC tm;
COLORREF clrForeground;
COLORREF clrBackground;
INT x, y, i;
<span style = "background-color:#dfd"> if (lpdis->itemID == -1) // empty item </span>
<span style = "background-color:#fdd"> return ;</span>
<span style = "background-color:#dfd"> HDC hdc = CreateCompatibleDC(lpdis->hDC);
if (hdc == NULL)</span>
<span style = "background-color:#fdd"> return;</span>
<span style = "background-color:#dfd"> if ((WORD)(lpdis->itemID) < (CtrlNum - 1))</span>
{
<span style = "background-color:#dfd"> hbmIcon = LoadBitmap(pUserData->hRes, (LPCTSTR)CtrlID[lpdis->itemID]);</span>
//LoadStringEx(pUserData->hRes, StrID[lpdis->itemID], svColorMode, 32); //½¾êR{{bNXàe\¦sS LJW.20200815 RM#129440
<span style = "background-color:#dfd"> LoadStringEx(pUserData->hRes, StrID[lpdis->itemID], svColorMode, SMALL_BUFF_SZ);</span>
}
<span style = "background-color:#dfd"> else</span>
{
<span style = "background-color:#fdd"> hbmIcon = LoadBitmap(ghInstance, (LPCTSTR)CtrlID[lpdis->itemID]);</span>
//LoadStringEx(pUserData->hRes, StrID[lpdis->itemID], svColorMode, 32);
<span style = "background-color:#fdd"> LoadStringEx(ghInstance, StrID[lpdis->itemID], svColorMode, SMALL_BUFF_SZ);</span>
}
//hbmIcon = LoadBitmap(pUserData->hRes, (LPCTSTR)CtrlID[lpdis->itemID]);
<span style = "background-color:#dfd"> GetObject(hbmIcon, sizeof(BITMAP), &bitmap);
CX_BITMAP = bitmap.bmWidth;
CY_BITMAP = bitmap.bmHeight;
hbmMask = CreateBitmap(CX_BITMAP, CY_BITMAP, 1, 1, NULL);</span>
// The colors depend on whether the item is selected.
<span style = "background-color:#dfd"> if(lpdis->itemState & ODS_DISABLED)</span>
clrForeground = SetTextColor(lpdis->hDC,
GetSysColor(lpdis->itemState & ODS_SELECTED ?
<span style = "background-color:#fdd"> COLOR_HIGHLIGHTTEXT : COLOR_GRAYTEXT));
else</span>
clrForeground = SetTextColor(lpdis->hDC,
GetSysColor(lpdis->itemState & ODS_SELECTED ?
<span style = "background-color:#dfd"> COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT));</span>
clrBackground = SetBkColor(lpdis->hDC,
GetSysColor(lpdis->itemState & ODS_SELECTED ?
<span style = "background-color:#dfd"> COLOR_HIGHLIGHT : COLOR_WINDOW));</span>
// Calculate the vertical and horizontal position.
<span style = "background-color:#dfd"> GetTextMetrics(lpdis->hDC, &tm);</span>
y = (lpdis->rcItem.bottom + lpdis->rcItem.top -
<span style = "background-color:#dfd"> tm.tmHeight) / 2;
x = LOWORD(GetDialogBaseUnits()) / 4;</span>
// Get and display the text for the list item.
<span style = "background-color:#dfd"> pcch = lstrlenW(svColorMode);</span>
ExtTextOut(lpdis->hDC, CX_BITMAP + 2 * x, y,
ETO_CLIPPED | ETO_OPAQUE, &lpdis->rcItem,
<span style = "background-color:#dfd"> svColorMode, pcch, NULL);</span>
// Restore the previous colors.
<span style = "background-color:#dfd"> SetTextColor(lpdis->hDC, clrForeground);
SetBkColor(lpdis->hDC, clrBackground);</span>
// Show the icon.
<span style = "background-color:#dfd"> SelectObject(hdc, hbmMask);</span>
TransparentBlt(lpdis->hDC, x, lpdis->rcItem.top + 1,
<span style = "background-color:#dfd"> CX_BITMAP, CY_BITMAP, hdc, 0, 0, CX_BITMAP, CY_BITMAP, SRCAND);
SelectObject(hdc, hbmIcon);</span>
TransparentBlt(lpdis->hDC, x, lpdis->rcItem.top + 1,
<span style = "background-color:#dfd"> CX_BITMAP, CY_BITMAP, hdc, 0, 0, CX_BITMAP, CY_BITMAP, SRCPAINT);
DeleteDC(hdc);</span>
// If the item has the focus, draw focus rectangle.
<span style = "background-color:#dfd"> if (lpdis->itemState & ODS_FOCUS)</span>
<span style = "background-color:#fdd"> DrawFocusRect(lpdis->hDC, &lpdis->rcItem);</span>
<span style = "background-color:#dfd"> if (hbmIcon)
DeleteObject(hbmIcon);
if (hbmMask)
DeleteObject(hbmMask);</span>
<span style = "background-color:#dfd">}</span>
</pre>
</body>
</html>