ReactOS 0.4.16-dev-1105-gafe29ee
misc.c File Reference
#include "desk.h"
#include <uxtheme.h>
#include <vsstyle.h>
#include <vssym32.h>
Include dependency graph for misc.c:

Go to the source code of this file.

Functions

static INT LengthOfStrResource (IN HINSTANCE hInst, IN UINT uID)
 
INT AllocAndLoadString (OUT LPTSTR *lpTarget, IN HINSTANCE hInst, IN UINT uID)
 
static void DrawEtchedLine (HTHEME hTheme, HDC hdc, int iPart, int iState, LPRECT pRect, UINT uFlags)
 
UINT ClrBtn_CustomDraw (NMCUSTOMDRAW *pCD, COLORREF Color)
 

Function Documentation

◆ AllocAndLoadString()

INT AllocAndLoadString ( OUT LPTSTR lpTarget,
IN HINSTANCE  hInst,
IN UINT  uID 
)

Definition at line 43 of file misc.c.

46{
47 INT ln;
48
50 uID);
51 if (ln++ > 0)
52 {
53 (*lpTarget) = (LPTSTR)LocalAlloc(LMEM_FIXED,
54 ln * sizeof(TCHAR));
55 if ((*lpTarget) != NULL)
56 {
57 INT Ret;
58 if (!(Ret = LoadString(hInst, uID, *lpTarget, ln)))
59 {
60 LocalFree((HLOCAL)(*lpTarget));
61 }
62 return Ret;
63 }
64 }
65 return 0;
66}
INT LengthOfStrResource(IN HINSTANCE hInst, IN UINT uID)
Definition: misc.c:23
#define NULL
Definition: types.h:112
HINSTANCE hInst
Definition: dxdiag.c:13
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
int32_t INT
Definition: typedefs.h:58
#define LMEM_FIXED
Definition: winbase.h:394
#define LoadString
Definition: winuser.h:5839
char TCHAR
Definition: xmlstorage.h:189
CHAR * LPTSTR
Definition: xmlstorage.h:192

◆ ClrBtn_CustomDraw()

UINT ClrBtn_CustomDraw ( NMCUSTOMDRAW pCD,
COLORREF  Color 
)

Definition at line 83 of file misc.c.

85{
86 enum { MARGIN = 1, SEPLINE = 2 };
87 HTHEME hTheme;
88 HGDIOBJ hOrgPen, hOrgBrush;
89 COLORREF clrOrgPen, clrOrgBrush, clrWidget;
90 INT nPadW, nPadH, nHalf, nArrow;
91 RECT r = pCD->rc;
92 POINT pts[3];
93
94 if (pCD->dwDrawStage == CDDS_PREPAINT)
96 if (pCD->dwDrawStage != CDDS_POSTPAINT)
97 return CDRF_DODEFAULT;
98
99 nPadW = GetSystemMetrics(SM_CXFOCUSBORDER) + MARGIN;
100 nPadH = GetSystemMetrics(SM_CYFOCUSBORDER) + MARGIN;
101
102 hTheme = GetWindowTheme(pCD->hdr.hwndFrom);
103 if (hTheme)
104 {
107 r.left += margins.cxLeftWidth + nPadW;
108 r.top += margins.cyTopHeight + nPadH;
109 r.right -= margins.cxRightWidth + nPadW;
110 r.bottom -= margins.cyBottomHeight + nPadH;
111 }
112 else
113 {
114 enum { FOCUSADJUST = 2 }; /* From comctl32 button.c */
115 InflateRect(&r, -(nPadW + FOCUSADJUST), -(nPadH + FOCUSADJUST));
116 }
117
118 hOrgPen = SelectObject(pCD->hdc, GetStockObject(DC_PEN));
119 hOrgBrush = SelectObject(pCD->hdc, GetStockObject(DC_BRUSH));
120 clrWidget = GetSysColor(COLOR_BTNTEXT);
121 clrOrgPen = SetDCPenColor(pCD->hdc, clrWidget);
122 clrOrgBrush = SetDCBrushColor(pCD->hdc, Color);
123
124 nHalf = (r.bottom - r.top) / 2;
125 Rectangle(pCD->hdc, r.left, r.top, r.right - nHalf - SEPLINE * 3, r.bottom);
126
127 SetDCBrushColor(pCD->hdc, clrWidget);
128 nArrow = ((r.bottom - r.top) / 3) & ~1;
129 pts[0].x = r.right - nHalf + nArrow / 2;
130 pts[0].y = r.top + nHalf - nArrow / 3;
131 pts[1].x = pts[0].x + nArrow;
132 pts[1].y = pts[0].y;
133 pts[2].x = pts[0].x + nArrow / 2;
134 pts[2].y = pts[1].y + nArrow / 2;
135 Polygon(pCD->hdc, pts, _countof(pts));
136
137 r.left = r.right - nHalf - SEPLINE * 3 / 2;
139
140 SetDCBrushColor(pCD->hdc, clrOrgBrush);
141 SetDCPenColor(pCD->hdc, clrOrgPen);
142 SelectObject(pCD->hdc, hOrgBrush);
143 SelectObject(pCD->hdc, hOrgPen);
144 return CDRF_DODEFAULT;
145}
static RECT margins
Definition: print.c:55
static void DrawEtchedLine(HTHEME hTheme, HDC hdc, int iPart, int iState, LPRECT pRect, UINT uFlags)
Definition: misc.c:69
HRESULT WINAPI GetThemeMargins(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, int iPropId, RECT *prc, MARGINS *pMargins)
Definition: property.c:216
HTHEME WINAPI GetWindowTheme(HWND hwnd)
Definition: system.c:866
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
BOOL Polygon(CONST PPOINT UnsafePoints, int Count, int polyFillMode)
Definition: polytest.cpp:730
#define CDRF_DODEFAULT
Definition: commctrl.h:268
#define CDRF_NOTIFYPOSTPAINT
Definition: commctrl.h:274
#define CDDS_PREPAINT
Definition: commctrl.h:280
#define CDDS_POSTPAINT
Definition: commctrl.h:281
#define _countof(array)
Definition: sndvol32.h:70
Definition: misc.c:279
HWND hwndFrom
Definition: winuser.h:3168
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
@ PBS_NORMAL
Definition: vsstyle.h:86
@ BP_PUSHBUTTON
Definition: vsstyle.h:74
#define TMT_CONTENTMARGINS
Definition: vssym32.h:324
COLORREF WINAPI SetDCPenColor(_In_ HDC hdc, _In_ COLORREF crColor)
Definition: dc.c:941
COLORREF WINAPI SetDCBrushColor(_In_ HDC hdc, _In_ COLORREF crColor)
Definition: dc.c:905
DWORD COLORREF
Definition: windef.h:300
HGDIOBJ WINAPI GetStockObject(_In_ int)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
DWORD WINAPI GetSysColor(_In_ int)
#define COLOR_BTNTEXT
Definition: winuser.h:944
#define BF_LEFT
Definition: winuser.h:454
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
int WINAPI GetSystemMetrics(_In_ int)

Referenced by BackgroundPageProc().

◆ DrawEtchedLine()

static void DrawEtchedLine ( HTHEME  hTheme,
HDC  hdc,
int  iPart,
int  iState,
LPRECT  pRect,
UINT  uFlags 
)
static

Definition at line 69 of file misc.c.

75{
76 if (hTheme)
77 DrawThemeEdge(hTheme, hdc, iPart, iState, pRect, EDGE_ETCHED, uFlags, pRect);
78 else
80}
UINT uFlags
Definition: api.c:59
HRESULT WINAPI DrawThemeEdge(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pDestRect, UINT uEdge, UINT uFlags, RECT *pContentRect)
Definition: draw.c:1342
HDC hdc
Definition: main.c:9
#define EDGE_ETCHED
Definition: winuser.h:452
BOOL WINAPI DrawEdge(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)

Referenced by ClrBtn_CustomDraw().

◆ LengthOfStrResource()

static INT LengthOfStrResource ( IN HINSTANCE  hInst,
IN UINT  uID 
)
static

Definition at line 7 of file misc.c.

9{
10 HRSRC hrSrc;
11 HGLOBAL hRes;
12 LPWSTR lpName, lpStr;
13
14 if (hInst == NULL)
15 {
16 return -1;
17 }
18
19 /* There are always blocks of 16 strings */
20 lpName = (LPWSTR)MAKEINTRESOURCE((uID >> 4) + 1);
21
22 /* Find the string table block */
23 if ((hrSrc = FindResourceW(hInst, lpName, (LPWSTR)RT_STRING)) &&
24 (hRes = LoadResource(hInst, hrSrc)) &&
25 (lpStr = LockResource(hRes)))
26 {
27 UINT x;
28
29 /* Find the string we're looking for */
30 uID &= 0xF; /* Position in the block, same as % 16 */
31 for (x = 0; x < uID; x++)
32 {
33 lpStr += (*lpStr) + 1;
34 }
35
36 /* Found the string */
37 return (int)(*lpStr);
38 }
39 return -1;
40}
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
unsigned int UINT
Definition: ndis.h:50
#define MAKEINTRESOURCE(i)
Definition: ntverrsrc.c:25
#define RT_STRING
Definition: pedump.c:368
_In_ LPCSTR lpName
Definition: winbase.h:2820
WCHAR * LPWSTR
Definition: xmlstorage.h:184