From db4de19878b106363a195c26d72e205985d680a5 Mon Sep 17 00:00:00 2001 From: craftwar Date: Tue, 10 Jul 2018 17:44:58 +0800 Subject: [PATCH] unicode2 --- Lite/AES.cpp | 4 ++-- Lite/AES.h | 3 ++- Lite/AnsiBar.cpp | 26 +++++++++++++------------- Lite/AppConfig.cpp | 2 +- Lite/AutoComplete.cpp | 2 +- Lite/AutoReplyPage.cpp | 42 +++++++++++++++++++++--------------------- Lite/AutoUpdate.cpp | 8 ++++---- Lite/StrUtils.cpp | 2 +- 8 files changed, 45 insertions(+), 44 deletions(-) diff --git a/Lite/AES.cpp b/Lite/AES.cpp index 792f09f..bad4120 100644 --- a/Lite/AES.cpp +++ b/Lite/AES.cpp @@ -24,8 +24,8 @@ CAES::~CAES() } - -void CAES::EnterPassword(CString passwd) +// ANSI hack, CStringA +void CAES::EnterPassword(CStringA passwd) { int len = (passwd.GetLength() / 16 + (passwd.GetLength() % 16 ? 1 : 0)) * 16; char pad[32]; diff --git a/Lite/AES.h b/Lite/AES.h index caa2d0c..1730eb1 100644 --- a/Lite/AES.h +++ b/Lite/AES.h @@ -15,7 +15,8 @@ class CAES : public CRijndael { public: - void EnterPassword(CString passwd); + // ANSI hack, CStringA + void EnterPassword(CStringA passwd); inline BOOL IsInitialized(){ return m_bInit; } CAES(); virtual ~CAES(); diff --git a/Lite/AnsiBar.cpp b/Lite/AnsiBar.cpp index f9b3507..971de9d 100644 --- a/Lite/AnsiBar.cpp +++ b/Lite/AnsiBar.cpp @@ -45,7 +45,7 @@ void CAnsiBar::OnBk() mnu.CreatePopupMenu(); for (int i = 10;i < 18;i++) { - mnu.AppendMenu(MF_OWNERDRAW, i, ""); + mnu.AppendMenu(MF_OWNERDRAW, i, TEXT("")); } CRect rc; ::GetWindowRect(::GetDlgItem(m_hWnd, IDC_ANSIBAR_BK), rc); @@ -67,7 +67,7 @@ void CAnsiBar::OnFg() mnu.CreatePopupMenu(); for (int i = 10;i < 26;i++) { - mnu.AppendMenu(MF_OWNERDRAW, i, ""); + mnu.AppendMenu(MF_OWNERDRAW, i, TEXT("")); } CRect rc; ::GetWindowRect(::GetDlgItem(m_hWnd, IDC_ANSIBAR_FG), rc); @@ -102,13 +102,13 @@ void CAnsiBar::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct) case IDC_ANSIBAR_SENDDROP: dc.DrawFrameControl(&lpDrawItemStruct->rcItem, DFC_SCROLL, DFCS_SCROLLDOWN | (lpDrawItemStruct->itemState&ODS_SELECTED ? DFCS_PUSHED : 0)); break; - default: //eIs + default: //前景背景按鈕 clr = AppConfig.colormap[(nIDCtl==IDC_ANSIBAR_FG?fg:bk)]; dc.FillSolidRect(&lpDrawItemStruct->rcItem, clr); if (GetRValue(clr) <= 128 && GetGValue(clr) <= 128 && GetBValue(clr) <= 128) txtclr = 0xffffff; dc.SetTextColor(txtclr); - char txt[5]; + TCHAR txt[5]; dc.DrawEdge(&lpDrawItemStruct->rcItem, lpDrawItemStruct->itemState&ODS_SELECTED ? EDGE_SUNKEN : EDGE_RAISED, BF_RECT); ::GetWindowText(lpDrawItemStruct->hwndItem, txt, 5); dc.DrawText(txt, 4, &lpDrawItemStruct->rcItem, DT_VCENTER | DT_CENTER | DT_SINGLELINE); @@ -171,13 +171,13 @@ void CAnsiBar::UpdateColor(UINT type) telnet->sel_start.y = tmp; } - if (telnet->sel_block || telnet->sel_start.y == telnet->sel_end.y) //pGϥΰ϶Υu + if (telnet->sel_block || telnet->sel_start.y == telnet->sel_end.y) //如果使用區塊選取或只選取單行 { for (int i = telnet->sel_start.y;i <= telnet->sel_end.y;i++) for (int p = telnet->sel_start.x;p < telnet->sel_end.x;p++) AddAttr(telnet->GetLineAttr(i)[p], type); } - else //ϥΰ϶ÿh + else //不使用區塊並選取多行 { int i, p; for (p = telnet->sel_start.x;p < telnet->site_settings.cols_per_page;p++) @@ -203,7 +203,7 @@ void CAnsiBar::UpdateColor(UINT type) void CAnsiBar::OnSend() { - Send(0); //榡 + Send(0); //全部格式 } void CAnsiBar::AddAttr(BYTE &attr, UINT type) @@ -247,13 +247,13 @@ void CAnsiBar::OnSendDropDown() UINT id = pop->TrackPopupMenu(TPM_LEFTALIGN | TPM_RETURNCMD, rc.left, rc.bottom, this); switch (id) { - case ID_SEND_RESETCLR: //eXm٭X + case ID_SEND_RESETCLR: //送出色彩還原碼 Send(4); break; - case ID_SEND_FG: //eXe + case ID_SEND_FG: //送出前景 Send(1); break; - case ID_SEND_BK: //eXI + case ID_SEND_BK: //送出背景 Send(2); break; } @@ -269,7 +269,7 @@ void CAnsiBar::Send(DWORD type) char tmp[4]; switch (type) { - case 1: //eXe + case 1: //送出前景 if (is_blink) escstr += "5;"; attr = fg; @@ -282,12 +282,12 @@ void CAnsiBar::Send(DWORD type) strcat(tmp, "m"); escstr += tmp; break; - case 2: //eXI + case 2: //送出背景 itoa(bk + 40, tmp, 10); strcat(tmp, "m"); escstr += tmp; break; - case 4: //eX٭X + case 4: //送出還原碼 escstr += "m"; break; default: diff --git a/Lite/AppConfig.cpp b/Lite/AppConfig.cpp index 3ecbb72..6e35142 100644 --- a/Lite/AppConfig.cpp +++ b/Lite/AppConfig.cpp @@ -116,7 +116,7 @@ CString GetIEPath() HKEY hk = NULL; // RegOpenKey( HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\IEXPLORE.EXE", &hk ); // RegQueryValue( hk, NULL, fpath.GetBuffer(_MAX_PATH), &len); - RegQueryValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\IEXPLORE.EXE", fpath.GetBuffer(_MAX_PATH), &len); + RegQueryValue(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\IEXPLORE.EXE"), fpath.GetBuffer(_MAX_PATH), &len); // RegCloseKey( hk ); fpath.ReleaseBuffer(); return fpath; diff --git a/Lite/AutoComplete.cpp b/Lite/AutoComplete.cpp index fc01012..5830621 100644 --- a/Lite/AutoComplete.cpp +++ b/Lite/AutoComplete.cpp @@ -277,7 +277,7 @@ int CAutoComplete::CompareItem(const void *p1, const void *p2) int r = item1->strstrpos - item2->strstrpos; if (0 != r) return r; - return strcmp(m_pOpenedList->m_pSrc->GetAt(item1->strpos), + return _tcscmp(m_pOpenedList->m_pSrc->GetAt(item1->strpos), m_pOpenedList->m_pSrc->GetAt(item2->strpos)); } diff --git a/Lite/AutoReplyPage.cpp b/Lite/AutoReplyPage.cpp index 6107f93..177bc68 100644 --- a/Lite/AutoReplyPage.cpp +++ b/Lite/AutoReplyPage.cpp @@ -74,8 +74,8 @@ void CAutoReplyPage::OnAdd() msg.SetWindowText(NULL); respond.SetWindowText(NULL); protect.SetCheck(FALSE); - first.SetWindowText("1"); - count.SetWindowText("1"); + first.SetWindowText(TEXT("1")); + count.SetWindowText(TEXT("1")); list.EnableWindow(FALSE); } @@ -170,7 +170,7 @@ BOOL CAutoReplyPage::OnInitDialog() void CAutoReplyPage::OnCancel() { - if (respond.IsWindowEnabled()) //٦bs説A + if (respond.IsWindowEnabled()) //還在編輯狀態 return; int c = list.GetCount(); @@ -197,20 +197,20 @@ void CAutoReplyPage::UpdateDisplay() msg.SetWindowText(item->msg); respond.SetPasswordChar(*LPCTSTR(item->respond) == '+' ? '*' : 0); CString tmp = LPCTSTR(item->respond) + 1; - tmp.Replace("^M^J", "\r\n"); - tmp.Replace("^M", "\r\n"); + tmp.Replace(TEXT("^M^J"), TEXT("\r\n")); + tmp.Replace(TEXT("^M"), TEXT("\r\n")); respond.SetWindowText(tmp); protect.SetCheck(*LPCTSTR(item->respond) == '+'); - char sfirst[8]; - itoa(item->first, sfirst, 10); + TCHAR sfirst[8]; + _itot(item->first, sfirst, 10); first.SetWindowText(sfirst); - char scount[8]; + TCHAR scount[8]; if (item->count == 0) count.SetWindowText(NULL); else { - itoa(item->count, scount, 10); + _itot(item->count, scount, 10); count.SetWindowText(scount); } } @@ -221,7 +221,7 @@ void CAutoReplyPage::OnSave() msg.GetWindowText(tmp); if (tmp.IsEmpty()) { - // ]wAJn۰ʦ^T! + // 設定不完整,必須輸入要自動回應的訊息! MessageBox(LoadString(IDS_INCOMPLETE_AUTO_SETTINGS) , NULL, MB_OK | MB_ICONSTOP); msg.SetFocus(); return; @@ -231,14 +231,14 @@ void CAutoReplyPage::OnSave() CTriggerItem* item; BOOL badd = (add.GetDlgCtrlID() == IDC_SAVE); int i; - if (badd) //sW + if (badd) //新增 { if (list.FindString(0, tmp) != LB_ERR) return; item = new CTriggerItem; item->pnext = NULL; } - else //ק + else //修改 { i = list.GetCurSel(); item = (CTriggerItem*)list.GetItemDataPtr(i); @@ -247,25 +247,25 @@ void CAutoReplyPage::OnSave() item->msg = tmp; respond.GetWindowText(tmp); - tmp.Replace("\r\n", "^M"); + tmp.Replace(TEXT("\r\n"), TEXT("^M")); item->respond = protect.GetCheck() ? "+" : "-"; item->respond += tmp; - char sfirst[8]; + TCHAR sfirst[8]; first.GetWindowText(sfirst, 8); - item->first = atoi(sfirst); + item->first = _tstoi(sfirst); if (item->first < 1) item->first = 1; - char scount[8]; + TCHAR scount[8]; count.GetWindowText(scount, 8); if (!*scount) item->count = 0; else - item->count = atoi(scount); + item->count = _tstoi(scount); - if (badd) //pGsW + if (badd) //如果新增 i = list.AddString(item->msg); - else //pGק + else //如果修改 { list.DeleteString(i); list.InsertString(i, item->msg); @@ -318,14 +318,14 @@ void CAutoReplyPage::EnableEdits(BOOL enable) void CAutoReplyPage::OnProtect() { - if (protect.GetCheck()) //pGOĿKXO@ + if (protect.GetCheck()) //如果是勾選密碼保護 { if (!AppConfig.QueryPassword(TRUE)) protect.SetCheck(0); else respond.SetPasswordChar('*'); } - else //pGOKXO@ + else //如果是取消密碼保護 { CPasswdDlg dlg; if (dlg.DoModal() == IDCANCEL) diff --git a/Lite/AutoUpdate.cpp b/Lite/AutoUpdate.cpp index c875a9a..db8a415 100644 --- a/Lite/AutoUpdate.cpp +++ b/Lite/AutoUpdate.cpp @@ -24,7 +24,7 @@ static char THIS_FILE[]=__FILE__; CAutoUpdater::CAutoUpdater() { // Initialize WinInet - hInternet = InternetOpen("AutoUpdateAgent", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); + hInternet = InternetOpen(TEXT("AutoUpdateAgent"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); } CAutoUpdater::~CAutoUpdater() @@ -144,7 +144,7 @@ CAutoUpdater::ErrorType CAutoUpdater::CheckForUpdate() // } MessageBox(AfxGetMainWnd()->m_hWnd, LoadString(IDS_INSTALL_UPDATE), LoadString(IDS_PCMAN_CLOSE), MB_ICONINFORMATION|MB_OK); - if (!::ShellExecute(AfxGetMainWnd()->m_hWnd, "open", updateFileLocation, NULL, NULL, + if (!::ShellExecute(AfxGetMainWnd()->m_hWnd, TEXT("open"), updateFileLocation, NULL, NULL, SW_SHOWNORMAL)) { return UpdateNotComplete; @@ -338,7 +338,7 @@ int CAutoUpdater::CompareVersions(CString ver1, CString ver2) { return -21; // Error in structure, too many parameters } - wVer1[i] = atoi(pToken); + wVer1[i] = _tstoi(pToken); pToken = strtok(NULL, _T(".")); i--; } @@ -358,7 +358,7 @@ int CAutoUpdater::CompareVersions(CString ver1, CString ver2) { return -22; // Error in structure, too many parameters } - wVer2[i] = atoi(pToken); + wVer2[i] = _tstoi(pToken); pToken = strtok(NULL, _T(".")); i--; } diff --git a/Lite/StrUtils.cpp b/Lite/StrUtils.cpp index fabddc5..5fd32c8 100644 --- a/Lite/StrUtils.cpp +++ b/Lite/StrUtils.cpp @@ -45,7 +45,7 @@ char* strnstri(const char* str, const char* sub, int len) int sl = strlen(sub); for (pstr = str; pstr <= pend - sl; pstr++) { - if (!strnicmp(pstr, sub, sl)) + if (!_tcsncicmp(pstr, sub, sl)) return (char*)pstr; } return NULL;