summaryrefslogtreecommitdiff
path: root/alf/alfbutton.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'alf/alfbutton.cpp')
-rw-r--r--alf/alfbutton.cpp34
1 files changed, 14 insertions, 20 deletions
diff --git a/alf/alfbutton.cpp b/alf/alfbutton.cpp
index 67a7236..ddf607d 100644
--- a/alf/alfbutton.cpp
+++ b/alf/alfbutton.cpp
@@ -13,8 +13,8 @@ typedef struct {
BOOL isDefault;
BOOL isHot;
HTHEME hTheme;
- UINT uxStatePrev;
- UINT uxStateCurrent;
+ int uxStatePrev;
+ int uxStateCurrent;
UINT itemStatePrev;
UINT itemStateCurrent;
DWORD uxDefaultAnimationDuration;
@@ -48,7 +48,7 @@ ALF__Button_Text_DrawStateProc(HDC hdc, LPARAM lData, WPARAM wData, int cx, int
}
static void
-ALF__Button_RenderUxtheme(HWND hwnd, ALFButtonPriv *priv, UINT uxstate, UINT itemState, HDC hDC, LPRECT pRcItem)
+ALF__Button_RenderUxtheme(HWND hwnd, ALFButtonPriv *priv, int uxstate, UINT itemState, HDC hDC, LPRECT pRcItem)
{
if (ALF_Compat_IsThemeBackgroundPartiallyTransparent(priv->hTheme, BP_PUSHBUTTON, uxstate)) {
ALF_Compat_DrawThemeParentBackground(hwnd, hDC, pRcItem);
@@ -66,7 +66,7 @@ ALF__Button_RenderUxtheme(HWND hwnd, ALFButtonPriv *priv, UINT uxstate, UINT ite
DrawFocusRect(hDC, &content);
int textlen = GetWindowTextLengthW(hwnd);
- WCHAR *textbuf = ALF_New(WCHAR, textlen + 1);
+ WCHAR *textbuf = ALF_New(WCHAR, (SIZE_T)textlen + 1);
GetWindowTextW(hwnd, textbuf, textlen+1);
UINT style = DT_CENTER;
@@ -93,9 +93,7 @@ ALF__Button_Render95(HWND hwnd, ALFButtonPriv *priv, LPDRAWITEMSTRUCT dis)
{
RECT r = dis->rcItem;
- int textlen = GetWindowTextLength(hwnd);
- TCHAR *textbuf = ALF_New(TCHAR, textlen + 1);
- GetWindowText(hwnd, textbuf, textlen+1);
+ TCHAR *textbuf = ALF_Text(hwnd);
if (priv->isDefault) {
HBRUSH framecolor = GetSysColorBrush(COLOR_WINDOWFRAME);
@@ -179,9 +177,7 @@ ALF__Button_Render3x(HWND hwnd, ALFButtonPriv *priv, LPDRAWITEMSTRUCT dis)
ALF_Compat_DrawThemeParentBackground(hwnd, dis->hDC, &r);
- int textlen = GetWindowTextLength(hwnd);
- TCHAR *textbuf = ALF_New(TCHAR, textlen + 1);
- GetWindowText(hwnd, textbuf, textlen+1);
+ TCHAR *textbuf = ALF_Text(hwnd);
HBRUSH framecolor = GetSysColorBrush(COLOR_WINDOWFRAME);
HBRUSH facecolor = GetSysColorBrush(COLOR_BTNFACE);
@@ -284,25 +280,23 @@ ALF__ButtonSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT
oldFont = SelectFont(hdc, font);
// calc drawtext style
- DWORD style = GetWindowLong(hwnd, GWL_STYLE);
+ LONG style = GetWindowLong(hwnd, GWL_STYLE);
UINT format = DT_LEFT | DT_EXPANDTABS | DT_CALCRECT;
if ((style & BS_MULTILINE) == 0)
format |= DT_SINGLELINE;
RECT r = { 0, 0, 0x7FFFFFFF, 100 };
- int textlen = GetWindowTextLength(hwnd);
- TCHAR *textbuf = ALF_New(TCHAR, textlen + 1);
- GetWindowText(hwnd, textbuf, textlen+1);
+ TCHAR *textbuf = ALF_Text(hwnd);
DrawText(hdc, textbuf, -1, &r, format);
ALF_Free(textbuf);
int xpadding = ALF_Compat_GetSystemMetricsForDpi(SM_CXEDGE,
- ALF_CentipointsToPixels(GetParent(hwnd), 7200)) * 2 + 6;
+ (UINT)ALF_CentipointsToPixels(GetParent(hwnd), 7200)) * 2 + 6;
int ypadding = ALF_Compat_GetSystemMetricsForDpi(SM_CYEDGE,
- ALF_CentipointsToPixels(GetParent(hwnd), 7200)) * 2 + 4;
+ (UINT)ALF_CentipointsToPixels(GetParent(hwnd), 7200)) * 2 + 4;
SIZE *pSize = (SIZE*)(void*)lParam;
if (pSize->cx < r.right - r.left + xpadding) {
@@ -325,7 +319,7 @@ ALF__ButtonSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT
if (!ALF_Compat_BufferedPaintRenderAnimation(hwnd, dis->hDC)) {
if (priv->hTheme) {
// Draw XP style themed button
- UINT stateid = PBS_NORMAL;
+ int stateid = PBS_NORMAL;
if (priv->isDefault && IsChild(GetForegroundWindow(), hwnd))
stateid = priv->uxIsDefaultAnimating ? PBS_DEFAULTED_ANIMATING : PBS_DEFAULTED;
@@ -336,7 +330,7 @@ ALF__ButtonSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT
if (dis->itemState & ODS_DISABLED)
stateid = PBS_DISABLED;
- if (priv->uxStatePrev == (UINT)-1) {
+ if (priv->uxStatePrev == -1) {
// initial draw
priv->uxStateCurrent = stateid;
priv->itemStateCurrent = dis->itemState;
@@ -498,8 +492,8 @@ ALF_AddButton(HWND win, WORD id, int x, int y, const TCHAR *text)
NULL);
ALFButtonPriv *priv = ALF_New(ALFButtonPriv, 1);
- priv->uxStateCurrent = (UINT)-1;
- priv->uxStatePrev = (UINT)-1;
+ priv->uxStateCurrent = -1;
+ priv->uxStatePrev = -1;
ALF_Compat_SetWindowSubclass(hwndButton, ALF__ButtonSubclassProc, 0, (DWORD_PTR)priv);