--- q_a/samples/locale/locale.c 2018/08/09 18:29:40 1.1.1.1 +++ q_a/samples/locale/locale.c 2018/08/09 18:30:07 1.1.1.2 @@ -1,3 +1,14 @@ + +/******************************************************************************\ +* This is a part of the Microsoft Source Code Samples. +* Copyright (C) 1993 Microsoft Corporation. +* All rights reserved. +* This source code is only intended as a supplement to +* Microsoft Development Tools and/or WinHelp documentation. +* See these sources for detailed information regarding the +* Microsoft samples programs. +\******************************************************************************/ + /**************************************************************************\ * locale.c -- sample program demonstrating the locale... APIs * @@ -46,7 +57,7 @@ int ret; * input parameters: standard window procedure parameters. * \**************************************************************************/ -LRESULT MainDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK MainDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { int i; TCHAR buffer[MAXTCHAR]; @@ -57,6 +68,42 @@ TCHAR buffer[MAXTCHAR]; switch (message) { /********************************************************************\ + * WM_INITDIALOG + * + * Fill the combobox with the language, sublanguage pairs. + * + \********************************************************************/ + case WM_INITDIALOG: + + /* fill up the combobox with the possible input values to + * GetLocaleInfoW(). The strings are in a lookup table + * in the file locale.h + */ + for (i = 0; i < NLANG; i++) { + + SendDlgItemMessage (hwnd, DID_COMBOBOX, CB_ADDSTRING, 0, + (LPARAM)langstrings[i].String); + } + + /* Attempt to create a unicode font for the listbox with the + * same size as the default system font. This will work well + * if the uclucida.ttf font was installed with the control panel. + * If not, then some of the characters in the strings returned + * by GetLocaleInfoW() will be displayed as the 'missing' font glyph. + */ + { HFONT hfont; + LOGFONT logfont; + + GetObject (GetStockObject(SYSTEM_FONT), sizeof(LOGFONT), &logfont); + logfont.lfCharSet = UNICODE_CHARSET; + wsprintf (logfont.lfFaceName, TEXT("Lucida Sans Unicode")); + hfont = CreateFontIndirect (&logfont); + SendDlgItemMessage (hwnd, DID_LISTBOX, WM_SETFONT, (WPARAM) hfont, 0); + } + return 0; + + + /********************************************************************\ * WM_SYSCOMMAND * * ignore all syscommand messages, except for SC_CLOSE. @@ -70,21 +117,6 @@ TCHAR buffer[MAXTCHAR]; return FALSE; break; - /********************************************************************\ - * WM_INITDIALOG - * - * Fill the combobox with the language, sublanguage pairs. - * - \********************************************************************/ - case WM_INITDIALOG: - for (i = 0; i < NLANG; i++) { - - SendDlgItemMessage (hwnd, DID_COMBOBOX, CB_ADDSTRING, 0, - (LPARAM)langstrings[i].String); - } -// SendDlgItemMessage (hwnd, DID_COMBOBOX, CB_SHOWDROPDOWN, (WPARAM) TRUE, 0); - return NULL; - /********************************************************************\ @@ -104,7 +136,7 @@ TCHAR buffer[MAXTCHAR]; for (i = 0; i < NLOCALEENTRIES; i++) { linfo[0] = 0; - GetLocaleInfoW (MAKELCID (langstrings[iSel].Value), + GetLocaleInfoW (MAKELCID( langstrings[iSel].Value, 0 ), localeentry[i].Value, linfo, MAXTCHAR); wsprintf (buffer, TEXT("%s \t %s"), localeentry[i].String, linfo);