Respond to WM_MEASUREITEM with the font height.
authorRobert Dickenson <robd@reactos.org>
Wed, 28 Aug 2002 19:01:49 +0000 (19:01 +0000)
committerRobert Dickenson <robd@reactos.org>
Wed, 28 Aug 2002 19:01:49 +0000 (19:01 +0000)
svn path=/trunk/; revision=3429

rosapps/templates/dialog/page1.c

index dfb9190..aa0ec23 100644 (file)
@@ -127,18 +127,44 @@ static void OnDrawItem(HWND hWnd, LPARAM lParam)
     } 
 }
 
-LRESULT CALLBACK PageWndProc1(HWND hDlg, UINT message, WPARAM wParam, 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)
 {
-    LPMEASUREITEMSTRUCT lpmis; 
+    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)
+{
     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
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-