ReactOS  0.4.12-dev-18-gf469aca
lrgcell.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Character Map
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: base/applications/charmap/lrgcell.c
5  * PURPOSE: large cell window implementation
6  * COPYRIGHT: Copyright 2007 Ged Murphy <gedmurphy@reactos.org>
7  *
8  */
9 
10 #include "precomp.h"
11 
12 static
13 HFONT
14 SetLrgFont(PMAP infoPtr)
15 {
16  LOGFONTW lf;
17  HFONT hFont = NULL;
18  HDC hdc;
19  HWND hCombo;
20  LPWSTR lpFontName;
21  INT Len;
22 
23  hCombo = GetDlgItem(infoPtr->hParent,
25 
26  Len = GetWindowTextLengthW(hCombo);
27 
28  if (Len != 0)
29  {
30  lpFontName = HeapAlloc(GetProcessHeap(),
31  0,
32  (Len + 1) * sizeof(WCHAR));
33 
34  if (lpFontName)
35  {
36  SendMessageW(hCombo,
37  WM_GETTEXT,
38  Len + 1,
39  (LPARAM)lpFontName);
40 
41  ZeroMemory(&lf,
42  sizeof(lf));
43 
44  hdc = GetDC(infoPtr->hLrgWnd);
45  lf.lfHeight = GetDeviceCaps(hdc,
46  LOGPIXELSY) / 2;
47  ReleaseDC(infoPtr->hLrgWnd,
48  hdc);
49 
52  lpFontName,
53  sizeof(lf.lfFaceName) / sizeof(lf.lfFaceName[0]));
54 
55  hFont = CreateFontIndirectW(&lf);
56 
58  0,
59  lpFontName);
60  }
61  }
62 
63  return hFont;
64 }
65 
66 
69  UINT uMsg,
70  WPARAM wParam,
71  LPARAM lParam)
72 {
73  PMAP infoPtr;
74  LRESULT Ret = 0;
75  static INT cxClient, cyClient;
76  static RECT rc;
77  static HFONT hFont = NULL;
78 
79  infoPtr = (PMAP)GetWindowLongPtrW(hwnd,
81 
82  if (infoPtr == NULL && uMsg != WM_CREATE)
83  {
84  goto HandleDefaultMessage;
85  }
86 
87  switch (uMsg)
88  {
89  case WM_CREATE:
90  {
91  infoPtr = (PMAP)(((LPCREATESTRUCTW)lParam)->lpCreateParams);
92 
93  SetWindowLongPtrW(hwnd,
95  (LONG_PTR)infoPtr);
96 
97  hFont = SetLrgFont(infoPtr);
98 
99  break;
100  }
101 
102  case WM_SIZE:
103  {
104  cxClient = LOWORD(lParam);
105  cyClient = HIWORD(lParam);
106 
107  rc.left = 0;
108  rc.top = 0;
109  rc.right = cxClient;
110  rc.bottom = cyClient;
111 
112  break;
113  }
114 
115  case WM_PAINT:
116  {
117  PAINTSTRUCT ps;
118  HDC hdc;
119  HFONT hOldFont;
120 
121  hdc = BeginPaint(hwnd,
122  &ps);
123 
124  Rectangle(hdc,
125  0,
126  0,
127  cxClient,
128  cyClient);
129 
130  hOldFont = SelectObject(hdc, hFont);
131 
132  DrawTextW(hdc,
133  &infoPtr->pActiveCell->ch,
134  1,
135  &rc,
137 
138  SelectObject(hdc, hOldFont);
139 
140  EndPaint(hwnd,
141  &ps);
142 
143  UpdateStatusBar(infoPtr->pActiveCell->ch);
144  break;
145  }
146 
147  case WM_DESTROY:
148  {
149  DeleteObject(hFont);
150 
151  break;
152  }
153 
154  default:
155  {
156 HandleDefaultMessage:
157  Ret = DefWindowProcW(hwnd,
158  uMsg,
159  wParam,
160  lParam);
161  break;
162  }
163  }
164 
165  return Ret;
166 }
#define HDC
Definition: msvc.h:22
HWND hParent
Definition: precomp.h:41
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HDC WINAPI GetDC(_In_opt_ HWND)
__wchar_t WCHAR
Definition: xmlstorage.h:180
struct _MAP * PMAP
#define WM_GETTEXT
Definition: winuser.h:1600
LONG lfHeight
Definition: dimm.idl:59
BYTE lfCharSet
Definition: dimm.idl:67
#define CALLBACK
Definition: compat.h:27
LONG top
Definition: windef.h:297
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define ZeroMemory
Definition: winbase.h:1635
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define GetWindowLongPtrW
Definition: winuser.h:4698
LONG left
Definition: windef.h:296
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define DEFAULT_CHARSET
Definition: wingdi.h:382
LONG right
Definition: windef.h:298
int32_t INT
Definition: typedefs.h:56
WPARAM wParam
Definition: combotst.c:138
HFONT hFont
Definition: main.c:53
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
Definition: precomp.h:38
UINT_PTR WPARAM
Definition: windef.h:207
PCELL pActiveCell
Definition: precomp.h:46
LONG_PTR LPARAM
Definition: windef.h:208
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define GWLP_USERDATA
Definition: treelist.c:63
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:416
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
#define DT_VCENTER
Definition: winuser.h:543
#define WM_DESTROY
Definition: winuser.h:1591
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_SIZE
Definition: winuser.h:1593
int WINAPI GetWindowTextLengthW(_In_ HWND)
unsigned int UINT
Definition: ndis.h:50
#define Len
Definition: deflate.h:82
#define WM_PAINT
Definition: winuser.h:1602
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
HWND hLrgWnd
Definition: precomp.h:42
WCHAR ch
Definition: precomp.h:35
#define IDC_FONTCOMBO
Definition: resource.h:12
#define DT_SINGLELINE
Definition: winuser.h:540
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
LRESULT CALLBACK LrgCellWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: lrgcell.c:68
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
VOID UpdateStatusBar(WCHAR wch)
Definition: charmap.c:262
#define WM_CREATE
Definition: winuser.h:1590
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
#define HIWORD(l)
Definition: typedefs.h:246
static HFONT SetLrgFont(PMAP infoPtr)
Definition: lrgcell.c:14
LONG bottom
Definition: windef.h:299
#define DT_CENTER
Definition: winuser.h:527
#define LOGPIXELSY
Definition: wingdi.h:717
#define SetWindowLongPtrW
Definition: winuser.h:5215
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define HeapFree(x, y, z)
Definition: compat.h:394
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17