Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

lrgcell.c

Go to the documentation of this file.
00001 /*
00002  * PROJECT:     ReactOS Character Map
00003  * LICENSE:     GPL - See COPYING in the top level directory
00004  * FILE:        base/applications/charmap/lrgcell.c
00005  * PURPOSE:     large cell window implementation
00006  * COPYRIGHT:   Copyright 2007 Ged Murphy <gedmurphy@reactos.org>
00007  *
00008  */
00009 
00010 #include <precomp.h>
00011 
00012 
00013 static
00014 HFONT
00015 SetLrgFont(PMAP infoPtr)
00016 {
00017     LOGFONTW lf;
00018     HFONT hFont = NULL;
00019     HDC hdc;
00020     HWND hCombo;
00021     LPWSTR lpFontName;
00022     INT Len;
00023 
00024     hCombo = GetDlgItem(infoPtr->hParent,
00025                         IDC_FONTCOMBO);
00026 
00027     Len = GetWindowTextLengthW(hCombo);
00028 
00029     if (Len != 0)
00030     {
00031         lpFontName = HeapAlloc(GetProcessHeap(),
00032                                0,
00033                                (Len + 1) * sizeof(WCHAR));
00034 
00035         if (lpFontName)
00036         {
00037             SendMessageW(hCombo,
00038                          WM_GETTEXT,
00039                          31,
00040                          (LPARAM)lpFontName);
00041 
00042             ZeroMemory(&lf,
00043                        sizeof(lf));
00044 
00045             hdc = GetDC(infoPtr->hLrgWnd);
00046             lf.lfHeight = GetDeviceCaps(hdc,
00047                                         LOGPIXELSY) / 2;
00048             ReleaseDC(infoPtr->hLrgWnd,
00049                       hdc);
00050 
00051             lf.lfCharSet =  DEFAULT_CHARSET;
00052             wcscpy(lf.lfFaceName,
00053                    lpFontName);
00054 
00055             hFont = CreateFontIndirectW(&lf);
00056 
00057             HeapFree(GetProcessHeap(),
00058                      0,
00059                      lpFontName);
00060         }
00061     }
00062 
00063     return hFont;
00064 }
00065 
00066 
00067 LRESULT CALLBACK
00068 LrgCellWndProc(HWND hwnd,
00069                UINT uMsg,
00070                WPARAM wParam,
00071                LPARAM lParam)
00072 {
00073     PMAP infoPtr;
00074     LRESULT Ret = 0;
00075     static INT cxClient, cyClient;
00076     static RECT rc;
00077     static HFONT hFont = NULL;
00078 
00079     infoPtr = (PMAP)GetWindowLongPtrW(hwnd,
00080                                      GWLP_USERDATA);
00081 
00082     if (infoPtr == NULL && uMsg != WM_CREATE)
00083     {
00084         goto HandleDefaultMessage;
00085     }
00086 
00087     switch (uMsg)
00088     {
00089         case WM_CREATE:
00090         {
00091             infoPtr = (PMAP)(((LPCREATESTRUCTW)lParam)->lpCreateParams);
00092 
00093             SetWindowLongPtrW(hwnd,
00094                               GWLP_USERDATA,
00095                               (LONG_PTR)infoPtr);
00096 
00097             hFont = SetLrgFont(infoPtr);
00098 
00099             break;
00100         }
00101 
00102         case WM_SIZE:
00103         {
00104             cxClient = LOWORD(lParam);
00105             cyClient = HIWORD(lParam);
00106 
00107             rc.left = 0;
00108             rc.top = 0;
00109             rc.right = cxClient;
00110             rc.bottom = cyClient;
00111 
00112             break;
00113         }
00114 
00115         case WM_PAINT:
00116         {
00117             PAINTSTRUCT ps;
00118             HDC hdc;
00119             HFONT hOldFont;
00120 
00121             hdc = BeginPaint(hwnd,
00122                              &ps);
00123 
00124             Rectangle(hdc,
00125                       0,
00126                       0,
00127                       cxClient,
00128                       cyClient);
00129 
00130             hOldFont = SelectObject(hdc, hFont);
00131 
00132             DrawTextW(hdc,
00133                       &infoPtr->pActiveCell->ch,
00134                       1,
00135                       &rc,
00136                       DT_CENTER | DT_VCENTER | DT_SINGLELINE);
00137 
00138             SelectObject(hdc, hOldFont);
00139 
00140             EndPaint(hwnd,
00141                      &ps);
00142 
00143             break;
00144         }
00145 
00146         case WM_DESTROY:
00147         {
00148             DeleteObject(hFont);
00149 
00150             break;
00151         }
00152 
00153         default:
00154         {
00155 HandleDefaultMessage:
00156             Ret = DefWindowProcW(hwnd,
00157                                  uMsg,
00158                                  wParam,
00159                                  lParam);
00160             break;
00161         }
00162     }
00163 
00164     return Ret;
00165 }

Generated on Thu Feb 9 04:38:59 2012 for ReactOS by doxygen 1.6.3

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.