?? inputmethddlg.cpp
字號:
g_twostr = m_Resultstr.GetAt(1+ncount);
g_threestr = m_Resultstr.GetAt(2+ncount);
g_fourstr = m_Resultstr.GetAt(3+ncount);
g_fivestr = m_Resultstr.GetAt(4+ncount);
}
}
}
}
void CInputMethddlg::DisplayCharecter()
{
g_rightflag = 0;
if (1 == m_Resultstr.GetLength())
{
g_onestr = m_Resultstr.GetAt(0);
g_twostr = 0;
g_threestr = 0;//
g_fourstr = 0;
g_fivestr = 0;
}
else if (2 == m_Resultstr.GetLength())
{
g_onestr = m_Resultstr.GetAt(0);
g_twostr = m_Resultstr.GetAt(1);
g_threestr = 0;
g_fourstr = 0;
g_fivestr = 0;
}
else if (3 == m_Resultstr.GetLength())
{
g_onestr = m_Resultstr.GetAt(0);
g_twostr = m_Resultstr.GetAt(1);
g_threestr = m_Resultstr.GetAt(2);
g_fourstr = 0;
g_fivestr = 0;
}
else if (4 == m_Resultstr.GetLength())
{
g_onestr = m_Resultstr.GetAt(0);
g_twostr = m_Resultstr.GetAt(1);
g_threestr = m_Resultstr.GetAt(2);
g_fourstr = m_Resultstr.GetAt(3);
g_fivestr = 0;
}
else if (5 <= m_Resultstr.GetLength())
{
g_onestr = m_Resultstr.GetAt(0);
g_twostr = m_Resultstr.GetAt(1);
g_threestr = m_Resultstr.GetAt(2);
g_fourstr = m_Resultstr.GetAt(3);
g_fivestr = m_Resultstr.GetAt(4);
}
}
void CInputMethddlg::OnBtnBackSpace()
{
if (b_pinyinflag)
{
int len = m_letterstr.GetLength();
if (0 < len)
{
m_letterstr = m_letterstr.Left(len - 1); //減掉一位
InvalidateRect(&g_Inputbtn[INPUT_BTNRESULT].rectbtn, TRUE);
int templen = m_letterstr.GetLength();
if (templen > 0)
{
if ('a' == m_letterstr.GetAt(templen-1))
OnBtnLetA();
else if ('b' == m_letterstr.GetAt(templen-1))
OnBtnLetB();
else if ('c' == m_letterstr.GetAt(templen-1))
OnBtnLetC();
else if ('d' == m_letterstr.GetAt(templen-1))
OnBtnLetD();
else if ('e' == m_letterstr.GetAt(templen-1))
OnBtnLetE();
else if ('g' == m_letterstr.GetAt(templen-1))
OnBtnLetG();
else if ('i' == m_letterstr.GetAt(templen-1))
OnBtnLetI();
else if ('j' == m_letterstr.GetAt(templen-1))
OnBtnLetJ();
else if ('n' == m_letterstr.GetAt(templen-1))
OnBtnLetN();
else if ('o' == m_letterstr.GetAt(templen-1))
OnBtnLetO();
else if ('u' == m_letterstr.GetAt(templen-1))
OnBtnLetU();
else if ('v' == m_letterstr.GetAt(templen-1))
OnBtnLetV();
}
else if (0 == templen)
{
m_Resultstr.Empty();
g_rightflag = 0;
g_onestr = g_twostr = g_threestr = g_fourstr = g_fivestr = 0;
}
}
if (0 == len)
{
int textlen = m_TextResult.GetLength();
if (0 < textlen)
{
m_TextResult = m_TextResult.Left(textlen - 1);
if (NULL != pNotepaddlg)
pNotepaddlg->PostMessage(WM_INPUT_CHARACTER, 2, 0);
}
}
}
else
{
int len = m_TextResult.GetLength();
if (0 < len)
{
m_TextResult = m_TextResult.Left(len - 1);
if (NULL != pNotepaddlg)
pNotepaddlg->PostMessage(WM_INPUT_CHARACTER, 2, 0);
}
}
}
void CInputMethddlg::OnBtnEnter()
{
m_TextResult += '\r';
m_TextResult += '\n';
if (NULL != pNotepaddlg)
pNotepaddlg->PostMessage(WM_INPUT_CHARACTER, 1, 0);
}
void CInputMethddlg::OnBtnBlank()
{
m_TextResult += ' ';
if (NULL != pNotepaddlg)
pNotepaddlg->PostMessage(WM_INPUT_CHARACTER, 1, 0);
}
void CInputMethddlg::OnBtnPinyin()
{
b_pinyinflag = true;
m_Resultstr.Empty();
m_letterstr.Empty();
g_onestr = g_twostr = g_threestr = g_fourstr = g_fivestr = 0;
}
void CInputMethddlg::OnBtnLetA()
{
for (int i = 0; i < 29; i ++)
{
if (0 == wcscmp(g_pymba[i].letters, m_letterstr))
m_Resultstr = g_pymba[i].charactor;
}
DisplayCharecter();
}
void CInputMethddlg::OnBtnLetB()
{
if (0 == wcscmp(_T("b"), m_letterstr))
{
m_Resultstr = PINYIN_LETB_B;
}
DisplayCharecter();
}
void CInputMethddlg::OnBtnLetC()
{
if (0 == wcscmp(_T("c"), m_letterstr))
m_Resultstr = PINYIN_LETC_C;
DisplayCharecter();
}
void CInputMethddlg::OnBtnLetD()
{
}
void CInputMethddlg::OnBtnLetE()
{
for (int i = 0; i < 33; i ++)
{
if (0 == wcscmp(g_pymbe[i].letters, m_letterstr))
m_Resultstr = g_pymbe[i].charactor;
}
DisplayCharecter();
}
void CInputMethddlg::OnBtnLetG()
{
for (int i = 0; i < 77; i ++)
{
if (g_pymbg[i].letters == m_letterstr)
m_Resultstr = g_pymbg[i].charactor;
}
DisplayCharecter();
}
void CInputMethddlg::OnBtnLetI()
{
for (int i = 0; i < 68; i ++)
{
if (g_pymbi[i].letters == m_letterstr)
m_Resultstr = g_pymbi[i].charactor;
}
DisplayCharecter();
}
void CInputMethddlg::OnBtnLetJ()
{
if (0 == wcscmp(_T("j"), m_letterstr))
m_Resultstr = PINYIN_LETJ_J;
DisplayCharecter();
}
void CInputMethddlg::OnBtnLetN()
{
for (int i = 0; i < 91; i ++)
{
if (g_pymbn[i].letters == m_letterstr)
m_Resultstr = g_pymbn[i].charactor;
}
DisplayCharecter();
}
void CInputMethddlg::OnBtnLetO()
{
for (int i = 0; i < 48; i ++)
{
if (g_pymbo[i].letters == m_letterstr)
m_Resultstr = g_pymbo[i].charactor;
}
DisplayCharecter();
}
void CInputMethddlg::OnBtnLetU()
{
for (int i = 0; i < 47; i ++)
{
if (g_pymbu[i].letters == m_letterstr)
m_Resultstr = g_pymbu[i].charactor;
}
DisplayCharecter();
}
void CInputMethddlg::OnBtnLetV()
{
for (int i = 0; i < 2; i ++)
{
if (g_pymbv[i].letters == m_letterstr)
m_Resultstr = g_pymbv[i].charactor;
}
DisplayCharecter();
}
void CInputMethddlg::OnTextBtnOne()
{
if (0 != g_onestr)
{
m_TextResult += g_onestr;
if (pNotepaddlg != NULL)
pNotepaddlg->PostMessage(WM_INPUT_CHARACTER,1,0);
}
}
void CInputMethddlg::OnTextBtnTwo()
{
if (0 != g_twostr)
{
m_TextResult += g_twostr;
if (pNotepaddlg != NULL)
pNotepaddlg->PostMessage(WM_INPUT_CHARACTER,1,0);
}
}
void CInputMethddlg::OnTextBtnThree()
{
if (0 != g_threestr)
{
m_TextResult += g_threestr;
if (pNotepaddlg != NULL)
pNotepaddlg->PostMessage(WM_INPUT_CHARACTER,1,0);
}
}
void CInputMethddlg::OnTextBtnFour()
{
if (0 != g_fourstr)
{
m_TextResult += g_fourstr;
if (pNotepaddlg != NULL)
pNotepaddlg->PostMessage(WM_INPUT_CHARACTER,1,0);
}
}
void CInputMethddlg::OnTextBtnFive()
{
if (0 != g_fivestr)
{
m_TextResult += g_fivestr;
if (pNotepaddlg != NULL)
pNotepaddlg->PostMessage(WM_INPUT_CHARACTER,1,0);
}
}
BOOL CInputMethddlg::DestroyWindow()
{
// TODO: Add your specialized code here and/or call the base class
CharacterBar.DeleteObject();
LetterResultbmp.DeleteObject();
LetterSel.DeleteObject();
LetterUnsel.DeleteObject();
BigKeySel.DeleteObject();
BigKeyUnsel.DeleteObject();
MoveLeftSel.DeleteObject();
MoveLeftUnsel.DeleteObject();
MoveRightUnsel.DeleteObject();
MoveRightSel.DeleteObject();
SignSel.DeleteObject();
SignUnsel.DeleteObject();
bitmapback.DeleteObject();
m_TextResult.Empty();
m_TextResult = _T("");
return CDialog::DestroyWindow();
}
BOOL CInputMethddlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
// if (pMsg->message == WM_LBUTTONDBLCLK)
// pMsg->message = WM_LBUTTONDOWN;
return CDialog::PreTranslateMessage(pMsg);
}
void CInputMethddlg::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
int nID = GetBtnIDFromPoint(point);
if (nID >= 0 && nID < INPUT_BTNEND)
for (int i = 0; i < INPUT_BTNEND; i ++)
{
if (i == nID)
{
g_Inputbtn[i].nstatus = DOWN;
if (i == INPUT_BTNLEFT)
OnBtnMoveLeft();
else if (i == INPUT_BTNRIGHT)
OnBtnMoveRight();
else if (i == INPUT_BTNBACKSPACE)
{
KillTimer(1);
OnBtnBackSpace();
}
else if (i == INPUT_BTNENTER)
OnBtnEnter();
else if (i == INPUT_BTNONE)
OnTextBtnOne();
else if (i == INPUT_BTNTWO)
OnTextBtnTwo();
else if (i == INPUT_BTNTHREE)
OnTextBtnThree();
else if (i == INPUT_BTNFOUR)
OnTextBtnFour();
else if (i == INPUT_BTNFIVE)
OnTextBtnFive();
else if (i >= INPUT_BTNLETA && i <= INPUT_BTNLETZ)
{
if (0 == g_keyswitchflag)
{
char ch = 'a' + i - INPUT_BTNLETA;
if (b_pinyinflag)
{
m_letterstr += ch;
if (i == INPUT_BTNLETA)
OnBtnLetA();
else if (i == INPUT_BTNLETB)
OnBtnLetB();
else if (i == INPUT_BTNLETC)
OnBtnLetC();
else if (i == INPUT_BTNLETE)
OnBtnLetE();
else if (i == INPUT_BTNLETG)
OnBtnLetG();
else if (i == INPUT_BTNLETI)
OnBtnLetI();
else if (i == INPUT_BTNLETJ)
OnBtnLetJ();
else if (i == INPUT_BTNLETN)
OnBtnLetN();
else if (i == INPUT_BTNLETO)
OnBtnLetO();
else if (i == INPUT_BTNLETU)
OnBtnLetU();
else if (i == INPUT_BTNLETV)
OnBtnLetV();
}
else
m_TextResult += ch;
if (false == b_pinyinflag)
pNotepaddlg->PostMessage(WM_INPUT_CHARACTER,1,0);
}
else if (1 == g_keyswitchflag)
{
char ch = 'A' + i - INPUT_BTNLETA;
m_TextResult += ch;
pNotepaddlg->PostMessage(WM_INPUT_CHARACTER,1,0);
}
}
else if (i == INPUT_BTNSWITCH)
{
g_keyswitchflag ++;
if (2 == g_keyswitchflag)
g_keyswitchflag = 0;
}
else if (i == INPUT_BTNSIGN)
OnBtnSign();
else if (i == INPUT_BTNBLANK)
OnBtnBlank();
else if (i == INPUT_BTNMOVEWIN)
{
g_movewinflag ++;
if (2 == g_movewinflag)
g_movewinflag = 0;
if (1 == g_movewinflag)
SetWindowPos(&this->wndTop,0,0,480,130,0);
else
SetWindowPos(&this->wndTop,0,142,480,130,0);
}
else if (i == INPUT_BTNEXIT)
{
this->ShowWindow(SW_HIDE); //隱藏對話框
// PostMessage(WM_INPUT_CHARACTER,3,0); //刷新窗口
}
else if (i == INPUT_BTNPINYIN)
OnBtnPinyin();
}
else
g_Inputbtn[i].nstatus = UP;
InvalidateRect(&g_Inputbtn[i].rectbtn, TRUE);
}
CDialog::OnLButtonUp(nFlags, point);
}
void CInputMethddlg::PostNcDestroy()
{
// TODO: Add your specialized code here and/or call the base class
delete this;
CDialog::PostNcDestroy();
}
void CInputMethddlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
if (1 == nIDEvent)
{
OnBtnBackSpace();
}
CDialog::OnTimer(nIDEvent);
}
void CInputMethddlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
int i = GetBtnIDFromPoint(point);
if (i == INPUT_BTNBACKSPACE)
SetTimer(1, 100, NULL);
CDialog::OnLButtonDown(nFlags, point);
}
void CInputMethddlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
KillTimer(1);
int nID = GetBtnIDFromPoint(point);
for (int i = 0; i < INPUT_BTNEND; i ++)
{
if (i == nID)
{
g_Inputbtn[i].nstatus = DOWN;
}
else
g_Inputbtn[i].nstatus = UP;
InvalidateRect(&g_Inputbtn[i].rectbtn, TRUE);
}
CDialog::OnMouseMove(nFlags, point);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -