|
|
1.1 root 1: /**************************************************************************\
2: * locale.c -- sample program demonstrating the locale... APIs
3: *
4: * In this sample the main window is a dialog box. There is no need to
5: * register a new window class or create a new window. Instead just call
6: * DialogBox() and use the template defined in the .RC file. All of the
7: * interesting code is thus in the window procedure for the dialog box.
8: * In this case, simply respond to the combobox command messsages and fill
9: * the list box with appropriate values.
10: *
11: \**************************************************************************/
12:
13: #define UNICODE
14:
15:
16: #include <windows.h>
17: #include "locale.h"
18:
19:
20: /**************************************************************************\
21: *
22: * function: WinMain()
23: *
24: * input parameters: c.f. generic sample
25: *
26: \**************************************************************************/
27: int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
28: LPSTR lpCmdLine, int nCmdShow)
29: {
30: int ret;
31:
32: UNREFERENCED_PARAMETER( hPrevInstance );
33: UNREFERENCED_PARAMETER( lpCmdLine );
34: UNREFERENCED_PARAMETER( nCmdShow);
35:
36: ret = DialogBox (hInstance, TEXT("localeDlg"), NULL, (DLGPROC)MainDlgProc);
37: return ret;
38: }
39:
40:
41:
42: /**************************************************************************\
43: *
44: * function: MainDlgProc()
45: *
46: * input parameters: standard window procedure parameters.
47: *
48: \**************************************************************************/
49: LRESULT MainDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
50: {
51: int i;
52: TCHAR buffer[MAXTCHAR];
53:
54: UNREFERENCED_PARAMETER(lParam);
55:
56:
57: switch (message) {
58:
59: /********************************************************************\
60: * WM_SYSCOMMAND
61: *
62: * ignore all syscommand messages, except for SC_CLOSE.
63: * on this one, call EndDialog().
64: \********************************************************************/
65: case WM_SYSCOMMAND:
66: if (wParam == SC_CLOSE) {
67: EndDialog (hwnd, TRUE);
68: return TRUE;
69: } else
70: return FALSE;
71: break;
72:
73: /********************************************************************\
74: * WM_INITDIALOG
75: *
76: * Fill the combobox with the language, sublanguage pairs.
77: *
78: \********************************************************************/
79: case WM_INITDIALOG:
80: for (i = 0; i < NLANG; i++) {
81:
82: SendDlgItemMessage (hwnd, DID_COMBOBOX, CB_ADDSTRING, 0,
83: (LPARAM)langstrings[i].String);
84: }
85: // SendDlgItemMessage (hwnd, DID_COMBOBOX, CB_SHOWDROPDOWN, (WPARAM) TRUE, 0);
86: return NULL;
87:
88:
89:
90: /********************************************************************\
91: * WM_COMMAND
92: *
93: * When the different languages are selected, clear the list box,
94: * then fill it up again with the new information.
95: *
96: \********************************************************************/
97: case WM_COMMAND:
98: if ((HIWORD(wParam) == CBN_SELCHANGE) && (LOWORD(wParam) == DID_COMBOBOX)) {
99: int iSel;
100: TCHAR linfo[MAXTCHAR];
101:
102: iSel = SendMessage ((HWND) lParam, CB_GETCURSEL, 0,0);
103: SendDlgItemMessage (hwnd, DID_LISTBOX, LB_RESETCONTENT, 0, 0);
104:
105: for (i = 0; i < NLOCALEENTRIES; i++) {
106: linfo[0] = 0;
107: GetLocaleInfoW (MAKELCID (langstrings[iSel].Value),
108: localeentry[i].Value, linfo, MAXTCHAR);
109:
110: wsprintf (buffer, TEXT("%s \t %s"), localeentry[i].String, linfo);
111:
112: SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LPARAM)buffer);
113: }
114:
115: }
116: break; /* end WM_COMMAND */
117:
118:
119: default: return FALSE;
120: } /* end switch(message) */
121: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.