From 8a22ec305f8663b85c31dbc26c891f4068532a12 Mon Sep 17 00:00:00 2001 From: Robert Dickenson Date: Wed, 28 Aug 2002 19:01:49 +0000 Subject: [PATCH] Respond to WM_MEASUREITEM with the font height. svn path=/trunk/; revision=3429 --- rosapps/templates/dialog/page1.c | 37 ++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/rosapps/templates/dialog/page1.c b/rosapps/templates/dialog/page1.c index dfb9190dadd..aa0ec2355b4 100644 --- a/rosapps/templates/dialog/page1.c +++ b/rosapps/templates/dialog/page1.c @@ -127,18 +127,44 @@ static void OnDrawItem(HWND hWnd, LPARAM lParam) } } + +void OnSetFont(HWND hWnd, WPARAM wParam, LPARAM lParam) +{ + RECT rc; + WINDOWPOS wp; + + GetWindowRect(hWnd, &rc); + wp.hwnd = hWnd; + wp.cx = rc.right - rc.left; + wp.cy = rc.bottom - rc.top; + wp.flags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER; + SendMessage(hWnd, WM_WINDOWPOSCHANGED, 0, (LPARAM)&wp); +} + +void OnMeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct) +{ + HFONT hFont; + LOGFONT lf; + + hFont = GetStockObject(SYSTEM_FONT); + GetObject(hFont, sizeof(LOGFONT), &lf); + if (lf.lfHeight < 0) + lpMeasureItemStruct->itemHeight = -lf.lfHeight; + else + lpMeasureItemStruct->itemHeight = lf.lfHeight; +} + LRESULT CALLBACK PageWndProc1(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { - LPMEASUREITEMSTRUCT lpmis; - switch (message) { case WM_INITDIALOG: InitListCtrl(hDlg); return TRUE; + case WM_SETFONT: + OnSetFont(hDlg, wParam, lParam); + return TRUE; case WM_MEASUREITEM: - lpmis = (LPMEASUREITEMSTRUCT)lParam; - // Set the height of the list box items. - lpmis->itemHeight = 20; + OnMeasureItem((LPMEASUREITEMSTRUCT)lParam); return TRUE; case WM_DRAWITEM: OnDrawItem(hDlg, lParam); @@ -155,4 +181,3 @@ LRESULT CALLBACK PageWndProc1(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa } //////////////////////////////////////////////////////////////////////////////// -