PPageAccelTbl.cpp

00001 /* 
00002  *      Copyright (C) 2003-2005 Gabest
00003  *      http://www.gabest.org
00004  *
00005  *  This Program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2, or (at your option)
00008  *  any later version.
00009  *   
00010  *  This Program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013  *  GNU General Public License for more details.
00014  *   
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with GNU Make; see the file COPYING.  If not, write to
00017  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
00018  *  http://www.gnu.org/copyleft/gpl.html
00019  *
00020  */
00021 
00022 // PPageAccelTbl.cpp : implementation file
00023 //
00024 
00025 #include "stdafx.h"
00026 #include "mplayerc.h"
00027 #include "PPageAccelTbl.h"
00028 
00029 // CPPageAccelTbl dialog
00030 
00031 IMPLEMENT_DYNAMIC(CPPageAccelTbl, CPPageBase)
00032 CPPageAccelTbl::CPPageAccelTbl()
00033         : CPPageBase(CPPageAccelTbl::IDD, CPPageAccelTbl::IDD)
00034         , m_list(0)
00035         , m_counter(0)
00036         , m_fWinLirc(FALSE)
00037         , m_WinLircLink(_T("http://winlirc.sourceforge.net/"))
00038         , m_fUIce(FALSE)
00039         , m_UIceLink(_T("http://www.mediatexx.com/"))
00040 {
00041 }
00042 
00043 CPPageAccelTbl::~CPPageAccelTbl()
00044 {
00045 }
00046 
00047 BOOL CPPageAccelTbl::PreTranslateMessage(MSG* pMsg)
00048 {
00049         if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN 
00050         && (pMsg->hwnd == m_WinLircEdit.m_hWnd || pMsg->hwnd == m_UIceEdit.m_hWnd))
00051         {
00052                 OnApply();
00053                 return TRUE;
00054         }
00055 
00056         return __super::PreTranslateMessage(pMsg);
00057 }
00058 
00059 
00060 void CPPageAccelTbl::SetupList()
00061 {
00062         for(int row = 0; row < m_list.GetItemCount(); row++)
00063         {
00064                 wmcmd& wc = m_wmcmds.GetAt((POSITION)m_list.GetItemData(row));
00065 
00066                 CString mod = MakeAccelModLabel(wc.fVirt);
00067                 m_list.SetItemText(row, COL_MOD, mod);
00068 
00069                 CString key = MakeAccelVkeyLabel(wc.key, wc.fVirt&FVIRTKEY);
00070                 m_list.SetItemText(row, COL_KEY, key);
00071 
00072                 CString type = (wc.fVirt&FVIRTKEY)?_T("VIRTKEY"):_T("ASCII");
00073                 m_list.SetItemText(row, COL_TYPE, type);
00074 
00075                 CString id;
00076                 id.Format(_T("%d"), wc.cmd);
00077                 m_list.SetItemText(row, COL_ID, id);
00078 
00079                 m_list.SetItemText(row, COL_MOUSE, MakeMouseButtonLabel(wc.mouse));
00080 
00081                 m_list.SetItemText(row, COL_APPCMD, MakeAppCommandLabel(wc.appcmd));
00082 
00083                 m_list.SetItemText(row, COL_RMCMD, CString(wc.rmcmd));
00084 
00085                 CString repcnt;
00086                 repcnt.Format(_T("%d"), wc.rmrepcnt);
00087                 m_list.SetItemText(row, COL_RMREPCNT, repcnt);
00088         }
00089 }
00090 
00091 CString CPPageAccelTbl::MakeAccelModLabel(BYTE fVirt)
00092 {
00093         CString str;
00094         if(fVirt&FCONTROL) {if(!str.IsEmpty()) str += _T(" + "); str += _T("Ctrl");}
00095         if(fVirt&FALT) {if(!str.IsEmpty()) str += _T(" + "); str += _T("Alt");}
00096         if(fVirt&FSHIFT) {if(!str.IsEmpty()) str += _T(" + "); str += _T("Shift");}
00097         if(str.IsEmpty()) str = _T("None");
00098         return(str);
00099 }
00100 
00101 CString CPPageAccelTbl::MakeAccelVkeyLabel(WORD key, bool fVirtKey)
00102 {
00103         CString str;
00104 
00105         if(fVirtKey)
00106         switch(key)
00107         {
00108         case VK_LBUTTON: str = _T("VK_LBUTTON"); break;
00109         case VK_RBUTTON: str = _T("VK_RBUTTON"); break;
00110         case VK_CANCEL: str = _T("VK_CANCEL"); break;
00111         case VK_MBUTTON: str = _T("VK_MBUTTON"); break;
00112         case VK_XBUTTON1: str = _T("VK_XBUTTON1"); break;
00113         case VK_XBUTTON2: str = _T("VK_XBUTTON2"); break;
00114         case VK_BACK: str = _T("VK_BACK"); break;
00115         case VK_TAB: str = _T("VK_TAB"); break;
00116         case VK_CLEAR: str = _T("VK_CLEAR"); break;
00117         case VK_RETURN: str = _T("VK_RETURN"); break;
00118         case VK_SHIFT: str = _T("VK_SHIFT"); break;
00119         case VK_CONTROL: str = _T("VK_CONTROL"); break;
00120         case VK_MENU: str = _T("VK_MENU"); break;
00121         case VK_PAUSE: str = _T("VK_PAUSE"); break;
00122         case VK_CAPITAL: str = _T("VK_CAPITAL"); break;
00123 //      case VK_KANA: str = _T("VK_KANA"); break;
00124 //      case VK_HANGEUL: str = _T("VK_HANGEUL"); break;
00125         case VK_HANGUL: str = _T("VK_HANGUL"); break;
00126         case VK_JUNJA: str = _T("VK_JUNJA"); break;
00127         case VK_FINAL: str = _T("VK_FINAL"); break;
00128 //      case VK_HANJA: str = _T("VK_HANJA"); break;
00129         case VK_KANJI: str = _T("VK_KANJI"); break;
00130         case VK_ESCAPE: str = _T("VK_ESCAPE"); break;
00131         case VK_CONVERT: str = _T("VK_CONVERT"); break;
00132         case VK_NONCONVERT: str = _T("VK_NONCONVERT"); break;
00133         case VK_ACCEPT: str = _T("VK_ACCEPT"); break;
00134         case VK_MODECHANGE: str = _T("VK_MODECHANGE"); break;
00135         case VK_SPACE: str = _T("VK_SPACE"); break;
00136         case VK_PRIOR: str = _T("VK_PRIOR"); break;
00137         case VK_NEXT: str = _T("VK_NEXT"); break;
00138         case VK_END: str = _T("VK_END"); break;
00139         case VK_HOME: str = _T("VK_HOME"); break;
00140         case VK_LEFT: str = _T("VK_LEFT"); break;
00141         case VK_UP: str = _T("VK_UP"); break;
00142         case VK_RIGHT: str = _T("VK_RIGHT"); break;
00143         case VK_DOWN: str = _T("VK_DOWN"); break;
00144         case VK_SELECT: str = _T("VK_SELECT"); break;
00145         case VK_PRINT: str = _T("VK_PRINT"); break;
00146         case VK_EXECUTE: str = _T("VK_EXECUTE"); break;
00147         case VK_SNAPSHOT: str = _T("VK_SNAPSHOT"); break;
00148         case VK_INSERT: str = _T("VK_INSERT"); break;
00149         case VK_DELETE: str = _T("VK_DELETE"); break;
00150         case VK_HELP: str = _T("VK_HELP"); break;
00151         case VK_LWIN: str = _T("VK_LWIN"); break;
00152         case VK_RWIN: str = _T("VK_RWIN"); break;
00153         case VK_APPS: str = _T("VK_APPS"); break;
00154         case VK_SLEEP: str = _T("VK_SLEEP"); break;
00155         case VK_NUMPAD0: str = _T("VK_NUMPAD0"); break;
00156         case VK_NUMPAD1: str = _T("VK_NUMPAD1"); break;
00157         case VK_NUMPAD2: str = _T("VK_NUMPAD2"); break;
00158         case VK_NUMPAD3: str = _T("VK_NUMPAD3"); break;
00159         case VK_NUMPAD4: str = _T("VK_NUMPAD4"); break;
00160         case VK_NUMPAD5: str = _T("VK_NUMPAD5"); break;
00161         case VK_NUMPAD6: str = _T("VK_NUMPAD6"); break;
00162         case VK_NUMPAD7: str = _T("VK_NUMPAD7"); break;
00163         case VK_NUMPAD8: str = _T("VK_NUMPAD8"); break;
00164         case VK_NUMPAD9: str = _T("VK_NUMPAD9"); break;
00165         case VK_MULTIPLY: str = _T("VK_MULTIPLY"); break;
00166         case VK_ADD: str = _T("VK_ADD"); break;
00167         case VK_SEPARATOR: str = _T("VK_SEPARATOR"); break;
00168         case VK_SUBTRACT: str = _T("VK_SUBTRACT"); break;
00169         case VK_DECIMAL: str = _T("VK_DECIMAL"); break;
00170         case VK_DIVIDE: str = _T("VK_DIVIDE"); break;
00171         case VK_F1: str = _T("VK_F1"); break;
00172         case VK_F2: str = _T("VK_F2"); break;
00173         case VK_F3: str = _T("VK_F3"); break;
00174         case VK_F4: str = _T("VK_F4"); break;
00175         case VK_F5: str = _T("VK_F5"); break;
00176         case VK_F6: str = _T("VK_F6"); break;
00177         case VK_F7: str = _T("VK_F7"); break;
00178         case VK_F8: str = _T("VK_F8"); break;
00179         case VK_F9: str = _T("VK_F9"); break;
00180         case VK_F10: str = _T("VK_F10"); break;
00181         case VK_F11: str = _T("VK_F11"); break;
00182         case VK_F12: str = _T("VK_F12"); break;
00183         case VK_F13: str = _T("VK_F13"); break;
00184         case VK_F14: str = _T("VK_F14"); break;
00185         case VK_F15: str = _T("VK_F15"); break;
00186         case VK_F16: str = _T("VK_F16"); break;
00187         case VK_F17: str = _T("VK_F17"); break;
00188         case VK_F18: str = _T("VK_F18"); break;
00189         case VK_F19: str = _T("VK_F19"); break;
00190         case VK_F20: str = _T("VK_F20"); break;
00191         case VK_F21: str = _T("VK_F21"); break;
00192         case VK_F22: str = _T("VK_F22"); break;
00193         case VK_F23: str = _T("VK_F23"); break;
00194         case VK_F24: str = _T("VK_F24"); break;
00195         case VK_NUMLOCK: str = _T("VK_NUMLOCK"); break;
00196         case VK_SCROLL: str = _T("VK_SCROLL"); break;
00197 //      case VK_OEM_NEC_EQUAL: str = _T("VK_OEM_NEC_EQUAL"); break;
00198         case VK_OEM_FJ_JISHO: str = _T("VK_OEM_FJ_JISHO"); break;
00199         case VK_OEM_FJ_MASSHOU: str = _T("VK_OEM_FJ_MASSHOU"); break;
00200         case VK_OEM_FJ_TOUROKU: str = _T("VK_OEM_FJ_TOUROKU"); break;
00201         case VK_OEM_FJ_LOYA: str = _T("VK_OEM_FJ_LOYA"); break;
00202         case VK_OEM_FJ_ROYA: str = _T("VK_OEM_FJ_ROYA"); break;
00203         case VK_LSHIFT: str = _T("VK_LSHIFT"); break;
00204         case VK_RSHIFT: str = _T("VK_RSHIFT"); break;
00205         case VK_LCONTROL: str = _T("VK_LCONTROL"); break;
00206         case VK_RCONTROL: str = _T("VK_RCONTROL"); break;
00207         case VK_LMENU: str = _T("VK_LMENU"); break;
00208         case VK_RMENU: str = _T("VK_RMENU"); break;
00209         case VK_BROWSER_BACK: str = _T("VK_BROWSER_BACK"); break;
00210         case VK_BROWSER_FORWARD: str = _T("VK_BROWSER_FORWARD"); break;
00211         case VK_BROWSER_REFRESH: str = _T("VK_BROWSER_REFRESH"); break;
00212         case VK_BROWSER_STOP: str = _T("VK_BROWSER_STOP"); break;
00213         case VK_BROWSER_SEARCH: str = _T("VK_BROWSER_SEARCH"); break;
00214         case VK_BROWSER_FAVORITES: str = _T("VK_BROWSER_FAVORITES"); break;
00215         case VK_BROWSER_HOME: str = _T("VK_BROWSER_HOME"); break;
00216         case VK_VOLUME_MUTE: str = _T("VK_VOLUME_MUTE"); break;
00217         case VK_VOLUME_DOWN: str = _T("VK_VOLUME_DOWN"); break;
00218         case VK_VOLUME_UP: str = _T("VK_VOLUME_UP"); break;
00219         case VK_MEDIA_NEXT_TRACK: str = _T("VK_MEDIA_NEXT_TRACK"); break;
00220         case VK_MEDIA_PREV_TRACK: str = _T("VK_MEDIA_PREV_TRACK"); break;
00221         case VK_MEDIA_STOP: str = _T("VK_MEDIA_STOP"); break;
00222         case VK_MEDIA_PLAY_PAUSE: str = _T("VK_MEDIA_PLAY_PAUSE"); break;
00223         case VK_LAUNCH_MAIL: str = _T("VK_LAUNCH_MAIL"); break;
00224         case VK_LAUNCH_MEDIA_SELECT: str = _T("VK_LAUNCH_MEDIA_SELECT"); break;
00225         case VK_LAUNCH_APP1: str = _T("VK_LAUNCH_APP1"); break;
00226         case VK_LAUNCH_APP2: str = _T("VK_LAUNCH_APP2"); break;
00227         case VK_OEM_1: str = _T("VK_OEM_1"); break;
00228         case VK_OEM_PLUS: str = _T("VK_OEM_PLUS"); break;
00229         case VK_OEM_COMMA: str = _T("VK_OEM_COMMA"); break;
00230         case VK_OEM_MINUS: str = _T("VK_OEM_MINUS"); break;
00231         case VK_OEM_PERIOD: str = _T("VK_OEM_PERIOD"); break;
00232         case VK_OEM_2: str = _T("VK_OEM_2"); break;
00233         case VK_OEM_3: str = _T("VK_OEM_3"); break;
00234         case VK_OEM_4: str = _T("VK_OEM_4"); break;
00235         case VK_OEM_5: str = _T("VK_OEM_5"); break;
00236         case VK_OEM_6: str = _T("VK_OEM_6"); break;
00237         case VK_OEM_7: str = _T("VK_OEM_7"); break;
00238         case VK_OEM_8: str = _T("VK_OEM_8"); break;
00239         case VK_OEM_AX: str = _T("VK_OEM_AX"); break;
00240         case VK_OEM_102: str = _T("VK_OEM_102"); break;
00241         case VK_ICO_HELP: str = _T("VK_ICO_HELP"); break;
00242         case VK_ICO_00: str = _T("VK_ICO_00"); break;
00243         case VK_PROCESSKEY: str = _T("VK_PROCESSKEY"); break;
00244         case VK_ICO_CLEAR: str = _T("VK_ICO_CLEAR"); break;
00245         case VK_PACKET: str = _T("VK_PACKET"); break;
00246         case VK_OEM_RESET: str = _T("VK_OEM_RESET"); break;
00247         case VK_OEM_JUMP: str = _T("VK_OEM_JUMP"); break;
00248         case VK_OEM_PA1: str = _T("VK_OEM_PA1"); break;
00249         case VK_OEM_PA2: str = _T("VK_OEM_PA2"); break;
00250         case VK_OEM_PA3: str = _T("VK_OEM_PA3"); break;
00251         case VK_OEM_WSCTRL: str = _T("VK_OEM_WSCTRL"); break;
00252         case VK_OEM_CUSEL: str = _T("VK_OEM_CUSEL"); break;
00253         case VK_OEM_ATTN: str = _T("VK_OEM_ATTN"); break;
00254         case VK_OEM_FINISH: str = _T("VK_OEM_FINISH"); break;
00255         case VK_OEM_COPY: str = _T("VK_OEM_COPY"); break;
00256         case VK_OEM_AUTO: str = _T("VK_OEM_AUTO"); break;
00257         case VK_OEM_ENLW: str = _T("VK_OEM_ENLW"); break;
00258         case VK_OEM_BACKTAB: str = _T("VK_OEM_BACKTAB"); break;
00259         case VK_ATTN: str = _T("VK_ATTN"); break;
00260         case VK_CRSEL: str = _T("VK_CRSEL"); break;
00261         case VK_EXSEL: str = _T("VK_EXSEL"); break;
00262         case VK_EREOF: str = _T("VK_EREOF"); break;
00263         case VK_PLAY: str = _T("VK_PLAY"); break;
00264         case VK_ZOOM: str = _T("VK_ZOOM"); break;
00265         case VK_NONAME: str = _T("VK_NONAME"); break;
00266         case VK_PA1: str = _T("VK_PA1"); break;
00267         case VK_OEM_CLEAR: str = _T("VK_OEM_CLEAR"); break;
00268         default: 
00269                 if('0' <= key && key <= '9' || 'A' <= key && key <= 'Z')
00270                         str.Format(_T("%c"), (TCHAR)key);
00271                 break;
00272         }
00273 
00274         if(str.IsEmpty() || !fVirtKey)
00275         {
00276                 str.Format(_T("%c, 0x%02x"), (TCHAR)key, key); 
00277                 return(str);
00278         }
00279 
00280         return(str);
00281 }
00282 
00283 CString CPPageAccelTbl::MakeAccelShortcutLabel(UINT id)
00284 {
00285         CList<wmcmd>& wmcmds = AfxGetAppSettings().wmcmds;
00286         POSITION pos = wmcmds.GetHeadPosition();
00287         while(pos)
00288         {
00289                 ACCEL& a = wmcmds.GetNext(pos);
00290                 if(a.cmd == id)
00291                         return(MakeAccelShortcutLabel(a));
00292         }
00293 
00294         return(_T(""));
00295 }
00296 
00297 CString CPPageAccelTbl::MakeAccelShortcutLabel(ACCEL& a)
00298 {
00299         CString str;
00300 
00301         if(a.fVirt&1)
00302         switch(a.key)
00303         {
00304         case VK_LBUTTON: str = _T("LBtn"); break;
00305         case VK_RBUTTON: str = _T("RBtn"); break;
00306         case VK_CANCEL: str = _T("Cancel"); break;
00307         case VK_MBUTTON: str = _T("MBtn"); break;
00308         case VK_XBUTTON1: str = _T("X1Btn"); break;
00309         case VK_XBUTTON2: str = _T("X2Btn"); break;
00310         case VK_BACK: str = _T("Back"); break;
00311         case VK_TAB: str = _T("Tab"); break;
00312         case VK_CLEAR: str = _T("Clear"); break;
00313         case VK_RETURN: str = _T("Return"); break;
00314         case VK_SHIFT: str = _T("Shift"); break;
00315         case VK_CONTROL: str = _T("Ctrl"); break;
00316         case VK_MENU: str = _T("Alt"); break;
00317         case VK_PAUSE: str = _T("Pause"); break;
00318         case VK_CAPITAL: str = _T("Capital"); break;
00319 //      case VK_KANA: str = _T("Kana"); break;
00320 //      case VK_HANGEUL: str = _T("Hangeul"); break;
00321         case VK_HANGUL: str = _T("Hangul"); break;
00322         case VK_JUNJA: str = _T("Junja"); break;
00323         case VK_FINAL: str = _T("Final"); break;
00324 //      case VK_HANJA: str = _T("Hanja"); break;
00325         case VK_KANJI: str = _T("Kanji"); break;
00326         case VK_ESCAPE: str = _T("Escape"); break;
00327         case VK_CONVERT: str = _T("Convert"); break;
00328         case VK_NONCONVERT: str = _T("Non Convert"); break;
00329         case VK_ACCEPT: str = _T("Accept"); break;
00330         case VK_MODECHANGE: str = _T("Mode Change"); break;
00331         case VK_SPACE: str = _T("Space"); break;
00332         case VK_PRIOR: str = _T("PgUp"); break;
00333         case VK_NEXT: str = _T("PgDn"); break;
00334         case VK_END: str = _T("End"); break;
00335         case VK_HOME: str = _T("Home"); break;
00336         case VK_LEFT: str = _T("Left"); break;
00337         case VK_UP: str = _T("Up"); break;
00338         case VK_RIGHT: str = _T("Right"); break;
00339         case VK_DOWN: str = _T("Down"); break;
00340         case VK_SELECT: str = _T("Select"); break;
00341         case VK_PRINT: str = _T("Print"); break;
00342         case VK_EXECUTE: str = _T("Execute"); break;
00343         case VK_SNAPSHOT: str = _T("Snapshot"); break;
00344         case VK_INSERT: str = _T("Insert"); break;
00345         case VK_DELETE: str = _T("Delete"); break;
00346         case VK_HELP: str = _T("Help"); break;
00347         case VK_LWIN: str = _T("LWin"); break;
00348         case VK_RWIN: str = _T("RWin"); break;
00349         case VK_APPS: str = _T("Apps"); break;
00350         case VK_SLEEP: str = _T("Sleep"); break;
00351         case VK_NUMPAD0: str = _T("Numpad 0"); break;
00352         case VK_NUMPAD1: str = _T("Numpad 1"); break;
00353         case VK_NUMPAD2: str = _T("Numpad 2"); break;
00354         case VK_NUMPAD3: str = _T("Numpad 3"); break;
00355         case VK_NUMPAD4: str = _T("Numpad 4"); break;
00356         case VK_NUMPAD5: str = _T("Numpad 5"); break;
00357         case VK_NUMPAD6: str = _T("Numpad 6"); break;
00358         case VK_NUMPAD7: str = _T("Numpad 7"); break;
00359         case VK_NUMPAD8: str = _T("Numpad 8"); break;
00360         case VK_NUMPAD9: str = _T("Numpad 9"); break;
00361         case VK_MULTIPLY: str = _T("Multiply"); break;
00362         case VK_ADD: str = _T("Add"); break;
00363         case VK_SEPARATOR: str = _T("Separator"); break;
00364         case VK_SUBTRACT: str = _T("Subtract"); break;
00365         case VK_DECIMAL: str = _T("Decimal"); break;
00366         case VK_DIVIDE: str = _T("Divide"); break;
00367         case VK_F1: str = _T("F1"); break;
00368         case VK_F2: str = _T("F2"); break;
00369         case VK_F3: str = _T("F3"); break;
00370         case VK_F4: str = _T("F4"); break;
00371         case VK_F5: str = _T("F5"); break;
00372         case VK_F6: str = _T("F6"); break;
00373         case VK_F7: str = _T("F7"); break;
00374         case VK_F8: str = _T("F8"); break;
00375         case VK_F9: str = _T("F9"); break;
00376         case VK_F10: str = _T("F10"); break;
00377         case VK_F11: str = _T("F11"); break;
00378         case VK_F12: str = _T("F12"); break;
00379         case VK_F13: str = _T("F13"); break;
00380         case VK_F14: str = _T("F14"); break;
00381         case VK_F15: str = _T("F15"); break;
00382         case VK_F16: str = _T("F16"); break;
00383         case VK_F17: str = _T("F17"); break;
00384         case VK_F18: str = _T("F18"); break;
00385         case VK_F19: str = _T("F19"); break;
00386         case VK_F20: str = _T("F20"); break;
00387         case VK_F21: str = _T("F21"); break;
00388         case VK_F22: str = _T("F22"); break;
00389         case VK_F23: str = _T("F23"); break;
00390         case VK_F24: str = _T("F24"); break;
00391         case VK_NUMLOCK: str = _T("Numlock"); break;
00392         case VK_SCROLL: str = _T("Scroll"); break;
00393 //      case VK_OEM_NEC_EQUAL: str = _T("OEM NEC Equal"); break;
00394         case VK_OEM_FJ_JISHO: str = _T("OEM FJ Jisho"); break;
00395         case VK_OEM_FJ_MASSHOU: str = _T("OEM FJ Msshou"); break;
00396         case VK_OEM_FJ_TOUROKU: str = _T("OEM FJ Touroku"); break;
00397         case VK_OEM_FJ_LOYA: str = _T("OEM FJ Loya"); break;
00398         case VK_OEM_FJ_ROYA: str = _T("OEM FJ Roya"); break;
00399         case VK_LSHIFT: str = _T("LShift"); break;
00400         case VK_RSHIFT: str = _T("RShift"); break;
00401         case VK_LCONTROL: str = _T("LCtrl"); break;
00402         case VK_RCONTROL: str = _T("RCtrl"); break;
00403         case VK_LMENU: str = _T("LAlt"); break;
00404         case VK_RMENU: str = _T("RAlt"); break;
00405         case VK_BROWSER_BACK: str = _T("Browser Back"); break;
00406         case VK_BROWSER_FORWARD: str = _T("Browser Forward"); break;
00407         case VK_BROWSER_REFRESH: str = _T("Browser Refresh"); break;
00408         case VK_BROWSER_STOP: str = _T("Browser Stop"); break;
00409         case VK_BROWSER_SEARCH: str = _T("Browser Search"); break;
00410         case VK_BROWSER_FAVORITES: str = _T("Browser Favorites"); break;
00411         case VK_BROWSER_HOME: str = _T("Browser Home"); break;
00412         case VK_VOLUME_MUTE: str = _T("Volume Mute"); break;
00413         case VK_VOLUME_DOWN: str = _T("Volume Down"); break;
00414         case VK_VOLUME_UP: str = _T("Volume Up"); break;
00415         case VK_MEDIA_NEXT_TRACK: str = _T("Media Next Track"); break;
00416         case VK_MEDIA_PREV_TRACK: str = _T("Media Prev Track"); break;
00417         case VK_MEDIA_STOP: str = _T("Media Stop"); break;
00418         case VK_MEDIA_PLAY_PAUSE: str = _T("Media Play/Pause"); break;
00419         case VK_LAUNCH_MAIL: str = _T("Launch Mail"); break;
00420         case VK_LAUNCH_MEDIA_SELECT: str = _T("Launch Media Select"); break;
00421         case VK_LAUNCH_APP1: str = _T("Launch App1"); break;
00422         case VK_LAUNCH_APP2: str = _T("Launch App2"); break;
00423         case VK_OEM_1: str = _T("OEM 1"); break;
00424         case VK_OEM_PLUS: str = _T("Plus"); break;
00425         case VK_OEM_COMMA: str = _T("Comma"); break;
00426         case VK_OEM_MINUS: str = _T("Minus"); break;
00427         case VK_OEM_PERIOD: str = _T("Period"); break;
00428         case VK_OEM_2: str = _T("OEM 2"); break;
00429         case VK_OEM_3: str = _T("OEM 3"); break;
00430         case VK_OEM_4: str = _T("OEM 4"); break;
00431         case VK_OEM_5: str = _T("OEM 5"); break;
00432         case VK_OEM_6: str = _T("OEM 6"); break;
00433         case VK_OEM_7: str = _T("OEM 7"); break;
00434         case VK_OEM_8: str = _T("OEM 8"); break;
00435         case VK_OEM_AX: str = _T("OEM AX"); break;
00436         case VK_OEM_102: str = _T("OEM 102"); break;
00437         case VK_ICO_HELP: str = _T("ICO Help"); break;
00438         case VK_ICO_00: str = _T("ICO 00"); break;
00439         case VK_PROCESSKEY: str = _T("Process Key"); break;
00440         case VK_ICO_CLEAR: str = _T("ICO Clear"); break;
00441         case VK_PACKET: str = _T("Packet"); break;
00442         case VK_OEM_RESET: str = _T("OEM Reset"); break;
00443         case VK_OEM_JUMP: str = _T("OEM Jump"); break;
00444         case VK_OEM_PA1: str = _T("OEM PA1"); break;
00445         case VK_OEM_PA2: str = _T("OEM PA2"); break;
00446         case VK_OEM_PA3: str = _T("OEM PA3"); break;
00447         case VK_OEM_WSCTRL: str = _T("OEM WSCtrl"); break;
00448         case VK_OEM_CUSEL: str = _T("OEM CUSEL"); break;
00449         case VK_OEM_ATTN: str = _T("OEM ATTN"); break;
00450         case VK_OEM_FINISH: str = _T("OEM Finish"); break;
00451         case VK_OEM_COPY: str = _T("OEM Copy"); break;
00452         case VK_OEM_AUTO: str = _T("OEM Auto"); break;
00453         case VK_OEM_ENLW: str = _T("OEM ENLW"); break;
00454         case VK_OEM_BACKTAB: str = _T("OEM Backtab"); break;
00455         case VK_ATTN: str = _T("ATTN"); break;
00456         case VK_CRSEL: str = _T("CRSEL"); break;
00457         case VK_EXSEL: str = _T("EXSEL"); break;
00458         case VK_EREOF: str = _T("EREOF"); break;
00459         case VK_PLAY: str = _T("Play"); break;
00460         case VK_ZOOM: str = _T("Zoom"); break;
00461         case VK_NONAME: str = _T("Noname"); break;
00462         case VK_PA1: str = _T("PA1"); break;
00463         case VK_OEM_CLEAR: str = _T("OEM Clear"); break;
00464         default: 
00465                 if('0' <= a.key && a.key <= '9' || 'A' <= a.key && a.key <= 'Z')
00466                         str.Format(_T("%c"), (TCHAR)a.key);
00467                 break;
00468         }
00469 
00470         if(str.IsEmpty() || !(a.fVirt&1))
00471                 str.Format(_T("%c"), (TCHAR)a.key);
00472 
00473         if(a.fVirt&(FCONTROL|FALT|FSHIFT)) 
00474                 str = MakeAccelModLabel(a.fVirt) + _T(" + ") + str;
00475 
00476         str.Replace(_T(" + "), _T("+"));
00477 
00478         return(str);
00479 }
00480 
00481 CString CPPageAccelTbl::MakeMouseButtonLabel(UINT mouse)
00482 {
00483         CString ret;
00484         switch(mouse)
00485         {
00486         case wmcmd::NONE: default: ret = _T("None"); break;
00487         case wmcmd::LDOWN: ret = _T("Left Down"); break;
00488         case wmcmd::LUP: ret = _T("Left Up"); break;
00489         case wmcmd::LDBLCLK: ret = _T("Left DblClk"); break;
00490         case wmcmd::MDOWN: ret = _T("Middle Down"); break;
00491         case wmcmd::MUP: ret = _T("Middle Up"); break;
00492         case wmcmd::MDBLCLK: ret = _T("Middle DblClk"); break;
00493         case wmcmd::RDOWN: ret = _T("Right Down"); break;
00494         case wmcmd::RUP: ret = _T("Right Up"); break;
00495         case wmcmd::RDBLCLK: ret = _T("Right DblClk"); break;
00496         case wmcmd::X1DOWN: ret = _T("X1 Down"); break;
00497         case wmcmd::X1UP: ret = _T("X1 Up"); break;
00498         case wmcmd::X1DBLCLK: ret = _T("X1 DblClk"); break;
00499         case wmcmd::X2DOWN: ret = _T("X2 Down"); break;
00500         case wmcmd::X2UP: ret = _T("X2 Up"); break;
00501         case wmcmd::X2DBLCLK: ret = _T("X2 DblClk"); break;
00502         case wmcmd::WUP: ret = _T("Wheel Up"); break;
00503         case wmcmd::WDOWN: ret = _T("Wheel Down"); break;
00504         }
00505         return ret;
00506 }
00507 
00508 CString CPPageAccelTbl::MakeAppCommandLabel(UINT id)
00509 {
00510         CString str;
00511 
00512         ASSERT(id <= APPCOMMAND_LAST);
00513 
00514         switch(id)
00515         {
00516         default: str = _T(""); break;
00517         case APPCOMMAND_BROWSER_BACKWARD: str = _T("BROWSER_BACKWARD"); break;
00518         case APPCOMMAND_BROWSER_FORWARD: str = _T("BROWSER_FORWARD"); break;
00519         case APPCOMMAND_BROWSER_REFRESH: str = _T("BROWSER_REFRESH"); break;
00520         case APPCOMMAND_BROWSER_STOP: str = _T("BROWSER_STOP"); break;
00521         case APPCOMMAND_BROWSER_SEARCH: str = _T("BROWSER_SEARCH"); break;
00522         case APPCOMMAND_BROWSER_FAVORITES: str = _T("BROWSER_FAVORITES"); break;
00523         case APPCOMMAND_BROWSER_HOME: str = _T("BROWSER_HOME"); break;
00524         case APPCOMMAND_VOLUME_MUTE: str = _T("VOLUME_MUTE"); break;
00525         case APPCOMMAND_VOLUME_DOWN: str = _T("VOLUME_DOWN"); break;
00526         case APPCOMMAND_VOLUME_UP: str = _T("VOLUME_UP"); break;
00527         case APPCOMMAND_MEDIA_NEXTTRACK: str = _T("MEDIA_NEXTTRACK"); break;
00528         case APPCOMMAND_MEDIA_PREVIOUSTRACK: str = _T("MEDIA_PREVIOUSTRACK"); break;
00529         case APPCOMMAND_MEDIA_STOP: str = _T("MEDIA_STOP"); break;
00530         case APPCOMMAND_MEDIA_PLAY_PAUSE: str = _T("MEDIA_PLAY_PAUSE"); break;
00531         case APPCOMMAND_LAUNCH_MAIL: str = _T("LAUNCH_MAIL"); break;
00532         case APPCOMMAND_LAUNCH_MEDIA_SELECT: str = _T("LAUNCH_MEDIA_SELECT"); break;
00533         case APPCOMMAND_LAUNCH_APP1: str = _T("LAUNCH_APP1"); break;
00534         case APPCOMMAND_LAUNCH_APP2: str = _T("LAUNCH_APP2"); break;
00535         case APPCOMMAND_BASS_DOWN: str = _T("BASS_DOWN"); break;
00536         case APPCOMMAND_BASS_BOOST: str = _T("BASS_BOOST"); break;
00537         case APPCOMMAND_BASS_UP: str = _T("BASS_UP"); break;
00538         case APPCOMMAND_TREBLE_DOWN: str = _T("TREBLE_DOWN"); break;
00539         case APPCOMMAND_TREBLE_UP: str = _T("TREBLE_UP"); break;
00540         case APPCOMMAND_MICROPHONE_VOLUME_MUTE: str = _T("MICROPHONE_VOLUME_MUTE"); break;
00541         case APPCOMMAND_MICROPHONE_VOLUME_DOWN: str = _T("MICROPHONE_VOLUME_DOWN"); break;
00542         case APPCOMMAND_MICROPHONE_VOLUME_UP: str = _T("MICROPHONE_VOLUME_UP"); break;
00543         case APPCOMMAND_HELP: str = _T("HELP"); break;
00544         case APPCOMMAND_FIND: str = _T("FIND"); break;
00545         case APPCOMMAND_NEW: str = _T("NEW"); break;
00546         case APPCOMMAND_OPEN: str = _T("OPEN"); break;
00547         case APPCOMMAND_CLOSE: str = _T("CLOSE"); break;
00548         case APPCOMMAND_SAVE: str = _T("SAVE"); break;
00549         case APPCOMMAND_PRINT: str = _T("PRINT"); break;
00550         case APPCOMMAND_UNDO: str = _T("UNDO"); break;
00551         case APPCOMMAND_REDO: str = _T("REDO"); break;
00552         case APPCOMMAND_COPY: str = _T("COPY"); break;
00553         case APPCOMMAND_CUT: str = _T("CUT"); break;
00554         case APPCOMMAND_PASTE: str = _T("PASTE"); break;
00555         case APPCOMMAND_REPLY_TO_MAIL: str = _T("REPLY_TO_MAIL"); break;
00556         case APPCOMMAND_FORWARD_MAIL: str = _T("FORWARD_MAIL"); break;
00557         case APPCOMMAND_SEND_MAIL: str = _T("SEND_MAIL"); break;
00558         case APPCOMMAND_SPELL_CHECK: str = _T("SPELL_CHECK"); break;
00559         case APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE: str = _T("DICTATE_OR_COMMAND_CONTROL_TOGGLE"); break;
00560         case APPCOMMAND_MIC_ON_OFF_TOGGLE: str = _T("MIC_ON_OFF_TOGGLE"); break;
00561         case APPCOMMAND_CORRECTION_LIST: str = _T("CORRECTION_LIST"); break;
00562         case APPCOMMAND_MEDIA_PLAY: str = _T("MEDIA_PLAY"); break;
00563         case APPCOMMAND_MEDIA_PAUSE: str = _T("MEDIA_PAUSE"); break;
00564         case APPCOMMAND_MEDIA_RECORD: str = _T("MEDIA_RECORD"); break;
00565         case APPCOMMAND_MEDIA_FAST_FORWARD: str = _T("MEDIA_FAST_FORWARD"); break;
00566         case APPCOMMAND_MEDIA_REWIND: str = _T("MEDIA_REWIND"); break;
00567         case APPCOMMAND_MEDIA_CHANNEL_UP: str = _T("MEDIA_CHANNEL_UP"); break;
00568         case APPCOMMAND_MEDIA_CHANNEL_DOWN: str = _T("MEDIA_CHANNEL_DOWN"); break;
00569         }
00570 
00571         return str;
00572 }
00573 void CPPageAccelTbl::DoDataExchange(CDataExchange* pDX)
00574 {
00575         __super::DoDataExchange(pDX);
00576         DDX_Text(pDX, IDC_EDIT1, m_WinLircAddr);
00577         DDX_Control(pDX, IDC_EDIT1, m_WinLircEdit);
00578         DDX_Control(pDX, IDC_STATICLINK, m_WinLircLink);
00579         DDX_Check(pDX, IDC_CHECK1, m_fWinLirc);
00580         DDX_Text(pDX, IDC_EDIT2, m_UIceAddr);
00581         DDX_Control(pDX, IDC_EDIT2, m_UIceEdit);
00582         DDX_Control(pDX, IDC_STATICLINK2, m_UIceLink);
00583         DDX_Check(pDX, IDC_CHECK9, m_fUIce);
00584 }
00585 
00586 BEGIN_MESSAGE_MAP(CPPageAccelTbl, CPPageBase)
00587         ON_NOTIFY(LVN_BEGINLABELEDIT, IDC_LIST1, OnBeginlabeleditList)
00588         ON_NOTIFY(LVN_DOLABELEDIT, IDC_LIST1, OnDolabeleditList)
00589         ON_NOTIFY(LVN_ENDLABELEDIT, IDC_LIST1, OnEndlabeleditList)
00590         ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
00591         ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
00592         ON_WM_TIMER()
00593         ON_WM_CTLCOLOR()
00594 END_MESSAGE_MAP()
00595 
00596 // CPPageAccelTbl message handlers
00597 
00598 BOOL CPPageAccelTbl::OnInitDialog()
00599 {
00600         __super::OnInitDialog();
00601 
00602         AppSettings& s = AfxGetAppSettings();
00603 
00604         m_wmcmds.RemoveAll();
00605         m_wmcmds.AddTail(&s.wmcmds);
00606         m_fWinLirc = s.fWinLirc;
00607         m_WinLircAddr = s.WinLircAddr;
00608         m_fUIce = s.fUIce;
00609         m_UIceAddr = s.UIceAddr;
00610 
00611         UpdateData(FALSE);
00612 
00613         CRect r;
00614         GetDlgItem(IDC_PLACEHOLDER)->GetWindowRect(r);
00615         ScreenToClient(r);
00616 
00617         m_list.CreateEx(
00618                 WS_EX_CLIENTEDGE, 
00619                 WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_TABSTOP|LVS_REPORT|LVS_AUTOARRANGE|LVS_SHOWSELALWAYS, 
00620                 r, this, IDC_LIST1);
00621 
00622         m_list.SetExtendedStyle(m_list.GetExtendedStyle()|LVS_EX_FULLROWSELECT|LVS_EX_DOUBLEBUFFER);
00623 
00624         for(int i = 0, j = m_list.GetHeaderCtrl()->GetItemCount(); i < j; i++) m_list.DeleteColumn(0);
00625         m_list.InsertColumn(COL_CMD, _T("Command"), LVCFMT_LEFT, 80);
00626         m_list.InsertColumn(COL_MOD, _T("Modifier"), LVCFMT_LEFT, 40);
00627         m_list.InsertColumn(COL_KEY, _T("Key"), LVCFMT_LEFT, 40);
00628         m_list.InsertColumn(COL_TYPE, _T("Type"), LVCFMT_LEFT, 40);
00629         m_list.InsertColumn(COL_ID, _T("ID"), LVCFMT_LEFT, 40);
00630         m_list.InsertColumn(COL_MOUSE, _T("Mouse"), LVCFMT_LEFT, 80);
00631         m_list.InsertColumn(COL_APPCMD, _T("App Command"), LVCFMT_LEFT, 120);
00632         m_list.InsertColumn(COL_RMCMD, _T("RemoteCmd"), LVCFMT_LEFT, 80);
00633         m_list.InsertColumn(COL_RMREPCNT, _T("RepCnt"), LVCFMT_CENTER, 60);
00634 
00635         POSITION pos = m_wmcmds.GetHeadPosition();
00636     for(int i = 0; pos; i++)
00637         {
00638                 int row = m_list.InsertItem(m_list.GetItemCount(), m_wmcmds.GetAt(pos).name, COL_CMD);
00639                 m_list.SetItemData(row, (DWORD_PTR)pos);
00640                 m_wmcmds.GetNext(pos);
00641         }
00642 
00643         SetupList();
00644 
00645         m_list.SetColumnWidth(COL_CMD, LVSCW_AUTOSIZE);
00646         m_list.SetColumnWidth(COL_MOD, LVSCW_AUTOSIZE);
00647         m_list.SetColumnWidth(COL_KEY, LVSCW_AUTOSIZE);
00648         m_list.SetColumnWidth(COL_TYPE, LVSCW_AUTOSIZE);
00649         m_list.SetColumnWidth(COL_ID, LVSCW_AUTOSIZE_USEHEADER);
00650 
00651         return TRUE;  // return TRUE unless you set the focus to a control
00652         // EXCEPTION: OCX Property Pages should return FALSE
00653 }
00654 
00655 BOOL CPPageAccelTbl::OnApply()
00656 {
00657         UpdateData();
00658 
00659         AppSettings& s = AfxGetAppSettings();
00660 
00661         s.wmcmds.RemoveAll();
00662         s.wmcmds.AddTail(&m_wmcmds);
00663 
00664         CArray<ACCEL> pAccel;
00665         pAccel.SetSize(m_wmcmds.GetCount());
00666         POSITION pos = m_wmcmds.GetHeadPosition();
00667         for(int i = 0; pos; i++) pAccel[i] = m_wmcmds.GetNext(pos);
00668         if(s.hAccel) DestroyAcceleratorTable(s.hAccel);
00669         s.hAccel = CreateAcceleratorTable(pAccel.GetData(), pAccel.GetCount());
00670 
00671         GetParentFrame()->m_hAccelTable = s.hAccel;
00672 
00673         s.fWinLirc = !!m_fWinLirc;
00674         s.WinLircAddr = m_WinLircAddr;
00675         if(s.fWinLirc) s.WinLircClient.Connect(m_WinLircAddr);
00676         s.fUIce = !!m_fUIce;
00677         s.UIceAddr = m_UIceAddr;
00678         if(s.fUIce) s.UIceClient.Connect(m_UIceAddr);
00679 
00680         return __super::OnApply();
00681 }
00682 
00683 void CPPageAccelTbl::OnBnClickedButton1()
00684 {
00685         m_list.SetFocus();
00686 
00687         for(int i = 0, j = m_list.GetItemCount(); i < j; i++)
00688         {
00689                 m_list.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
00690         }
00691 }
00692 
00693 void CPPageAccelTbl::OnBnClickedButton2()
00694 {
00695         m_list.SetFocus();
00696 
00697         POSITION pos = m_list.GetFirstSelectedItemPosition();
00698         if(!pos) return;
00699 
00700         AppSettings& s = AfxGetAppSettings();
00701 
00702         while(pos)
00703         {
00704                 wmcmd& wc = m_wmcmds.GetAt((POSITION)m_list.GetItemData(m_list.GetNextSelectedItem(pos)));
00705                 wc.Restore();
00706         }
00707 
00708         SetupList();
00709 
00710         SetModified();
00711 }
00712 
00713 void CPPageAccelTbl::OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult) 
00714 {
00715         LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
00716         LV_ITEM* pItem = &pDispInfo->item;
00717 
00718         *pResult = FALSE;
00719 
00720         if(pItem->iItem < 0) 
00721                 return;
00722 
00723         if(pItem->iSubItem == COL_MOD || pItem->iSubItem == COL_KEY || pItem->iSubItem == COL_TYPE
00724         || pItem->iSubItem == COL_MOUSE || pItem->iSubItem == COL_APPCMD 
00725         || pItem->iSubItem == COL_RMCMD || pItem->iSubItem == COL_RMREPCNT)
00726         {
00727                 *pResult = TRUE;
00728         }
00729 }
00730 
00731 static BYTE s_mods[] = {0,FALT,FCONTROL,FSHIFT,FCONTROL|FALT,FCONTROL|FSHIFT,FALT|FSHIFT,FCONTROL|FALT|FSHIFT};
00732 
00733 void CPPageAccelTbl::OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult) 
00734 {
00735         LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
00736         LV_ITEM* pItem = &pDispInfo->item;
00737 
00738         *pResult = FALSE;
00739 
00740         if(pItem->iItem < 0) 
00741                 return;
00742 
00743         wmcmd& wc = m_wmcmds.GetAt((POSITION)m_list.GetItemData(pItem->iItem));
00744         ACCEL& a = wc;
00745 
00746         CList<CString> sl;
00747         int nSel = -1;
00748 
00749         if(pItem->iSubItem == COL_MOD)
00750         {
00751                 for(int i = 0; i < countof(s_mods); i++)
00752                 {
00753                         sl.AddTail(MakeAccelModLabel(s_mods[i]));
00754                         if((a.fVirt&~3) == s_mods[i]) nSel = i;
00755                 }
00756 
00757                 m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
00758 
00759                 *pResult = TRUE;
00760         }
00761         else if(pItem->iSubItem == COL_KEY)
00762         {
00763                 for(int i = 0; i < 256; i++)
00764                 {
00765                         sl.AddTail(MakeAccelVkeyLabel(i, a.fVirt&FVIRTKEY));
00766                         if(a.key == i) nSel = i;
00767                 }
00768 
00769                 m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
00770 
00771                 *pResult = TRUE;
00772         }
00773         else if(pItem->iSubItem == COL_TYPE)
00774         {
00775                 sl.AddTail(_T("VIRTKEY"));
00776                 sl.AddTail(_T("ASCII"));
00777 
00778                 nSel = !(a.fVirt&FVIRTKEY);
00779 
00780                 m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
00781 
00782                 *pResult = TRUE;
00783         }
00784         else if(pItem->iSubItem == COL_MOUSE)
00785         {
00786                 for(UINT i = 0; i < wmcmd::LAST; i++)
00787                 {
00788                         sl.AddTail(MakeMouseButtonLabel(i));
00789                         if(wc.mouse == i) nSel = i;
00790                 }
00791 
00792                 m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
00793 
00794                 *pResult = TRUE;
00795         }
00796         else if(pItem->iSubItem == COL_APPCMD)
00797         {
00798                 for(int i = 0; i <= APPCOMMAND_LAST; i++)
00799                 {
00800                         sl.AddTail(MakeAppCommandLabel(i));
00801                         if(wc.appcmd == i) nSel = i;
00802                 }
00803 
00804                 m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
00805 
00806                 *pResult = TRUE;
00807         }
00808         else if(pItem->iSubItem == COL_RMCMD)
00809         {
00810                 m_list.ShowInPlaceEdit(pItem->iItem, pItem->iSubItem);
00811 
00812                 *pResult = TRUE;
00813         }
00814         else if(pItem->iSubItem == COL_RMREPCNT)
00815         {
00816                 m_list.ShowInPlaceEdit(pItem->iItem, pItem->iSubItem);
00817 
00818                 *pResult = TRUE;
00819         }
00820 }
00821 
00822 void CPPageAccelTbl::OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult) 
00823 {
00824         LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
00825         LV_ITEM* pItem = &pDispInfo->item;
00826 
00827         *pResult = FALSE;
00828 
00829         if(!m_list.m_fInPlaceDirty)
00830                 return;
00831 
00832         if(pItem->iItem < 0) 
00833                 return;
00834 
00835         wmcmd& wc = m_wmcmds.GetAt((POSITION)m_list.GetItemData(pItem->iItem));
00836 
00837         if(pItem->iSubItem == COL_MOD)
00838         {
00839                 if(pItem->lParam >= 0 && pItem->lParam < countof(s_mods))
00840                 {
00841                         wc.fVirt = (wc.fVirt&3) | (s_mods[pItem->lParam]&~3);
00842                         m_list.SetItemText(pItem->iItem, COL_MOD, pItem->pszText);
00843                         *pResult = TRUE;
00844                 }
00845         }
00846         else if(pItem->iSubItem == COL_KEY)
00847         {
00848                 int i = pItem->lParam;
00849                 if(i >= 0 && i < 256)
00850                 {
00851                         wc.key = (WORD)i;
00852                         m_list.SetItemText(pItem->iItem, COL_KEY, pItem->pszText);
00853                         *pResult = TRUE;
00854                 }
00855         }
00856         else if(pItem->iSubItem == COL_TYPE)
00857         {
00858                 int i = pItem->lParam;
00859                 if(i >= 0 && i < 2)
00860                 {
00861                         wc.fVirt = (wc.fVirt&~FVIRTKEY) | (i == 0 ? FVIRTKEY : 0);
00862                         m_list.SetItemText(pItem->iItem, COL_KEY, MakeAccelVkeyLabel(wc.key, wc.fVirt&FVIRTKEY));
00863                         m_list.SetItemText(pItem->iItem, COL_TYPE, (wc.fVirt&FVIRTKEY)?_T("VIRTKEY"):_T("ASCII"));
00864                         *pResult = TRUE;
00865                 }
00866         }
00867         else if(pItem->iSubItem == COL_APPCMD)
00868         {
00869                 int i = pItem->lParam;
00870                 if(i >= 0 && i <= APPCOMMAND_LAST)
00871                 {
00872                         wc.appcmd = (WORD)i;
00873                         m_list.SetItemText(pItem->iItem, COL_APPCMD, pItem->pszText);
00874                         *pResult = TRUE;
00875                 }
00876         }
00877         else if(pItem->iSubItem == COL_MOUSE)
00878         {
00879                 wc.mouse = pItem->lParam;
00880                 m_list.SetItemText(pItem->iItem, COL_MOUSE, pItem->pszText);
00881         }
00882         else if(pItem->iSubItem == COL_RMCMD)
00883         {
00884                 wc.rmcmd = CStringA(CString(pItem->pszText)).Trim();
00885                 wc.rmcmd.Replace(' ', '_');
00886                 m_list.SetItemText(pItem->iItem, pItem->iSubItem, CString(wc.rmcmd));
00887                 *pResult = TRUE;
00888         }
00889         else if(pItem->iSubItem == COL_RMREPCNT)
00890         {
00891                 CString str = CString(pItem->pszText).Trim();
00892                 wc.rmrepcnt = _tcstol(str, NULL, 10);
00893                 str.Format(_T("%d"), wc.rmrepcnt);
00894                 m_list.SetItemText(pItem->iItem, pItem->iSubItem, str);
00895                 *pResult = TRUE;
00896         }
00897 
00898         if(*pResult)
00899                 SetModified();
00900 }
00901 
00902 
00903 void CPPageAccelTbl::OnTimer(UINT nIDEvent)
00904 {
00905         UpdateData();
00906 
00907         if(m_fWinLirc)
00908         {
00909                 CString addr;
00910                 m_WinLircEdit.GetWindowText(addr);
00911                 AfxGetAppSettings().WinLircClient.Connect(addr);
00912         }
00913 
00914         m_WinLircEdit.Invalidate();
00915 
00916         if(m_fUIce)
00917         {
00918                 CString addr;
00919                 m_UIceEdit.GetWindowText(addr);
00920                 AfxGetAppSettings().UIceClient.Connect(addr);
00921         }
00922 
00923         m_UIceEdit.Invalidate();
00924 
00925         m_counter++;
00926 
00927         __super::OnTimer(nIDEvent);
00928 }
00929 
00930 HBRUSH CPPageAccelTbl::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
00931 {
00932         HBRUSH hbr = __super::OnCtlColor(pDC, pWnd, nCtlColor);
00933 
00934         int status = -1;
00935 
00936         if(*pWnd == m_WinLircEdit)
00937                 status = AfxGetAppSettings().WinLircClient.GetStatus();
00938         else if(*pWnd == m_UIceEdit)
00939                 status = AfxGetAppSettings().UIceClient.GetStatus();
00940 
00941         if(status == 0 || status == 2 && (m_counter&1))
00942                 pDC->SetTextColor(0x0000ff);
00943         else if(status == 1) 
00944                 pDC->SetTextColor(0x008000);
00945 
00946         return hbr;
00947 }
00948 
00949 BOOL CPPageAccelTbl::OnSetActive()
00950 {
00951         SetTimer(1, 1000, NULL);
00952 
00953         return CPPageBase::OnSetActive();
00954 }
00955 
00956 BOOL CPPageAccelTbl::OnKillActive()
00957 {
00958         KillTimer(1);
00959 
00960         return CPPageBase::OnKillActive();
00961 }
00962 

Generated on Tue Dec 13 14:47:00 2005 for guliverkli by  doxygen 1.4.5