|
@@ -1,342 +0,0 @@
|
|
|
-#include "CVKWnd.h"
|
|
|
|
|
-#include "shellapi.h"
|
|
|
|
|
-#pragma comment(lib, "shell32.lib")
|
|
|
|
|
-
|
|
|
|
|
-CVKWnd::CVKWnd()
|
|
|
|
|
-{
|
|
|
|
|
- m_pMinBtn = NULL;
|
|
|
|
|
- m_pCloseBtn = NULL;
|
|
|
|
|
- m_pTabLayout = NULL;
|
|
|
|
|
- m_pSymbolTab = NULL;
|
|
|
|
|
- m_pLShift = NULL;
|
|
|
|
|
- m_pRShift = NULL;
|
|
|
|
|
- m_pNum = NULL;
|
|
|
|
|
- m_pCtrl = NULL;
|
|
|
|
|
- m_pLSymbol = NULL;
|
|
|
|
|
- m_pRSymbol = NULL;
|
|
|
|
|
- m_pInputBtn = NULL;
|
|
|
|
|
- m_bShiftDown = false;
|
|
|
|
|
- m_bCtrlDown = false;
|
|
|
|
|
-}
|
|
|
|
|
-CVKWnd::~CVKWnd(void)
|
|
|
|
|
-{
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-void CVKWnd::LoadCom()
|
|
|
|
|
-{
|
|
|
|
|
-}
|
|
|
|
|
-void CVKWnd::OnPrepare()
|
|
|
|
|
-{
|
|
|
|
|
-}
|
|
|
|
|
-void CVKWnd::Init()
|
|
|
|
|
-{
|
|
|
|
|
- m_pMinBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("minbtn")));
|
|
|
|
|
- m_pCloseBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("closebtn")));
|
|
|
|
|
-
|
|
|
|
|
- m_pTabLayout = static_cast<CTabLayoutUI*>(m_pm.FindControl(_T("switch")));
|
|
|
|
|
-
|
|
|
|
|
- m_pLShift = static_cast<COptionUI*>(m_pm.FindControl(_T("opt_shiftl")));
|
|
|
|
|
- m_pRShift = static_cast<COptionUI*>(m_pm.FindControl(_T("opt_shiftr")));
|
|
|
|
|
- m_pNum = static_cast<COptionUI*>(m_pm.FindControl(_T("opt_num")));
|
|
|
|
|
- m_pCtrl = static_cast<COptionUI*>(m_pm.FindControl(_T("opt_ctrl")));
|
|
|
|
|
- m_pSymbolTab = static_cast<CTabLayoutUI*>(m_pm.FindControl(_T("sswitch")));
|
|
|
|
|
- m_pLSymbol = static_cast<CButtonUI*>(m_pm.FindControl(_T("lsymbol")));
|
|
|
|
|
- m_pRSymbol = static_cast<CButtonUI*>(m_pm.FindControl(_T("rsymbol")));
|
|
|
|
|
- m_pInputBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("inputtype")));
|
|
|
|
|
-
|
|
|
|
|
- for (int i = 65; i < 91; i++)
|
|
|
|
|
- {
|
|
|
|
|
- CDuiString strTemp;
|
|
|
|
|
- strTemp.Format(_T("btn_%d"), i);
|
|
|
|
|
- CButtonUI* pBtn = static_cast<CButtonUI*>(m_pm.FindControl(strTemp.GetData()));
|
|
|
|
|
- if (pBtn)
|
|
|
|
|
- {
|
|
|
|
|
- CDuiString str = pBtn->GetText();
|
|
|
|
|
- m_pVecBtn.push_back(pBtn);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-void CVKWnd::Notify(TNotifyUI& msg)
|
|
|
|
|
-{
|
|
|
|
|
- if (msg.sType == _T("windowinit")) OnPrepare();
|
|
|
|
|
- else if (msg.sType == _T("click"))
|
|
|
|
|
- {
|
|
|
|
|
- if (msg.pSender == m_pCloseBtn)
|
|
|
|
|
- {
|
|
|
|
|
- PostQuitMessage(0);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- else if (msg.pSender == m_pMinBtn)
|
|
|
|
|
- {
|
|
|
|
|
- SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- else if (msg.pSender->GetName() == _T("handinput"))
|
|
|
|
|
- {
|
|
|
|
|
- CDuiString strapp = CPaintManagerUI::GetInstancePath() + _T("..\\app\\handinput\\handinput.exe");
|
|
|
|
|
- ShellExecute(NULL, _T("open"), strapp.GetData(), NULL, NULL, SW_SHOWDEFAULT);
|
|
|
|
|
- // PostQuitMessage(0);
|
|
|
|
|
- }
|
|
|
|
|
- else if (msg.pSender == m_pCtrl) //ctrl键
|
|
|
|
|
- {
|
|
|
|
|
- if (m_pCtrl->IsSelected())
|
|
|
|
|
- {
|
|
|
|
|
- m_bCtrlDown = false;
|
|
|
|
|
- m_pLShift->SetEnabled();
|
|
|
|
|
- m_pRShift->SetEnabled();
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- m_bCtrlDown = true;
|
|
|
|
|
- m_pLShift->Selected(false);
|
|
|
|
|
- m_pRShift->Selected(false);
|
|
|
|
|
- m_pLShift->SetEnabled(false);
|
|
|
|
|
- m_pRShift->SetEnabled(false);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- else if (msg.pSender == m_pLSymbol) //符号左方向按钮
|
|
|
|
|
- {
|
|
|
|
|
- if (m_pSymbolTab)
|
|
|
|
|
- m_pSymbolTab->SelectItem(0);
|
|
|
|
|
- if (m_pLSymbol && m_pRSymbol)
|
|
|
|
|
- {
|
|
|
|
|
- m_pLSymbol->SetEnabled(false);
|
|
|
|
|
- m_pRSymbol->SetEnabled();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- else if (msg.pSender == m_pRSymbol) //符号右方向按钮
|
|
|
|
|
- {
|
|
|
|
|
- if (m_pSymbolTab)
|
|
|
|
|
- m_pSymbolTab->SelectItem(1);
|
|
|
|
|
- if (m_pLSymbol && m_pRSymbol)
|
|
|
|
|
- {
|
|
|
|
|
- m_pLSymbol->SetEnabled();
|
|
|
|
|
- m_pRSymbol->SetEnabled(false);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- else if (msg.pSender->GetName().Find(_T("btn_")) == 0) //普通按键
|
|
|
|
|
- {
|
|
|
|
|
- CDuiString strTemp = msg.pSender->GetName();
|
|
|
|
|
- strTemp = strTemp.Right(strTemp.GetLength() - 4);
|
|
|
|
|
- int iKey = _wtoi(strTemp.GetData());
|
|
|
|
|
- OnClickVK(iKey);
|
|
|
|
|
- }
|
|
|
|
|
- else if (msg.pSender->GetName().Find(_T("lbtn_")) == 0 || msg.pSender->GetName().Find(_T("rbtn_")) == 0) //左右都有的按键
|
|
|
|
|
- {
|
|
|
|
|
- CDuiString strTemp = msg.pSender->GetName();
|
|
|
|
|
- strTemp = strTemp.Right(strTemp.GetLength() - 5);
|
|
|
|
|
- int iKey = _wtoi(strTemp.GetData());
|
|
|
|
|
- OnClickVK(iKey);
|
|
|
|
|
- }
|
|
|
|
|
- else if (msg.pSender->GetName().Find(_T("opt_shift")) == 0) //shift键
|
|
|
|
|
- {
|
|
|
|
|
- if (msg.pSender == m_pLShift)
|
|
|
|
|
- {
|
|
|
|
|
- if (m_pLShift->IsSelected())
|
|
|
|
|
- {
|
|
|
|
|
- m_pRShift->Selected(false);
|
|
|
|
|
- SwitchLetter(false);
|
|
|
|
|
- m_bShiftDown = false;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- m_pRShift->Selected(true);
|
|
|
|
|
- SwitchLetter(true);
|
|
|
|
|
- m_bShiftDown = true;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- if (m_pRShift->IsSelected())
|
|
|
|
|
- {
|
|
|
|
|
- m_pLShift->Selected(false);
|
|
|
|
|
- SwitchLetter(false);
|
|
|
|
|
- m_bShiftDown = false;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- m_pLShift->Selected(true);
|
|
|
|
|
- SwitchLetter(true);
|
|
|
|
|
- m_bShiftDown = true;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- else if (msg.pSender == m_pNum) //数字键
|
|
|
|
|
- {
|
|
|
|
|
- if (m_pNum->IsSelected())
|
|
|
|
|
- {
|
|
|
|
|
- m_pTabLayout->SelectItem(0);
|
|
|
|
|
- m_pCtrl->SetEnabled(true);
|
|
|
|
|
-
|
|
|
|
|
- m_pLShift->Selected(false);
|
|
|
|
|
- m_pRShift->Selected(false);
|
|
|
|
|
- SwitchLetter(false);
|
|
|
|
|
- m_bShiftDown = false;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- m_bShiftDown = false;
|
|
|
|
|
- m_pTabLayout->SelectItem(1);
|
|
|
|
|
- m_pLShift->Selected(true);
|
|
|
|
|
- m_pRShift->Selected(true);
|
|
|
|
|
- m_pLShift->SetEnabled(true);
|
|
|
|
|
- m_pRShift->SetEnabled(true);
|
|
|
|
|
- m_pCtrl->Selected(false);
|
|
|
|
|
- m_pCtrl->SetEnabled(false);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- else if (msg.pSender->GetName().Find(_T("symbol_")) == 0) //符号键
|
|
|
|
|
- {
|
|
|
|
|
- CDuiString strTemp = msg.pSender->GetName();
|
|
|
|
|
- strTemp = strTemp.Right(strTemp.GetLength() - 7);
|
|
|
|
|
- int iKey = _wtoi(strTemp.GetData());
|
|
|
|
|
- keybd_event(VK_SHIFT, 0, 0, 0);
|
|
|
|
|
- keybd_event(iKey, 0, 0, 0);
|
|
|
|
|
- keybd_event(iKey, 0, KEYEVENTF_KEYUP, 0);
|
|
|
|
|
- keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-LRESULT CVKWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
|
-{
|
|
|
|
|
- LONG styleValue = ::GetWindowLong(*this, GWL_EXSTYLE);
|
|
|
|
|
- styleValue &= ~WS_CAPTION;
|
|
|
|
|
- ::SetWindowLong(*this, GWL_EXSTYLE, styleValue | WS_EX_NOACTIVATE);
|
|
|
|
|
-
|
|
|
|
|
- SetWindowPos(*this, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
|
|
|
|
|
-
|
|
|
|
|
- m_pm.Init(m_hWnd);
|
|
|
|
|
- CDialogBuilder builder;
|
|
|
|
|
- CControlUI* pRoot = builder.Create(_T("virtual_keyboard.xml"), (UINT)0, NULL, &m_pm);
|
|
|
|
|
- ASSERT(pRoot && "Failed to parse XML");
|
|
|
|
|
- m_pm.AttachDialog(pRoot);
|
|
|
|
|
- m_pm.AddNotifier(this);
|
|
|
|
|
-
|
|
|
|
|
- Init();
|
|
|
|
|
-
|
|
|
|
|
- return 0;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-LRESULT CVKWnd::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
|
-{
|
|
|
|
|
- ::PostQuitMessage(0L);
|
|
|
|
|
-
|
|
|
|
|
- bHandled = FALSE;
|
|
|
|
|
- return 0;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-LRESULT CVKWnd::OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
|
-{
|
|
|
|
|
- if (::IsIconic(*this)) bHandled = FALSE;
|
|
|
|
|
- return (wParam == 0) ? TRUE : FALSE;
|
|
|
|
|
-}
|
|
|
|
|
-LRESULT CVKWnd::OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
|
-{
|
|
|
|
|
- return 0;
|
|
|
|
|
-}
|
|
|
|
|
-LRESULT CVKWnd::OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
|
-{
|
|
|
|
|
- return 0;
|
|
|
|
|
-}
|
|
|
|
|
-LRESULT CVKWnd::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
|
-{
|
|
|
|
|
- POINT pt; pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam);
|
|
|
|
|
- ::ScreenToClient(*this, &pt);
|
|
|
|
|
-
|
|
|
|
|
- RECT rcClient;
|
|
|
|
|
- ::GetClientRect(*this, &rcClient);
|
|
|
|
|
-
|
|
|
|
|
- RECT rcCaption = m_pm.GetCaptionRect();
|
|
|
|
|
- if (pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right \
|
|
|
|
|
- && pt.y >= rcCaption.top && pt.y < rcCaption.bottom)
|
|
|
|
|
- {
|
|
|
|
|
- CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(pt));
|
|
|
|
|
- if (pControl && _tcscmp(pControl->GetClass(), _T("ButtonUI")) != 0)
|
|
|
|
|
- return HTCAPTION;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return HTCLIENT;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-LRESULT CVKWnd::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
|
-{
|
|
|
|
|
- if (!IsIconic(*this))
|
|
|
|
|
- {
|
|
|
|
|
- RECT rcClient;
|
|
|
|
|
- GetClientRect(*this, &rcClient);
|
|
|
|
|
- HRGN hRgn = ::CreateRoundRectRgn(rcClient.left, rcClient.top, rcClient.right, rcClient.bottom, 3, 3);
|
|
|
|
|
- SetWindowRgn(*this, hRgn, TRUE);
|
|
|
|
|
- DeleteObject(hRgn);
|
|
|
|
|
- }
|
|
|
|
|
- bHandled = FALSE;
|
|
|
|
|
- return 0;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-LRESULT CVKWnd::OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
|
-{
|
|
|
|
|
- bHandled = FALSE;
|
|
|
|
|
- return 0;
|
|
|
|
|
-}
|
|
|
|
|
-LRESULT CVKWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
|
-{
|
|
|
|
|
- LRESULT lRes = 0;
|
|
|
|
|
- BOOL bHandled = TRUE;
|
|
|
|
|
- switch (uMsg)
|
|
|
|
|
- {
|
|
|
|
|
- case WM_CREATE: lRes = OnCreate(uMsg, wParam, lParam, bHandled); break;
|
|
|
|
|
- case WM_DESTROY: lRes = OnDestroy(uMsg, wParam, lParam, bHandled); break;
|
|
|
|
|
- case WM_NCACTIVATE: lRes = OnNcActivate(uMsg, wParam, lParam, bHandled); break;
|
|
|
|
|
- case WM_NCCALCSIZE: lRes = OnNcCalcSize(uMsg, wParam, lParam, bHandled); break;
|
|
|
|
|
- case WM_NCPAINT: lRes = OnNcPaint(uMsg, wParam, lParam, bHandled); break;
|
|
|
|
|
- case WM_NCHITTEST: lRes = OnNcHitTest(uMsg, wParam, lParam, bHandled); break;
|
|
|
|
|
- case WM_SIZE: lRes = OnSize(uMsg, wParam, lParam, bHandled); break;
|
|
|
|
|
- default:
|
|
|
|
|
- bHandled = FALSE;
|
|
|
|
|
- }
|
|
|
|
|
- SetCursor(LoadCursor(NULL, IDC_ARROW));
|
|
|
|
|
- if (bHandled)
|
|
|
|
|
- return lRes;
|
|
|
|
|
- if (m_pm.MessageHandler(uMsg, wParam, lParam, lRes))
|
|
|
|
|
- return lRes;
|
|
|
|
|
- return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-LRESULT CVKWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled)
|
|
|
|
|
-{
|
|
|
|
|
- if (uMsg == WM_KEYDOWN)
|
|
|
|
|
- {
|
|
|
|
|
- if (wParam == VK_RETURN)
|
|
|
|
|
- {
|
|
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
- else if (wParam == VK_ESCAPE)
|
|
|
|
|
- {
|
|
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return false;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-void CVKWnd::OnClickVK(int iKeyValue)
|
|
|
|
|
-{
|
|
|
|
|
- if (m_bCtrlDown && (iKeyValue == 65 || iKeyValue == 67 || iKeyValue == 86 || iKeyValue == 88 || iKeyValue == 90))
|
|
|
|
|
- {
|
|
|
|
|
- keybd_event(VK_CONTROL, 0, 0, 0);
|
|
|
|
|
- }
|
|
|
|
|
- if (m_bShiftDown)
|
|
|
|
|
- keybd_event(VK_SHIFT, 0, 0, 0);
|
|
|
|
|
- keybd_event(iKeyValue, 0, 0, 0);
|
|
|
|
|
- Sleep(50);
|
|
|
|
|
-
|
|
|
|
|
- keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
|
|
|
|
|
-
|
|
|
|
|
- m_pCtrl->Selected(false);
|
|
|
|
|
- m_bCtrlDown = false;
|
|
|
|
|
-}
|
|
|
|
|
-void CVKWnd::SwitchLetter(bool bUpper)
|
|
|
|
|
-{
|
|
|
|
|
-
|
|
|
|
|
-}
|
|
|