2 * PROJECT: ReactOS Character Map
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/applications/charmap/charmap.c
5 * PURPOSE: main dialog implementation
6 * COPYRIGHT: Copyright 2007 Ged Murphy <gedmurphy@reactos.org>
16 /* Font-enumeration callback */
20 EnumFontNames(ENUMLOGFONTEXW
*lpelfe
,
21 NEWTEXTMETRICEXW
*lpntme
,
25 HWND hwndCombo
= (HWND
)lParam
;
26 LPWSTR pszName
= lpelfe
->elfLogFont
.lfFaceName
;
28 /* make sure font doesn't already exist in our list */
29 if(SendMessageW(hwndCombo
,
32 (LPARAM
)pszName
) == CB_ERR
)
39 idx
= (INT
)SendMessageW(hwndCombo
,
44 /* record the font's attributes (Fixedwidth and Truetype) */
45 fFixed
= (lpelfe
->elfLogFont
.lfPitchAndFamily
& FIXED_PITCH
) ? TRUE
: FALSE
;
46 fTrueType
= (lpelfe
->elfLogFont
.lfOutPrecision
== OUT_STROKE_PRECIS
) ? TRUE
: FALSE
;
48 /* store this information in the list-item's userdata area */
49 SendMessageW(hwndCombo
,
52 MAKEWPARAM(fFixed
, fTrueType
));
59 /* Initialize the font-list by enumeration all system fonts */
62 FillFontStyleComboList(HWND hwndCombo
)
67 /* FIXME: for fun, draw each font in its own style */
68 HFONT hFont
= GetStockObject(DEFAULT_GUI_FONT
);
69 SendMessageW(hwndCombo
,
74 ZeroMemory(&lf
, sizeof(lf
));
75 lf
.lfCharSet
= DEFAULT_CHARSET
;
77 hdc
= GetDC(hwndCombo
);
79 /* store the list of fonts in the combo */
80 EnumFontFamiliesExW(hdc
,
82 (FONTENUMPROCW
)EnumFontNames
,
89 SendMessageW(hwndCombo
,
98 ChangeMapFont(HWND hDlg
)
105 hCombo
= GetDlgItem(hDlg
, IDC_FONTCOMBO
);
107 Len
= GetWindowTextLengthW(hCombo
);
111 lpFontName
= HeapAlloc(GetProcessHeap(),
113 (Len
+ 1) * sizeof(WCHAR
));
122 hMap
= GetDlgItem(hDlg
, IDC_FONTMAP
);
130 HeapFree(GetProcessHeap(),
139 AddCharToSelection(HWND hText
,
143 INT Len
= GetWindowTextLength(hText
);
147 lpText
= HeapAlloc(GetProcessHeap(),
149 (Len
+ 2) * sizeof(WCHAR
));
153 LPWSTR lpStr
= lpText
;
170 HeapFree(GetProcessHeap(),
198 static HICON hSmIcon
;
199 static HICON hBgIcon
;
200 LPWSTR lpAboutText
= NULL
;
208 hSmIcon
= LoadImageW(hInstance
,
209 MAKEINTRESOURCEW(IDI_ICON
),
222 hBgIcon
= LoadImageW(hInstance
,
223 MAKEINTRESOURCEW(IDI_ICON
),
236 FillFontStyleComboList(GetDlgItem(hDlg
,
240 hSysMenu
= GetSystemMenu(hDlg
,
242 if (hSysMenu
!= NULL
)
244 if (LoadStringW(hInstance
,
249 AppendMenuW(hSysMenu
,
253 AppendMenuW(hSysMenu
,
264 switch(LOWORD(wParam
))
268 switch (HIWORD(wParam
))
271 AddCharToSelection(GetDlgItem(hDlg
, IDC_TEXTBOX
),
280 if (HIWORD(wParam
) == CBN_SELCHANGE
)
290 HWND hMap
= GetDlgItem(hDlg
, IDC_FONTMAP
);
292 ch
= (WCHAR
) SendMessageW(hMap
, FM_GETCHAR
, 0, 0);
296 AddCharToSelection(GetDlgItem(hDlg
, IDC_TEXTBOX
),
305 DestroyIcon(hSmIcon
);
307 DestroyIcon(hBgIcon
);
327 DestroyIcon(hSmIcon
);
329 DestroyIcon(hBgIcon
);
343 wWinMain(HINSTANCE hInst
,
348 INITCOMMONCONTROLSEX iccx
;
353 iccx
.dwSize
= sizeof(INITCOMMONCONTROLSEX
);
354 iccx
.dwICC
= ICC_TAB_CLASSES
;
355 InitCommonControlsEx(&iccx
);
357 if (RegisterMapClasses(hInstance
))
359 Ret
= DialogBoxW(hInstance
,
360 MAKEINTRESOURCEW(IDD_CHARMAP
),
364 UnregisterMapClasses(hInstance
);