home *** CD-ROM | disk | FTP | other *** search
- /*
- * Function support segment for INTERNAT
- *
- * William S. Hall
- * 3665 Benton Street, #66
- * Santa Clara, CA 95051
- *
- */
-
- #define NOKANJI
- #define NOCOMM
- #define NOSOUND
- #include <windows.h>
- #include <stdlib.h>
- #include <search.h>
- #include <ctype.h>
- #include <string.h>
- #include <stdio.h>
- #include "interfns.h"
- #include "intermnu.h"
- #include "intdgdef.h"
- #include "internat.h"
- #include "interdlg.h"
- #include "winutils.h"
- #include "interstr.h"
-
- /* local functions */
- BOOL FAR PASCAL AboutDlg(HWND hDlg, unsigned message, WORD wParam, LONG lParam);
- BOOL FAR PASCAL CompareDlgFunc(HWND hDlg, unsigned message, WORD wParam,
- LONG lParam);
- BOOL FAR PASCAL IntlDlg(HWND hDlg, unsigned message, WORD wParam, LONG lParam);
- static void NEAR DoCompare(HWND hDlg, BOOL cmptype);
- static void NEAR SetOEMCharSet(HWND hWnd, WORD id);
- static void NEAR ResetDisplay(void);
- static void NEAR DoAnsiCase(HWND hWnd, WORD id,
- WORD (FAR PASCAL *fp)(LPSTR, WORD));
- static void NEAR DoCCase(HWND hWnd, WORD id, int (*fp)(int));
- static WORD NEAR GetCheckedItem(HMENU hSub);
- static void NEAR IsAnsiType(HWND hWnd, WORD id, BOOL (FAR PASCAL *fp)(char));
- static void NEAR AnsiOem(HWND hWnd, WORD id, BOOL cset,
- int (FAR PASCAL *fp)(LPSTR, LPSTR, int));
- static void NEAR IsCType(HWND hWnd, WORD id, BOOL (*fp)(int));
- static void NEAR LSort(HWND hWnd, WORD id, int (*fp)());
- static void NEAR ShowKBCodePage(HWND hWnd);
- static int lcompare(BYTE *c1, BYTE *c2);
- static int lcomparei(BYTE *c1, BYTE *c2);
- static int compare(BYTE *c1, BYTE *c2);
- static int comparei(BYTE *c1, BYTE *c2);
- static void NEAR ShowKBType(HWND hWnd);
- BOOL FAR PASCAL OEMConvertDlg(HWND hDlg,unsigned message,WORD wParam,
- LONG lParam);
- static void NEAR SetOEMConvertStyle(HWND hDlg, WORD id, BOOL flag);
- static void NEAR IntlDlgInit(HWND hDlg);
- static void NEAR GetLanguageString(BYTE *buf);
- static void NEAR ShowKBLanguage(HWND hWnd);
- BOOL FAR PASCAL ListSortDlg(HWND hDlg, unsigned message, WORD wParam,
- LONG lParam);
- static void NEAR ListSortInit(HWND hDlg);
- static void NEAR ListOpen(HWND hDlg);
- static void NEAR SwitchLanguage(HWND hWnd);
-
- #define BUFLEN 128 /* comparison string buf length */
- #define MAXTOGGLEMENUS 3 /* first three menus contain toggled items */
- #define MAXPATHLEN 144
- #define MAXFILENAMELEN 12
- #define NAMELEN 128
-
- /* display contents of WM_KEYUP, WM_KEYDOWN, WM_CHAR, and WM_DEADCHAR msgs */
- void FAR DoKeyStuff(HWND hWnd, unsigned message, WORD wParam, LONG lParam)
- {
- RECT rect;
- BYTE buf[40];
- BYTE fmt[40];
- WORD loword;
- BYTE lobyte, hibyte;
-
- GetClientRect(hWnd, &rect);
- rect.left = kwidth;
- loword = LOWORD(lParam);
- lobyte = LOBYTE(HIWORD(lParam));
- hibyte = HIBYTE(HIWORD(lParam));
-
- switch(message) {
- case WM_KEYDOWN:
- GetKeyNameText(lParam, buf, sizeof(buf));
- memset(kbubuf, 0, sizeof(kbubuf));
- memset(kbbuf, 0, sizeof(kbbuf));
- LoadString(hRC, IDS_KEYDOWN, fmt, sizeof(fmt));
- rect.top = cheight;
- rect.bottom = rect.top + 4 * cheight;
- wsprintf(kbdbuf, fmt, wParam, loword, lobyte,
- hibyte, (LPSTR)buf);
- break;
- case WM_KEYUP:
- GetKeyNameText(lParam, buf, sizeof(buf));
- LoadString(hRC, IDS_KEYUP, fmt, sizeof(fmt));
- rect.top = 2 * cheight;
- rect.bottom = rect.top + cheight;
- wsprintf(kbubuf, fmt,
- wParam, loword, lobyte, hibyte, (LPSTR)buf);
- break;
- case WM_CHAR:
- GetKeyNameText(lParam, buf, sizeof(buf));
- LoadString(hRC, IDS_KEYCHAR, fmt, sizeof(fmt));
- rect.top = 3 * cheight;
- rect.bottom = rect.top + cheight;
- wsprintf(kbbuf, fmt,
- wParam, loword, lobyte, hibyte, (LPSTR)buf);
- break;
- case WM_DEADCHAR:
- GetKeyNameText(lParam, buf, sizeof(buf));
- LoadString(hRC, IDS_KEYMUTE, fmt, sizeof(fmt));
- rect.top = 3 * cheight;
- rect.bottom = rect.top + cheight;
- wsprintf(kbbuf, fmt,
- wParam, loword, lobyte, hibyte, (LPSTR)buf);
- break;
- }
- InvalidateRect(hWnd, &rect, TRUE);
- }
-
- /* menu command processor */
- void FAR WndCommand(HWND hWnd, WORD wParam)
- {
- switch(wParam) {
- case IDM_ABOUT:
- OpenDlgBox(hWnd, AboutDlg, DT_ABOUT, hRC);
- break;
- case IDM_OEMCHARSET:
- SetOEMCharSet(hWnd, wParam);
- break;
- case IDM_ANSIUPPER:
- DoAnsiCase(hWnd, wParam, AnsiUpperBuff);
- break;
- case IDM_ANSILOWER:
- DoAnsiCase(hWnd, wParam, AnsiLowerBuff);
- break;
- case IDM_ISCHARALPHA:
- IsAnsiType(hWnd, wParam, IsCharAlpha);
- break;
- case IDM_ISCHARALPHANUM:
- IsAnsiType(hWnd, wParam, IsCharAlphaNumeric);
- break;
- case IDM_ISCHARUPPER:
- IsAnsiType(hWnd, wParam, IsCharUpper);
- break;
- case IDM_ISCHARLOWER:
- IsAnsiType(hWnd, wParam, IsCharLower);
- break;
- case IDM_TOUPPER:
- DoCCase(hWnd, wParam, toupper);
- break;
- case IDM_TOLOWER:
- DoCCase(hWnd, wParam, tolower);
- break;
- case IDM_ISALPHA:
- IsCType(hWnd, wParam, isalpha);
- break;
- case IDM_ISALNUM:
- IsCType(hWnd, wParam, isalnum);
- break;
- case IDM_ISUPPER:
- IsCType(hWnd, wParam, isupper);
- break;
- case IDM_ISLOWER:
- IsCType(hWnd, wParam, islower);
- break;
- case IDM_LSTRCMP:
- LSort(hWnd, wParam, lcompare);
- break;
- case IDM_LSTRCMPI:
- LSort(hWnd, wParam, lcomparei);
- break;
- case IDM_STRCMP:
- LSort(hWnd, wParam, compare);
- break;
- case IDM_STRCMPI:
- LSort(hWnd, wParam, comparei);
- break;
- case IDM_ANSITOOEM:
- AnsiOem(hWnd, wParam, TRUE, AnsiToOemBuff);
- break;
- case IDM_OEMTOANSI:
- AnsiOem(hWnd, wParam, FALSE, OemToAnsiBuff);
- break;
- case IDM_LSTRCMPTEST:
- OpenDlgBoxParam(hWnd, CompareDlgFunc, DT_COMPARE, hRC, (LONG)TRUE);
- break;
- case IDM_STRCMPTEST:
- OpenDlgBoxParam(hWnd, CompareDlgFunc, DT_COMPARE, hRC, (LONG)FALSE);
- break;
- case IDM_KBCODEPAGE:
- ShowKBCodePage(hWnd);
- break;
- case IDM_KBLAYOUT:
- ShowKBLanguage(hWnd);
- break;
- case IDM_KBTYPE:
- ShowKBType(hWnd);
- break;
- case IDM_ESOEMCONVERT:
- OpenDlgBox(hWnd, OEMConvertDlg, DT_OEMCONVERT, hRC);
- break;
- case IDM_INTL:
- OpenDlgBox(hWnd, IntlDlg, DT_INTL, hRC);
- break;
- case IDM_LISTSORT:
- OpenDlgBox(hWnd, ListSortDlg, DT_LISTSORT, hRC);
- break;
- case IDM_LANGUAGE:
- SwitchLanguage(hWnd);
- break;
- }
- }
-
- /* Change language. This routine is a bit cavalier if the menu does not load */
- static void NEAR SwitchLanguage(HWND hWnd)
- {
- register int result;
- BOOL change = FALSE;
- BYTE buf[80];
-
- result = OpenDlgBox(hWnd, LangDlgFunc, DT_LANGUAGE, hRC);
-
- switch (result) {
- case IDS_PIGLATIN:
- if (hRC == hInst) {
- LoadString(hInst, IDS_PGLLIBNAME, buf, sizeof(buf));
- hRC = LoadLibrary(buf);
- if (hRC >= 32)
- change = TRUE;
- }
- break;
- case IDS_ENGLISH:
- if (hRC != hInst) {
- if (hRC)
- FreeLibrary(hRC);
- hRC = hInst;
- change = TRUE;
- }
- break;
- }
- if (change) {
- char szTitle[50];
- HMENU hMenu, hOldMenu;
- /* redraw title */
- LoadString(hRC, IDS_TITLE,szTitle,sizeof(szTitle));
- SetWindowText(hWnd, szTitle);
- /* load the menu */
- hOldMenu = GetMenu(hWnd);
- hMenu = LoadMenu(hRC, szAppName);
- SetMenu(hWnd, hMenu);
- DestroyMenu(hOldMenu);
- /* restore the display to startup */
- ResetDisplay();
- InvalidateRect(hWnd, NULL, TRUE);
- }
- }
-
- /* read the keyboard type */
- static void NEAR ShowKBType(HWND hWnd)
- {
-
- char fmt[255];
- char buf[255];
-
- LoadString(hRC, IDS_KBTYPE, fmt, sizeof(fmt));
- wsprintf(buf,fmt,GetKeyboardType(0),GetKeyboardType(1),GetKeyboardType(2));
-
- MessageBox(hWnd, buf, szAppName, MB_OK | MB_ICONINFORMATION);
- }
-
- /* show the code page Windows THINKS it has */
- static void NEAR ShowKBCodePage(HWND hWnd)
- {
- char buf[80];
- char fmt[80];
- int cp;
-
- cp = GetKBCodePage();
-
- LoadString(hRC, IDS_KBCODEPAGE, fmt, sizeof(fmt));
- wsprintf(buf, fmt, cp);
-
- MessageBox(hWnd, buf, szAppName, MB_OK | MB_ICONINFORMATION);
- }
-
- /* sort the backing store, but only from the space char only */
- static void NEAR LSort(HWND hWnd, WORD id, int (*fp)())
- {
- HMENU hMenu;
- WORD item;
- HCURSOR hCursor;
-
- hMenu = GetMenu(hWnd);
- item = GetCheckedItem(hMenu);
- CheckMenuItem(hMenu, item, MF_UNCHECKED);
-
- if (item == id)
- ResetDisplay();
- else {
- SetCapture(hWnd);
- hCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
- ResetDisplay();
- qsort(display + 32, sizeof(display) - 32, sizeof(char), fp);
- CheckMenuItem(hMenu, id, MF_CHECKED);
- SetCursor(hCursor);
- ReleaseCapture();
- }
- InvalidateRect(hWnd, NULL, TRUE);
- }
-
- /* do a lstrcmp compare */
- static int lcompare(BYTE *c1, BYTE *c2)
- {
- static BYTE buf1[2];
- static BYTE buf2[2];
-
- buf1[0] = *c1;
- buf2[0] = *c2;
-
- return lstrcmp(buf1, buf2);
- }
-
- /* do a lstrcmpi compare */
- static int lcomparei(BYTE *c1, BYTE *c2)
- {
-
- static BYTE buf1[2];
- static BYTE buf2[2];
-
- buf1[0] = *c1;
- buf2[0] = *c2;
-
- return lstrcmpi(buf1, buf2);
-
- }
-
- /* do a strcmp compare */
- static int compare(BYTE *c1, BYTE *c2)
- {
- static BYTE buf1[2];
- static BYTE buf2[2];
-
- buf1[0] = *c1;
- buf2[0] = *c2;
-
- return strcmp(buf1, buf2);
- }
-
- /* do a strcmpi compare */
- static int comparei(BYTE *c1, BYTE *c2)
- {
-
- static BYTE buf1[2];
- static BYTE buf2[2];
-
- buf1[0] = *c1;
- buf2[0] = *c2;
-
- return strcmpi(buf1, buf2);
-
- }
-
- /* set screen to show the OEM character set */
- static void NEAR SetOEMCharSet(HWND hWnd, WORD id)
- {
- HMENU hMenu;
- WORD item;
-
- hMenu = GetMenu(hWnd);
- item = GetCheckedItem(hMenu);
- CheckMenuItem(hMenu, item, MF_UNCHECKED);
-
- if (item == id)
- OEMCharSet = FALSE;
- else {
- ResetDisplay();
- OEMCharSet = TRUE;
- CheckMenuItem(hMenu, id, MF_CHECKED);
- }
- InvalidateRect(hWnd, NULL, TRUE);
- }
-
- /* do one of the many conversions from ANSI to OEM or back */
- static void NEAR AnsiOem(HWND hWnd, WORD id,
- BOOL cset, int (FAR PASCAL *fp)(LPSTR,LPSTR,int))
- {
-
- HMENU hMenu;
- WORD item;
-
- hMenu = GetMenu(hWnd);
- item = GetCheckedItem(hMenu);
- CheckMenuItem(hMenu, item, MF_UNCHECKED);
-
- if (item == id)
- ResetDisplay();
- else {
- ResetDisplay();
- if (cset)
- OEMCharSet = TRUE;
- (*fp)(display, display, sizeof(display));
- CheckMenuItem(hMenu, id, MF_CHECKED);
- }
- InvalidateRect(hWnd, NULL, TRUE);
- }
-
- /* map to upper or lower case using Windows functions */
- static void NEAR DoAnsiCase(HWND hWnd, WORD id,
- WORD (FAR PASCAL *fp)(LPSTR, WORD))
- {
-
- HMENU hMenu;
- WORD item;
-
- hMenu = GetMenu(hWnd);
- item = GetCheckedItem(hMenu);
- CheckMenuItem(hMenu, item, MF_UNCHECKED);
-
- if (item == id)
- ResetDisplay();
- else {
- ResetDisplay();
- (*fp)(display, sizeof(display));
- CheckMenuItem(hMenu, id, MF_CHECKED);
- }
- InvalidateRect(hWnd, NULL, TRUE);
- }
-
- /* map to upper or lower case using C functions */
- static void NEAR DoCCase(HWND hWnd, WORD id, int (*fp)(int))
- {
-
- HMENU hMenu;
- WORD item;
- register int i;
-
- hMenu = GetMenu(hWnd);
- item = GetCheckedItem(hMenu);
- CheckMenuItem(hMenu, item, MF_UNCHECKED);
-
- if (item == id)
- ResetDisplay();
- else {
- for (i = 0; i < sizeof(display); i++)
- display[i] = (BYTE)(*fp)(i);
- CheckMenuItem(hMenu, id, MF_CHECKED);
- }
- InvalidateRect(hWnd, NULL, TRUE);
- }
-
- /* determine ANSI type for character */
- static void NEAR IsAnsiType(HWND hWnd, WORD id, BOOL (FAR PASCAL *fp)(char))
- {
-
- HMENU hMenu;
- WORD item;
- register int i;
-
- hMenu = GetMenu(hWnd);
- item = GetCheckedItem(hMenu);
- CheckMenuItem(hMenu, item, MF_UNCHECKED);
-
- if (item == id)
- ResetDisplay();
- else {
- for (i = 0; i < sizeof(display); i++) {
- if ((*fp)((char)i))
- display[i] = (BYTE)i;
- else
- display[i] = '_';
- }
- CheckMenuItem(hMenu, id, MF_CHECKED);
- }
- InvalidateRect(hWnd, NULL, TRUE);
- }
-
- /* determine C type for character */
- static void NEAR IsCType(HWND hWnd, WORD id, BOOL (*fp)(int))
- {
-
- HMENU hMenu;
- WORD item;
- register int i;
-
- hMenu = GetMenu(hWnd);
- item = GetCheckedItem(hMenu);
- CheckMenuItem(hMenu, item, MF_UNCHECKED);
-
- if (item == id)
- ResetDisplay();
- else {
- for (i = 0; i < sizeof(display); i++) {
- if ((*fp)(i))
- display[i] = (BYTE)i;
- else
- display[i] = '_';
- }
- CheckMenuItem(hMenu, id, MF_CHECKED);
- }
- InvalidateRect(hWnd, NULL, TRUE);
- }
-
- /* look at a menu and find out which one is checked */
- static WORD NEAR GetCheckedItem(HMENU hMenu)
- {
- register WORD i, j;
- register WORD state;
- HMENU hSub;
- WORD n;
-
- for (j = 0; j < MAXTOGGLEMENUS; j++) {
- hSub = GetSubMenu(hMenu, j);
- n = GetMenuItemCount(hSub);
- for (i = 0; i < n; i++) {
- state = GetMenuState(hSub, i, MF_BYPOSITION);
- if (state & MF_CHECKED)
- return GetMenuItemID(hSub, i);
- }
- }
- return -1;
- }
-
- /* reset the backing store and any flags */
- static void NEAR ResetDisplay(void)
- {
- register int i;
-
- for (i = 0; i < sizeof(display); i++)
- display[i] = (BYTE)i;
- OEMCharSet = FALSE;
- }
-
- /* compare two strings dialog */
- BOOL FAR PASCAL CompareDlgFunc(HWND hDlg, unsigned message,
- WORD wParam, LONG lParam)
- {
- static BOOL cmptype;
-
- switch(message) {
-
- case WM_INITDIALOG:
- SendDlgItemMessage(hDlg, IDD_STRING1, EM_LIMITTEXT, BUFLEN, 0L);
- SendDlgItemMessage(hDlg, IDD_STRING2, EM_LIMITTEXT, BUFLEN, 0L);
- cmptype = (BOOL)lParam;
- break;
-
- case WM_COMMAND:
- switch(wParam) {
-
- case IDD_STRING1:
- case IDD_STRING2: /* compare on every char typed */
- if (HIWORD(lParam) == EN_CHANGE)
- DoCompare(hDlg, cmptype);
- break;
-
- case IDCANCEL:
- EndDialog(hDlg, FALSE);
- break;
-
- default:
- return FALSE;
- }
- break;
-
- default:
- return FALSE;
- }
- return TRUE;
- }
-
- /* do the compare using either C or Windows functions */
- static void NEAR DoCompare(HWND hDlg, BOOL cmptype)
- {
- BYTE buf1[BUFLEN];
- BYTE buf2[BUFLEN];
- int cmp;
- int cmpi;
- static char cbuf[2];
- static char cibuf[2];
-
- GetDlgItemText(hDlg, IDD_STRING1, buf1, sizeof(buf1));
- GetDlgItemText(hDlg, IDD_STRING2, buf2, sizeof(buf2));
-
- if (cmptype) {
- cmp = lstrcmp(buf1, buf2);
- cmpi = lstrcmpi(buf1, buf2);
- }
- else {
- cmp = strcmp(buf1, buf2);
- cmpi = strcmpi(buf1, buf2);
- }
-
- if (cmp < 0)
- cbuf[0] = '<';
- else if (cmp > 0)
- cbuf[0] = '>';
- else
- cbuf[0] = '=';
-
- if (cmpi < 0)
- cibuf[0] = '<';
- else if (cmpi > 0)
- cibuf[0] = '>';
- else
- cibuf[0] = '=';
-
- SetDlgItemText(hDlg, IDD_CASE, cbuf);
- SetDlgItemText(hDlg, IDD_NOCASE, cibuf);
-
- }
-
- /* Show the effects of the OEMCONVERT style on an edit box */
- BOOL FAR PASCAL OEMConvertDlg(HWND hDlg, unsigned message, WORD wParam,
- LONG lParam)
- {
-
- switch(message) {
-
- case WM_INITDIALOG:
- SetOEMConvertStyle(hDlg, IDD_OEMCONVERT, TRUE);
- CheckDlgButton(hDlg, IDD_OEMON, TRUE);
- break;
-
- case WM_COMMAND:
- switch(wParam) {
- case IDD_OEMON:
- if (IsDlgButtonChecked(hDlg, IDD_OEMON)) {
- SetOEMConvertStyle(hDlg, IDD_OEMCONVERT, FALSE);
- CheckDlgButton(hDlg, IDD_OEMON, FALSE);
- }
- else {
- SetOEMConvertStyle(hDlg, IDD_OEMCONVERT, TRUE);
- CheckDlgButton(hDlg, IDD_OEMON, TRUE);
- }
- SetFocus(GetDlgItem(hDlg, IDD_OEMCONVERT));
- break;
-
- case IDOK:
- EndDialog(hDlg, TRUE);
- break;
-
- case IDCANCEL:
- EndDialog(hDlg, FALSE);
- break;
-
- default:
- return FALSE;
- }
- break;
-
- default:
- return FALSE;
- }
- return TRUE;
- }
-
- /* set the OEMCONVERT style on or off */
- static void NEAR SetOEMConvertStyle(HWND hDlg, WORD id, BOOL flag)
- {
-
- LONG style;
- HWND hctl;
-
- hctl = GetDlgItem(hDlg, id);
- style = GetWindowLong(hctl, GWL_STYLE);
-
- if (flag)
- style |= ES_OEMCONVERT;
- else
- style &= ~ES_OEMCONVERT;
- SetWindowLong(hctl, GWL_STYLE, style);
- }
-
- /* Read and display the strings from the win.ini [intl] section */
- BOOL FAR PASCAL IntlDlg(HWND hDlg, unsigned message, WORD wParam, LONG lParam)
- {
-
- switch(message) {
-
- case WM_INITDIALOG:
- IntlDlgInit(hDlg);
- break;
-
- case WM_COMMAND:
- switch(wParam) {
- case IDOK:
- case IDCANCEL:
- EndDialog(hDlg, TRUE);
- break;
-
- default:
- return FALSE;
- }
- break;
-
- default:
- return FALSE;
- }
- return TRUE;
- }
-
- #define DEFCOUNTRY 0
-
- /* Load up the dialog box */
- static void NEAR IntlDlgInit(HWND hDlg)
- {
-
- char kbuf[80];
- char intlbuf[40];
- char valbuf[80];
- int val;
-
- LoadString(hRC, IDS_INTL, intlbuf, sizeof(intlbuf));
-
- LoadString(hRC, IDS_COUNTRYCODE, kbuf, sizeof(kbuf));
- val = GetProfileInt(intlbuf, kbuf, 0);
- SetDlgItemInt(hDlg, IDD_COUNTRYCODE, val, FALSE);
-
- LoadString(hRC, IDS_COUNTRY, kbuf, sizeof(kbuf));
- val = GetProfileString(intlbuf, kbuf, "", valbuf, sizeof(valbuf));
- SetDlgItemText(hDlg, IDD_COUNTRY, valbuf);
-
- GetLanguageString(valbuf);
- SetDlgItemText(hDlg, IDD_LANGUAGE, valbuf);
-
- LoadString(hRC, IDS_LISTSEPARATOR, kbuf, sizeof(kbuf));
- val = GetProfileString(intlbuf, kbuf, "", valbuf, sizeof(valbuf));
- SetDlgItemText(hDlg, IDD_LISTSEPARATOR, valbuf);
-
- LoadString(hRC, IDS_MEASUREMENT, kbuf, sizeof(kbuf));
- val = GetProfileInt(intlbuf, kbuf, 0);
- SetDlgItemInt(hDlg, IDD_MEASUREMENT, val, FALSE);
-
- LoadString(hRC, IDS_TIMEFORMAT, kbuf, sizeof(kbuf));
- val = GetProfileInt(intlbuf, kbuf, 0);
- SetDlgItemInt(hDlg, IDD_TIMEFORMAT, val, FALSE);
-
- LoadString(hRC, IDS_TIMESEPARATOR, kbuf, sizeof(kbuf));
- val = GetProfileString(intlbuf, kbuf, "", valbuf, sizeof(valbuf));
- SetDlgItemText(hDlg, IDD_TIMESEPARATOR, valbuf);
-
- LoadString(hRC, IDS_AMSTRING, kbuf, sizeof(kbuf));
- val = GetProfileString(intlbuf, kbuf, "", valbuf, sizeof(valbuf));
- SetDlgItemText(hDlg, IDD_AMSTRING, valbuf);
-
- LoadString(hRC, IDS_PMSTRING, kbuf, sizeof(kbuf));
- val = GetProfileString(intlbuf, kbuf, "", valbuf, sizeof(valbuf));
- SetDlgItemText(hDlg, IDD_PMSTRING, valbuf);
-
- LoadString(hRC, IDS_TIMELEADINGZERO, kbuf, sizeof(kbuf));
- val = GetProfileInt(intlbuf, kbuf, 0);
- SetDlgItemInt(hDlg, IDD_TIMELEADINGZERO, val, FALSE);
-
- LoadString(hRC, IDS_WIN2DATEFORMAT, kbuf, sizeof(kbuf));
- val = GetProfileInt(intlbuf, kbuf, 0);
- SetDlgItemInt(hDlg, IDD_WIN2DATEFORMAT, val, FALSE);
-
- LoadString(hRC, IDS_WIN2DATESEPARATOR, kbuf, sizeof(kbuf));
- val = GetProfileString(intlbuf, kbuf, "", valbuf, sizeof(valbuf));
- SetDlgItemText(hDlg, IDD_WIN2DATESEPARATOR, valbuf);
-
- LoadString(hRC, IDS_SHORTDATEFORMAT, kbuf, sizeof(kbuf));
- val = GetProfileString(intlbuf, kbuf, "", valbuf, sizeof(valbuf));
- SetDlgItemText(hDlg, IDD_SHORTDATEFORMAT, valbuf);
-
- LoadString(hRC, IDS_LONGDATEFORMAT, kbuf, sizeof(kbuf));
- val = GetProfileString(intlbuf, kbuf, "", valbuf, sizeof(valbuf));
- SetDlgItemText(hDlg, IDD_LONGDATEFORMAT, valbuf);
-
- LoadString(hRC, IDS_CURRENCYSYMBOL, kbuf, sizeof(kbuf));
- val = GetProfileString(intlbuf, kbuf, "", valbuf, sizeof(valbuf));
- SetDlgItemText(hDlg, IDD_CURRENCYSYMBOL, valbuf);
-
- LoadString(hRC, IDS_CURRENCYFORMAT, kbuf, sizeof(kbuf));
- val = GetProfileInt(intlbuf, kbuf, 0);
- SetDlgItemInt(hDlg, IDD_CURRENCYFORMAT, val, FALSE);
-
- LoadString(hRC, IDS_CURRENCYDIGITS, kbuf, sizeof(kbuf));
- val = GetProfileInt(intlbuf, kbuf, 0);
- SetDlgItemInt(hDlg, IDD_CURRENCYDIGITS, val, FALSE);
-
- LoadString(hRC, IDS_NEGATIVECURRENCY, kbuf, sizeof(kbuf));
- val = GetProfileInt(intlbuf, kbuf, 0);
- SetDlgItemInt(hDlg, IDD_NEGATIVECURRENCY, val, FALSE);
-
- LoadString(hRC, IDS_1000SEPARATOR, kbuf, sizeof(kbuf));
- val = GetProfileString(intlbuf, kbuf, "", valbuf, sizeof(valbuf));
- SetDlgItemText(hDlg, IDD_1000SEPARATOR, valbuf);
-
- LoadString(hRC, IDS_DECIMALSEPARATOR, kbuf, sizeof(kbuf));
- val = GetProfileString(intlbuf, kbuf, "", valbuf, sizeof(valbuf));
- SetDlgItemText(hDlg, IDD_DECIMALSEPARATOR, valbuf);
-
- LoadString(hRC, IDS_DECIMALDIGITS, kbuf, sizeof(kbuf));
- val = GetProfileInt(intlbuf, kbuf, 0);
- SetDlgItemInt(hDlg, IDD_DECIMALDIGITS, val, FALSE);
-
- LoadString(hRC, IDS_DECIMALLEADINGZERO, kbuf, sizeof(kbuf));
- val = GetProfileInt(intlbuf, kbuf, 0);
- SetDlgItemInt(hDlg, IDD_DECIMALLEADINGZERO, val, FALSE);
-
- }
-
- /* Get the language module string. */
- static void NEAR GetLanguageString(BYTE *buf)
- {
- GetPrivateProfileString("boot.description", "language.dll",
- "English (American)", buf, 80, "system.ini");
- }
-
- /* Read the keyboard's name from Setup.inf.
- Imbedded strings used here are not language dependent */
- static void NEAR ShowKBLanguage(HWND hWnd)
- {
- char kbdll[20];
- char keystr[512];
- char winpath[MAXPATHLEN + MAXFILENAMELEN + 2];
- char *keyptr;
- register int len;
- char kbstring[80];
- char fmt[80];
- char buf[80];
- char *result;
-
- /* find out where SETUP.INF is located and add in its name */
- len = GetSystemDirectory(winpath, sizeof(winpath));
- if ((len == 0) || (len > MAXPATHLEN))
- return; /* error */
- if (winpath[len - 1] != '\\') /* are we in a subdirectory ? */
- lstrcat(winpath, "\\");
- lstrcat(winpath, "SETUP.INF");
-
- /* now read in the name of the keyboard dll in use from system.ini */
- len = GetPrivateProfileString("keyboard", "keyboard.dll",
- "", kbdll, sizeof(kbdll), "system.ini");
- if (len == 0)
- strcpy(keystr, "nodll"); /* none in use */
- else /* found one, so enumerate all possibilities */
- GetPrivateProfileString("keyboard.tables", NULL, "",
- keystr, sizeof(keystr), winpath);
- keyptr = keystr;
- while (len = strlen(keyptr)) { /* loop thru strings until target found */
- GetPrivateProfileString("keyboard.tables", keyptr, "",
- kbstring, sizeof(kbstring), winpath);
- if (result = strstr(kbstring, kbdll)) {
- strtok(kbstring, "\""); /* found one, parse and add to tile */
- LoadString(hRC, IDS_KBLAYOUT, fmt, sizeof(fmt));
- wsprintf(buf, fmt, (LPSTR)strtok(NULL, "\""));
- MessageBox(hWnd, buf, szAppName, MB_OK | MB_ICONINFORMATION);
- break;
- }
- keyptr += len + 1;
- }
- }
-
- /* Show the effects of sorting a list according to current language module */
- BOOL FAR PASCAL ListSortDlg(HWND hDlg, unsigned message, WORD wParam,
- LONG lParam)
- {
-
- switch(message) {
-
- case WM_INITDIALOG:
- ListSortInit(hDlg);
- break;
-
- case WM_COMMAND:
- switch(wParam) {
- case IDOK:
- ListOpen(hDlg);
- break;
-
- case IDCANCEL:
- EndDialog(hDlg, FALSE);
- break;
-
- default:
- return FALSE;
- }
- break;
-
- default:
- return FALSE;
- }
- return TRUE;
- }
-
- /* Initialize the dialog */
- static void NEAR ListSortInit(HWND hDlg)
- {
- BYTE buf[80];
- BYTE lang[80];
- BYTE title[50];
- BYTE *fmt = "%s : %s"; /* should be moved to resources */
-
- GetWindowText(hDlg, title, sizeof(title));
- GetLanguageString(lang);
- wsprintf(buf, fmt, (LPSTR)title, (LPSTR)lang);
- SetWindowText(hDlg, buf);
-
- SetOEMConvertStyle(hDlg, IDD_FILENAME, TRUE);
- SendDlgItemMessage(hDlg, IDD_FILENAME, EM_LIMITTEXT, NAMELEN, 0L);
- }
-
- /* Open a list of strings and put them into two
- list boxes with one sorted and the other unsorted.
- */
- static void NEAR ListOpen(HWND hDlg)
- {
-
- FILE *fp;
- BYTE fname[NAMELEN];
- BYTE buf[256];
- BYTE *pbuf;
- int pos;
- HWND hList;
-
- SendDlgItemMessage(hDlg, IDD_LISTSORT, LB_RESETCONTENT, 0, 0L);
- SendDlgItemMessage(hDlg, IDD_NOSORT, LB_RESETCONTENT, 0, 0L);
- GetDlgItemText(hDlg, IDD_FILENAME, fname, sizeof(fname));
- /* using stream functions, so must convert name */
- AnsiToOem(fname, fname);
- fp = fopen(fname, "r");
- if (fp != NULL) {
- SendDlgItemMessage(hDlg, IDD_LISTSORT, LB_RESETCONTENT, 0, 0L);
- SendDlgItemMessage(hDlg, IDD_LISTSORT, WM_SETREDRAW, FALSE, 0L);
- SendDlgItemMessage(hDlg, IDD_NOSORT, WM_SETREDRAW, FALSE, 0L);
- while (pbuf = fgets(buf, sizeof(buf), fp)) {
- buf[strlen(pbuf) - 1] = 0;
- pos = (int)SendDlgItemMessage(hDlg, IDD_LISTSORT, LB_ADDSTRING, 0,
- (LONG)(LPSTR)buf);
- if (pos == CB_ERR)
- break;
- pos = (int)SendDlgItemMessage(hDlg, IDD_NOSORT, LB_ADDSTRING, 0,
- (LONG)(LPSTR)buf);
- if (pos == CB_ERR)
- break;
- }
- fclose(fp);
- SendDlgItemMessage(hDlg, IDD_LISTSORT, WM_SETREDRAW, TRUE, 0L);
- SendDlgItemMessage(hDlg, IDD_NOSORT, WM_SETREDRAW, TRUE, 0L);
- hList = GetDlgItem(hDlg, IDD_LISTSORT);
- InvalidateRect(hList, NULL, TRUE);
- UpdateWindow(hList);
- hList = GetDlgItem(hDlg, IDD_NOSORT);
- InvalidateRect(hList, NULL, TRUE);
- UpdateWindow(hList);
- }
- else { /* file not found */
- MessageBeep(0);
- }
- }