コード例 #1
0
ファイル: settings.c プロジェクト: HBelusca/NasuTek-Odyssey
INT_PTR CALLBACK
InputLangPropDlgProc(HWND hDlg,
               UINT message,
               WPARAM wParam,
               LPARAM lParam)
{
    UNREFERENCED_PARAMETER(lParam);

    switch (message)
    {
        case WM_INITDIALOG:
            CreateKeyboardLayoutList(GetDlgItem(hDlg, IDC_KB_LAYOUT_IME_COMBO));
            InitInputLangPropDlg(hDlg);
            break;

        case WM_COMMAND:
            switch (LOWORD(wParam))
            {
                case IDOK:
                    SaveInputLang(hDlg);
                    UpdateLayoutsList();
                    EndDialog(hDlg,LOWORD(wParam));
                    break;

                case IDCANCEL:
                    EndDialog(hDlg,LOWORD(wParam));
                    break;
            }
            break;
    }

    return FALSE;
}
コード例 #2
0
ファイル: add.c プロジェクト: jmalak/reactos
static VOID
AddNewLayout(HWND hwndDlg)
{
    TCHAR NewLayout[CCH_ULONG_DEC + 1], Lang[MAX_PATH],
          LangID[CCH_LAYOUT_ID + 1], Layout[MAX_PATH],
          SubPath[CCH_LAYOUT_ID + 1], szMessage[MAX_PATH];
    INT iLayout, iLang;
    HKEY hKey, hSubKey;
    DWORD cValues;
    PTSTR pts;
    LCID lcid;

    iLayout = SendMessage(hLayoutList, CB_GETCURSEL, 0, 0);
    if (iLayout == CB_ERR) return;

    if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Preload"), 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)
    {
        if (RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, &cValues, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
        {
            _ultot(cValues + 1, NewLayout, 10);

            iLang = SendMessage(hLangList, CB_GETCURSEL, 0, 0);
            lcid = SendMessage(hLangList, CB_GETITEMDATA, iLang, 0);
            pts = (PTSTR) SendMessage(hLayoutList, CB_GETITEMDATA, iLayout, 0);

            GetLocaleInfo(MAKELCID(lcid, SORT_DEFAULT), LOCALE_ILANGUAGE, Lang, sizeof(Lang) / sizeof(TCHAR));
            wsprintf(LangID, _T("0000%s"), Lang);

            if (IsLayoutExists(pts, LangID))
            {
                LoadString(hApplet, IDS_LAYOUT_EXISTS2, szMessage, sizeof(szMessage) / sizeof(TCHAR));
                MessageBox(hwndDlg, szMessage, NULL, MB_OK | MB_ICONINFORMATION);

                RegCloseKey(hKey);
                return;
            }

            if (_tcscmp(LangID, pts) != 0)
            {
                if (!GetLayoutName(pts, Layout))
                {
                    RegCloseKey(hKey);
                    return;
                }
            }
            else
            {
                if (!GetLayoutName(LangID, Layout))
                {
                    RegCloseKey(hKey);
                    return;
                }
            }

            if (SendMessage(hLayoutList, CB_SELECTSTRING, (WPARAM) -1, (LPARAM)Layout) != CB_ERR)
            {
                if (GetLayoutCount(Lang) >= 1)
                {
                    wsprintf(SubPath, _T("d%03d%s"), GetLayoutCount(Lang), Lang);
                }
                else if ((_tcscmp(LangID, pts) != 0) && (GetLayoutCount(Lang) == 0))
                {
                    wsprintf(SubPath, _T("d%03d%s"), 0, Lang);
                }
                else SubPath[0] = '\0';
            }
            else
            {
                RegCloseKey(hKey);
                return;
            }

            if (_tcslen(SubPath) != 0)
            {
                if (RegCreateKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Substitutes"), 0, NULL,
                                   REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
                                   NULL, &hSubKey, NULL) == ERROR_SUCCESS)
                {
                    if (RegSetValueEx(hSubKey, SubPath, 0, REG_SZ, (LPBYTE)pts,
                                      (DWORD)((CCH_LAYOUT_ID + 1) * sizeof(TCHAR))) != ERROR_SUCCESS)
                    {
                        RegCloseKey(hSubKey);
                        RegCloseKey(hKey);
                        return;
                    }
                    RegCloseKey(hSubKey);
                }
                lstrcpy(pts, SubPath);
            }

            if (RegSetValueEx(hKey,
                              NewLayout,
                              0,
                              REG_SZ,
                              (LPBYTE)pts,
                              (DWORD)((CCH_LAYOUT_ID + 1) * sizeof(TCHAR))) == ERROR_SUCCESS)
            {
                UpdateLayoutsList();
            }
        }
        RegCloseKey(hKey);
    }
}
コード例 #3
0
ファイル: settings.c プロジェクト: HBelusca/NasuTek-Odyssey
/* Property page dialog callback */
INT_PTR CALLBACK
SettingPageProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
    UNREFERENCED_PARAMETER(lParam);

    switch (uMsg)
    {
        case WM_INITDIALOG:
        {
        	HIMAGELIST hImgList;

            MainDlgWnd = hwndDlg;
            AddListColumn(hwndDlg);
            (VOID) ListView_SetExtendedListViewStyle(GetDlgItem(MainDlgWnd, IDC_KEYLAYOUT_LIST),
                                                     LVS_EX_FULLROWSELECT);
            hImgList = ImageList_Create(16, 16, ILC_COLOR8 | ILC_MASK, 0, 1);
            InitLangList(hwndDlg, hImgList);
            (VOID) ListView_SetImageList(GetDlgItem(MainDlgWnd, IDC_KEYLAYOUT_LIST), hImgList, LVSIL_SMALL);
        }
            break;
        case WM_NOTIFY:
        {
            switch (LOWORD(wParam))
            {

            }
        }
            break;
        case WM_COMMAND:
            switch (LOWORD(wParam))
            {
                case IDC_REMOVE_BUTTON:
                    DeleteLayout();
                    break;

                case IDC_KEY_SET_BTN:
                    DialogBox(hApplet,
                              MAKEINTRESOURCE(IDD_KEYSETTINGS),
                              hwndDlg,
                              KeySettingsDlgProc);
                    break;

                case IDC_ADD_BUTTON:
                    DialogBox(hApplet,
                              MAKEINTRESOURCE(IDD_ADD),
                              hwndDlg,
                              AddDlgProc);
                    break;

                case IDC_PROP_BUTTON:
                    if (IsLayoutSelected() != -1)
                    DialogBox(hApplet,
                              MAKEINTRESOURCE(IDD_INPUT_LANG_PROP),
                              hwndDlg,
                              InputLangPropDlgProc);
                    break;

                case IDC_SET_DEFAULT:
                    SetDefaultLayout();
                    UpdateLayoutsList();
                    break;
            }
            break;
        case WM_DESTROY:
            break;
    }

    return FALSE;
}
コード例 #4
0
ファイル: settings.c プロジェクト: HBelusca/NasuTek-Odyssey
static VOID
DeleteLayout(VOID)
{
    INT iIndex, LayoutNum;
    LVITEM item;
    HKEY hKey, hSubKey;
    HWND hLayoutList = GetDlgItem(MainDlgWnd, IDC_KEYLAYOUT_LIST);
    TCHAR szLayoutNum[3 + 1], szTitle[MAX_PATH],
          szConf[MAX_PATH], szPreload[CCH_LAYOUT_ID + 1];
    DWORD dwSize;

    iIndex = (INT) SendMessage(hLayoutList, LVM_GETNEXTITEM, -1, LVNI_FOCUSED);

    if (iIndex != -1)
    {
        LoadString(hApplet, IDS_REM_QUESTION, szConf, sizeof(szConf) / sizeof(TCHAR));
        LoadString(hApplet, IDS_CONFIRMATION, szTitle, sizeof(szTitle) / sizeof(TCHAR));

        if (MessageBox(MainDlgWnd, szConf, szTitle, MB_YESNO | MB_ICONQUESTION) == IDYES)
        {
            ZeroMemory(&item, sizeof(LVITEM));

            item.mask = LVIF_PARAM;
            item.iItem = iIndex;

            (VOID) ListView_GetItem(hLayoutList, &item);
            LayoutNum = (INT) item.lParam;

            if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Preload"), 0,
                             KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)
            {
                _ultot(LayoutNum, szLayoutNum, 10);

                dwSize = sizeof(szPreload);
                RegQueryValueEx(hKey, szLayoutNum, NULL, NULL, (LPBYTE)szPreload, &dwSize);

                if (szPreload[0] == 'd')
                {
                    if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Substitutes"), 0,
                                     KEY_ALL_ACCESS, &hSubKey) == ERROR_SUCCESS)
                    {
                        if (RegDeleteValue(hSubKey, szPreload) != ERROR_SUCCESS)
                        {
                            RegCloseKey(hSubKey);
                            RegCloseKey(hKey);
                            return;
                        }
                        RegCloseKey(hSubKey);
                    }
                }

                if (RegDeleteValue(hKey, szLayoutNum) == ERROR_SUCCESS)
                {
                    UpdateLayoutsList();
                    UpdateRegValueNames(hKey);
                }
            }
            RegCloseKey(hKey);
        }
    }
}