summaryrefslogtreecommitdiff
path: root/alf/alflabel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'alf/alflabel.cpp')
-rw-r--r--alf/alflabel.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/alf/alflabel.cpp b/alf/alflabel.cpp
index e9ae550..7402ecd 100644
--- a/alf/alflabel.cpp
+++ b/alf/alflabel.cpp
@@ -2,6 +2,17 @@
/* LABEL */
+static
+int ALF__LabelTopPadding(HWND hwnd, ALFAPP app)
+{
+ // some pixels on top to align with the edit control
+ // see also: alfedit.cpp
+ return app->compatFn->GetSystemMetricsForDpi(
+ SM_CYEDGE, ALF_CentipointsToPixels(GetParent(hwnd), 7200))
+ + 1 /* internal padding in edit control */
+ + 1 /* external padding around edit control */;
+}
+
static LRESULT CALLBACK
ALF__LabelSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
{
@@ -41,12 +52,22 @@ ALF__LabelSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_
if (pSize->cx == 0)
pSize->cx = r.right - r.left;
if (pSize->cy == 0)
- pSize->cy = r.bottom - r.top;
+ pSize->cy = r.bottom - r.top + ALF__LabelTopPadding(hwnd, app);
if (font)
SelectFont(hdcLabel, oldFont);
ReleaseDC(hwnd, hdcLabel);
+ } else if (uMsg == ALF_WM_APPLYSIZE) {
+ RECT *p = (RECT *)lParam;
+
+ int topPadding = ALF__LabelTopPadding(hwnd, app);
+
+ return (LRESULT)DeferWindowPos((HDWP)wParam,
+ hwnd, NULL,
+ p->left, p->top + topPadding,
+ p->right - p->left, p->bottom - p->top - topPadding,
+ SWP_NOZORDER|SWP_NOACTIVATE);
}
return app->compatFn->DefSubclassProc(hwnd, uMsg, wParam, lParam);
@@ -74,8 +95,7 @@ ALF_AddLabel(HWND win, WORD id, UINT x, UINT y, const WCHAR *text)
p.y = y;
p.width = 0;
p.height = 0;
- p.flags = ALF_QUERYSIZE | ALF_MESSAGEFONT;
- p.margins[0] = 300; // TODO: pixel perfect margins from system metrics
+ p.flags = ALF_QUERYSIZE | ALF_APPLYSIZE | ALF_MESSAGEFONT;
ALF_AddWidgetEx(win, &p);