|
|
1.1.1.2 ! root 1: ! 2: /******************************************************************************\ ! 3: * This is a part of the Microsoft Source Code Samples. ! 4: * Copyright (C) 1993 Microsoft Corporation. ! 5: * All rights reserved. ! 6: * This source code is only intended as a supplement to ! 7: * Microsoft Development Tools and/or WinHelp documentation. ! 8: * See these sources for detailed information regarding the ! 9: * Microsoft samples programs. ! 10: \******************************************************************************/ ! 11: 1.1 root 12: /**************************************************************************\ 13: * locale.c -- sample program demonstrating the locale... APIs 14: * 15: * In this sample the main window is a dialog box. There is no need to 16: * register a new window class or create a new window. Instead just call 17: * DialogBox() and use the template defined in the .RC file. All of the 18: * interesting code is thus in the window procedure for the dialog box. 19: * In this case, simply respond to the combobox command messsages and fill 20: * the list box with appropriate values. 21: * 22: \**************************************************************************/ 23: 24: #define UNICODE 25: 26: 27: #include <windows.h> 28: #include "locale.h" 29: 30: 31: /**************************************************************************\ 32: * 33: * function: WinMain() 34: * 35: * input parameters: c.f. generic sample 36: * 37: \**************************************************************************/ 38: int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 39: LPSTR lpCmdLine, int nCmdShow) 40: { 41: int ret; 42: 43: UNREFERENCED_PARAMETER( hPrevInstance ); 44: UNREFERENCED_PARAMETER( lpCmdLine ); 45: UNREFERENCED_PARAMETER( nCmdShow); 46: 47: ret = DialogBox (hInstance, TEXT("localeDlg"), NULL, (DLGPROC)MainDlgProc); 48: return ret; 49: } 50: 51: 52: 53: /**************************************************************************\ 54: * 55: * function: MainDlgProc() 56: * 57: * input parameters: standard window procedure parameters. 58: * 59: \**************************************************************************/ 1.1.1.2 ! root 60: LRESULT CALLBACK MainDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 1.1 root 61: { 62: int i; 63: TCHAR buffer[MAXTCHAR]; 64: 65: UNREFERENCED_PARAMETER(lParam); 66: 67: 68: switch (message) { 69: 70: /********************************************************************\ 1.1.1.2 ! root 71: * WM_INITDIALOG ! 72: * ! 73: * Fill the combobox with the language, sublanguage pairs. ! 74: * ! 75: \********************************************************************/ ! 76: case WM_INITDIALOG: ! 77: ! 78: /* fill up the combobox with the possible input values to ! 79: * GetLocaleInfoW(). The strings are in a lookup table ! 80: * in the file locale.h ! 81: */ ! 82: for (i = 0; i < NLANG; i++) { ! 83: ! 84: SendDlgItemMessage (hwnd, DID_COMBOBOX, CB_ADDSTRING, 0, ! 85: (LPARAM)langstrings[i].String); ! 86: } ! 87: ! 88: /* Attempt to create a unicode font for the listbox with the ! 89: * same size as the default system font. This will work well ! 90: * if the uclucida.ttf font was installed with the control panel. ! 91: * If not, then some of the characters in the strings returned ! 92: * by GetLocaleInfoW() will be displayed as the 'missing' font glyph. ! 93: */ ! 94: { HFONT hfont; ! 95: LOGFONT logfont; ! 96: ! 97: GetObject (GetStockObject(SYSTEM_FONT), sizeof(LOGFONT), &logfont); ! 98: logfont.lfCharSet = UNICODE_CHARSET; ! 99: wsprintf (logfont.lfFaceName, TEXT("Lucida Sans Unicode")); ! 100: hfont = CreateFontIndirect (&logfont); ! 101: SendDlgItemMessage (hwnd, DID_LISTBOX, WM_SETFONT, (WPARAM) hfont, 0); ! 102: } ! 103: return 0; ! 104: ! 105: ! 106: /********************************************************************\ 1.1 root 107: * WM_SYSCOMMAND 108: * 109: * ignore all syscommand messages, except for SC_CLOSE. 110: * on this one, call EndDialog(). 111: \********************************************************************/ 112: case WM_SYSCOMMAND: 113: if (wParam == SC_CLOSE) { 114: EndDialog (hwnd, TRUE); 115: return TRUE; 116: } else 117: return FALSE; 118: break; 119: 120: 121: 122: /********************************************************************\ 123: * WM_COMMAND 124: * 125: * When the different languages are selected, clear the list box, 126: * then fill it up again with the new information. 127: * 128: \********************************************************************/ 129: case WM_COMMAND: 130: if ((HIWORD(wParam) == CBN_SELCHANGE) && (LOWORD(wParam) == DID_COMBOBOX)) { 131: int iSel; 132: TCHAR linfo[MAXTCHAR]; 133: 134: iSel = SendMessage ((HWND) lParam, CB_GETCURSEL, 0,0); 135: SendDlgItemMessage (hwnd, DID_LISTBOX, LB_RESETCONTENT, 0, 0); 136: 137: for (i = 0; i < NLOCALEENTRIES; i++) { 138: linfo[0] = 0; 1.1.1.2 ! root 139: GetLocaleInfoW (MAKELCID( langstrings[iSel].Value, 0 ), 1.1 root 140: localeentry[i].Value, linfo, MAXTCHAR); 141: 142: wsprintf (buffer, TEXT("%s \t %s"), localeentry[i].String, linfo); 143: 144: SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LPARAM)buffer); 145: } 146: 147: } 148: break; /* end WM_COMMAND */ 149: 150: 151: default: return FALSE; 152: } /* end switch(message) */ 153: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.