summaryrefslogtreecommitdiff
path: root/alf/alfedit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'alf/alfedit.cpp')
-rw-r--r--alf/alfedit.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/alf/alfedit.cpp b/alf/alfedit.cpp
index 65f14c8..df902e9 100644
--- a/alf/alfedit.cpp
+++ b/alf/alfedit.cpp
@@ -26,7 +26,10 @@ ALF__EditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_P
}
if (!ps->cy) {
- ps->cy = tm.tmHeight + 6; // FIXME! use system metrics
+ ps->cy = tm.tmHeight + 2*app->compatFn->GetSystemMetricsForDpi(
+ SM_CYEDGE, ALF_CentipointsToPixels(GetParent(hwnd), 7200))
+ + 2 /* padding internal to the edit control */
+ + 2 /* external padding to line up with themed button */;
}
}
@@ -35,6 +38,14 @@ ALF__EditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_P
ReleaseDC(hwnd, hDc);
return 0;
+ } else if (uMsg == ALF_WM_APPLYSIZE) {
+ RECT *p = (RECT *)lParam;
+
+ return (LRESULT)DeferWindowPos((HDWP)wParam,
+ hwnd, NULL,
+ p->left, p->top + 1,
+ p->right - p->left, p->bottom - p->top - 2,
+ SWP_NOZORDER|SWP_NOACTIVATE);
}
return app->compatFn->DefSubclassProc(hwnd, uMsg, wParam, lParam);
@@ -56,7 +67,7 @@ ALF_AddEdit(HWND win, WORD id, UINT x, UINT y, const WCHAR *text)
ALFAPP app = ALF_ApplicationFromWindow(win);
app->compatFn->SetWindowSubclass(hwndEdit, ALF__EditSubclassProc, 0, (DWORD_PTR)app);
- SetWindowPos(hwndEdit, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE | SWP_FRAMECHANGED);
+ SetWindowPos(hwndEdit, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_FRAMECHANGED);
ALFAddWidgetParams p;
ZeroMemory(&p, sizeof(p));
@@ -65,9 +76,7 @@ ALF_AddEdit(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] = 75; // TODO: pixel-perfect margin from system metrics
- p.margins[2] = 75;
+ p.flags = ALF_QUERYSIZE | ALF_APPLYSIZE | ALF_MESSAGEFONT;
ALF_AddWidgetEx(win, &p);