OSDN Git Service

Move more code from C104Keyboard and C109Keyboard to CKeyboardLayout,
authorKazuhiro Fujieda <fujieda@users.sourceforge.jp>
Mon, 18 Jul 2011 07:45:24 +0000 (16:45 +0900)
committerKazuhiro Fujieda <fujieda@users.sourceforge.jp>
Thu, 21 Jul 2011 00:59:07 +0000 (09:59 +0900)
and remove DoDataExchange.

xkeymacs/104keyboard.cpp
xkeymacs/104keyboard.h
xkeymacs/109keyboard.cpp
xkeymacs/109keyboard.h
xkeymacs/keyboardlayout.cpp
xkeymacs/keyboardlayout.h

index c4cef51..4392f2f 100644 (file)
@@ -2,8 +2,6 @@
 //\r
 \r
 #include "stdafx.h"\r
-#include <Lmcons.h>\r
-#include "xkeymacs.h"\r
 #include "104Keyboard.h"\r
 \r
 #ifdef _DEBUG\r
@@ -23,86 +21,3 @@ C104Keyboard::C104Keyboard(const HKEY_TYPE hkey_type, CWnd *const pParent /*=NUL
                // NOTE: the ClassWizard will add member initialization here\r
        //}}AFX_DATA_INIT\r
 }\r
-\r
-void C104Keyboard::DoDataExchange(CDataExchange *const pDX)\r
-{\r
-       CDialog::DoDataExchange(pDX);\r
-       //{{AFX_DATA_MAP(C104Keyboard)\r
-               // NOTE: the ClassWizard will add DDX and DDV calls here\r
-       //}}AFX_DATA_MAP\r
-}\r
-\r
-\r
-BEGIN_MESSAGE_MAP(C104Keyboard, CDialog)\r
-       //{{AFX_MSG_MAP(C104Keyboard)\r
-       ON_WM_DESTROY()\r
-       //}}AFX_MSG_MAP\r
-END_MESSAGE_MAP()\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-// C104Keyboard message handlers\r
-\r
-BOOL C104Keyboard::OnInitDialog() \r
-{\r
-       CDialog::OnInitDialog();\r
-       \r
-       CString szWindowText;\r
-       CString szFor;\r
-       switch (m_HkeyType) {\r
-       case CURRENT_USER:\r
-               {\r
-                       TCHAR szUserName[UNLEN + 1] = {'0'};\r
-                       DWORD nSize = UNLEN + 1;\r
-                       if (GetUserName(szUserName, &nSize)) {\r
-                               szFor.Format(IDS_FOR, szUserName);\r
-                       } else {\r
-                               szFor.LoadString(IDS_FOR_LOGGED_ON_USER);\r
-                       }\r
-               }\r
-               break;\r
-       case LOCAL_MACHINE:\r
-               szFor.LoadString(IDS_FOR_ANY_USER);\r
-               break;\r
-       default:\r
-               break;\r
-       }\r
-       this->GetWindowText(szWindowText);\r
-       this->SetWindowText(szWindowText + szFor);\r
-\r
-       m_ToolTip.Create(this, TTS_ALWAYSTIP | TTS_NOPREFIX);\r
-       m_ToolTip.SetMaxTipWidth(0x100);        // Enable multiline\r
-\r
-       InitKeyboardLayout();\r
-       \r
-       return TRUE;  // return TRUE unless you set the focus to a control\r
-                     // EXCEPTION: OCX Property Pages should return FALSE\r
-}\r
-\r
-void C104Keyboard::OnOK() \r
-{\r
-       if (LostKeyWarning(m_HkeyType) != IDCANCEL) {\r
-               SaveScanCodeMap(m_HkeyType);\r
-\r
-               CDialog::OnOK();\r
-       }\r
-}\r
-\r
-void C104Keyboard::OnDestroy() \r
-{\r
-       CDialog::OnDestroy();\r
-\r
-       DestroyKeyboardLayout();\r
-}\r
-\r
-BOOL C104Keyboard::PreTranslateMessage(MSG *const pMsg) \r
-{\r
-       switch (pMsg->message) {\r
-       case WM_LBUTTONDOWN:\r
-       case WM_LBUTTONUP:\r
-       case WM_MOUSEMOVE:\r
-               m_ToolTip.RelayEvent(pMsg);\r
-               break;\r
-       }\r
-\r
-       return CDialog::PreTranslateMessage(pMsg);\r
-}\r
index 9c6e95b..6c765a2 100644 (file)
@@ -17,7 +17,6 @@ class C104Keyboard : public CKeyboardLayout
 {\r
 // Construction\r
 public:\r
-       CToolTipCtrl m_ToolTip;\r
        C104Keyboard(HKEY_TYPE hkey_type, CWnd* pParent = NULL);   // standard constructor\r
 \r
 // Dialog Data\r
@@ -25,26 +24,6 @@ public:
        enum { IDD = IDD_104KEYBOARD };\r
                // NOTE: the ClassWizard will add data members here\r
        //}}AFX_DATA\r
-\r
-\r
-// Overrides\r
-       // ClassWizard generated virtual function overrides\r
-       //{{AFX_VIRTUAL(C104Keyboard)\r
-       public:\r
-       virtual BOOL PreTranslateMessage(MSG* pMsg);\r
-       protected:\r
-       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
-       //}}AFX_VIRTUAL\r
-\r
-// Implementation\r
-protected:\r
-       // Generated message map functions\r
-       //{{AFX_MSG(C104Keyboard)\r
-       virtual BOOL OnInitDialog();\r
-       virtual void OnOK();\r
-       afx_msg void OnDestroy();\r
-       //}}AFX_MSG\r
-       DECLARE_MESSAGE_MAP()\r
 };\r
 \r
 //{{AFX_INSERT_LOCATION}}\r
index 5f0d124..efe940b 100644 (file)
@@ -2,8 +2,6 @@
 //\r
 \r
 #include "stdafx.h"\r
-#include <Lmcons.h>\r
-#include "xkeymacs.h"\r
 #include "109Keyboard.h"\r
 \r
 #ifdef _DEBUG\r
@@ -24,89 +22,6 @@ C109Keyboard::C109Keyboard(const HKEY_TYPE hkey_type, CWnd *const pParent /*=NUL
        //}}AFX_DATA_INIT\r
 }\r
 \r
-void C109Keyboard::DoDataExchange(CDataExchange *const pDX)\r
-{\r
-       CDialog::DoDataExchange(pDX);\r
-       //{{AFX_DATA_MAP(C109Keyboard)\r
-               // NOTE: the ClassWizard will add DDX and DDV calls here\r
-       //}}AFX_DATA_MAP\r
-}\r
-\r
-\r
-BEGIN_MESSAGE_MAP(C109Keyboard, CDialog)\r
-       //{{AFX_MSG_MAP(C109Keyboard)\r
-       ON_WM_DESTROY()\r
-       //}}AFX_MSG_MAP\r
-END_MESSAGE_MAP()\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-// C109Keyboard message handlers\r
-\r
-BOOL C109Keyboard::OnInitDialog() \r
-{\r
-       CDialog::OnInitDialog();\r
-       \r
-       CString szWindowText;\r
-       CString szFor;\r
-       switch (m_HkeyType) {\r
-       case CURRENT_USER:\r
-               {\r
-                       TCHAR szUserName[UNLEN + 1] = {'0'};\r
-                       DWORD nSize = UNLEN + 1;\r
-                       if (GetUserName(szUserName, &nSize)) {\r
-                               szFor.Format(IDS_FOR, szUserName);\r
-                       } else {\r
-                               szFor.LoadString(IDS_FOR_LOGGED_ON_USER);\r
-                       }\r
-               }\r
-               break;\r
-       case LOCAL_MACHINE:\r
-               szFor.LoadString(IDS_FOR_ANY_USER);\r
-               break;\r
-       default:\r
-               break;\r
-       }\r
-       this->GetWindowText(szWindowText);\r
-       this->SetWindowText(szWindowText + szFor);\r
-\r
-       m_ToolTip.Create(this, TTS_ALWAYSTIP | TTS_NOPREFIX);\r
-       m_ToolTip.SetMaxTipWidth(0x100);        // Enable multiline\r
-\r
-       InitKeyboardLayout();\r
-\r
-       return TRUE;  // return TRUE unless you set the focus to a control\r
-                     // EXCEPTION: OCX Property Pages should return FALSE\r
-}\r
-\r
-void C109Keyboard::OnOK() \r
-{\r
-       if (LostKeyWarning(m_HkeyType) != IDCANCEL) {\r
-               SaveScanCodeMap(m_HkeyType);\r
-\r
-               CDialog::OnOK();\r
-       }\r
-}\r
-\r
-void C109Keyboard::OnDestroy() \r
-{\r
-       CDialog::OnDestroy();\r
-\r
-       DestroyKeyboardLayout();\r
-}\r
-\r
-BOOL C109Keyboard::PreTranslateMessage(MSG *const pMsg) \r
-{\r
-       switch (pMsg->message) {\r
-       case WM_LBUTTONDOWN:\r
-       case WM_LBUTTONUP:\r
-       case WM_MOUSEMOVE:\r
-               m_ToolTip.RelayEvent(pMsg);\r
-               break;\r
-       }\r
-\r
-       return CDialog::PreTranslateMessage(pMsg);\r
-}\r
-\r
 int C109Keyboard::GetToolTipID(int nToolTipID)\r
 {\r
        switch (nToolTipID) {\r
index e903f7b..6059d00 100644 (file)
@@ -25,26 +25,7 @@ public:
        enum { IDD = IDD_109KEYBOARD };\r
                // NOTE: the ClassWizard will add data members here\r
        //}}AFX_DATA\r
-\r
-\r
-// Overrides\r
-       // ClassWizard generated virtual function overrides\r
-       //{{AFX_VIRTUAL(C109Keyboard)\r
-       public:\r
-       virtual BOOL PreTranslateMessage(MSG* pMsg);\r
-       protected:\r
-       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
-       //}}AFX_VIRTUAL\r
-\r
-// Implementation\r
 protected:\r
-       // Generated message map functions\r
-       //{{AFX_MSG(C109Keyboard)\r
-       virtual BOOL OnInitDialog();\r
-       virtual void OnOK();\r
-       afx_msg void OnDestroy();\r
-       //}}AFX_MSG\r
-       DECLARE_MESSAGE_MAP()\r
        int GetToolTipID(int nToolTipID);\r
 };\r
 \r
index 79b2504..bafc3f0 100644 (file)
@@ -1,4 +1,5 @@
 #include "stdafx.h"\r
+#include <Lmcons.h>\r
 #include "keyboardlayout.h"\r
 \r
 const int MAX_KEYBOARD_LAYOUT = 112;\r
@@ -130,13 +131,79 @@ CKeyboardLayout::~CKeyboardLayout()
 {\r
 }\r
 \r
+BEGIN_MESSAGE_MAP(CKeyboardLayout, CDialog)\r
+       ON_WM_DESTROY()\r
+END_MESSAGE_MAP()\r
+\r
+BOOL CKeyboardLayout::OnInitDialog() \r
+{\r
+       CDialog::OnInitDialog();\r
+       \r
+       CString szWindowText;\r
+       CString szFor;\r
+       switch (m_HkeyType) {\r
+       case CURRENT_USER:\r
+               {\r
+                       TCHAR szUserName[UNLEN + 1] = {'0'};\r
+                       DWORD nSize = UNLEN + 1;\r
+                       if (GetUserName(szUserName, &nSize)) {\r
+                               szFor.Format(IDS_FOR, szUserName);\r
+                       } else {\r
+                               szFor.LoadString(IDS_FOR_LOGGED_ON_USER);\r
+                       }\r
+               }\r
+               break;\r
+       case LOCAL_MACHINE:\r
+               szFor.LoadString(IDS_FOR_ANY_USER);\r
+               break;\r
+       default:\r
+               break;\r
+       }\r
+       this->GetWindowText(szWindowText);\r
+       this->SetWindowText(szWindowText + szFor);\r
+\r
+       m_ToolTip.Create(this, TTS_ALWAYSTIP | TTS_NOPREFIX);\r
+       m_ToolTip.SetMaxTipWidth(0x100);        // Enable multiline\r
+\r
+       InitKeyboardLayout();\r
+       \r
+       return TRUE;  // return TRUE unless you set the focus to a control\r
+                     // EXCEPTION: OCX Property Pages should return FALSE\r
+}\r
+\r
+void CKeyboardLayout::OnOK() \r
+{\r
+       if (LostKeyWarning(m_HkeyType) != IDCANCEL) {\r
+               SaveScanCodeMap(m_HkeyType);\r
+               CDialog::OnOK();\r
+       }\r
+}\r
+\r
+void CKeyboardLayout::OnDestroy() \r
+{\r
+       CDialog::OnDestroy();\r
+       DestroyKeyboardLayout();\r
+}\r
+\r
+BOOL CKeyboardLayout::PreTranslateMessage(MSG *pMsg) \r
+{\r
+       switch (pMsg->message) {\r
+       case WM_LBUTTONDOWN:\r
+       case WM_LBUTTONUP:\r
+       case WM_MOUSEMOVE:\r
+               m_ToolTip.RelayEvent(pMsg);\r
+               break;\r
+       }\r
+       return CDialog::PreTranslateMessage(pMsg);\r
+}\r
+\r
 void CKeyboardLayout::InitKeyboardLayout()\r
 {\r
        m_ToolTip.Create(this, TTS_ALWAYSTIP | TTS_NOPREFIX);\r
        m_ToolTip.SetMaxTipWidth(0x100);        // Enable multiline\r
 \r
        LoadScanCodeMap(m_HkeyType);\r
-               for (int i = 0; i < MAX_KEYBOARD_LAYOUT; ++i) {\r
+       for (int i = 0; i < MAX_KEYBOARD_LAYOUT; ++i) {\r
                if (!GetDlgItem(m_KeyboardLayouts[i].nBaseControlID)\r
                 || !GetDlgItem(m_KeyboardLayouts[i].nCurrentControlID)) {\r
                        continue;\r
index 65ddcd0..dcbe947 100644 (file)
@@ -42,8 +42,12 @@ private:
        int Prefix2ID(BYTE nPrefix);\r
        DWORD GetScanCodeLength(HKEY_TYPE hkeyType);\r
        BOOL ChangedKeyboardLayout(HKEY_TYPE hkeyType);\r
+       virtual BOOL PreTranslateMessage(MSG *pMsg);\r
 protected:\r
        HKEY_TYPE m_HkeyType;\r
+       virtual BOOL OnInitDialog();\r
+       virtual void OnOK();\r
+       afx_msg void OnDestroy();\r
        void InitKeyboardLayout();\r
        void CKeyboardLayout::DestroyKeyboardLayout();\r
        BOOL GetScanCodeMap(HKEY_TYPE hkeyType, ScanCode original, ScanCode *current);\r
@@ -52,6 +56,7 @@ protected:
        int LostKeyWarning(HKEY_TYPE hkeyType);\r
        void SaveScanCodeMap(HKEY_TYPE hkeyType);\r
        void LoadScanCodeMap(HKEY_TYPE hkeyType);\r
+       DECLARE_MESSAGE_MAP()\r
 public:\r
        CToolTipCtrl *ToolTip();\r
        KeyboardLayout *GetKeyboardLayout(int nKey, BOOL bBase = FALSE);\r