LPTSTR ChangeTextLayout(LPCTSTR ptszInText, HKL hklCurLay, HKL hklToLay, BOOL TwoWay) { LPTSTR ptszOutText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR)); _tcscpy(ptszOutText, ptszInText); if (hklCurLay == NULL || hklToLay == NULL) return ptszOutText; LPTSTR ptszKeybCur = GetLayoutString(hklCurLay); LPTSTR ptszKeybNext = GetLayoutString(hklToLay); if (ptszKeybCur == 0 || ptszKeybNext == 0) return ptszOutText; for (DWORD i = 0; i < _tcslen(ptszInText); i++) { BOOL Found = FALSE; for (DWORD j = 0; j < _tcslen(ptszKeybCur) && !Found; j++) if (ptszKeybCur[j] == ptszInText[i]) { Found = TRUE; if (_tcslen(ptszKeybNext) >= j) ptszOutText[i] = ptszKeybNext[j]; } if (TwoWay && !Found) for (DWORD j = 0; j < _tcslen(ptszKeybNext) && !Found; j++) if (ptszKeybNext[j] == ptszInText[i]) { Found = TRUE; if (_tcslen(ptszKeybCur) >= j) ptszOutText[i] = ptszKeybCur[j]; } } return ptszOutText; }
LPTSTR ChangeTextLayout(LPCTSTR ptszInText, HKL hklCurLay, HKL hklToLay, BOOL TwoWay) { LPTSTR ptszOutText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(wchar_t)); mir_wstrcpy(ptszOutText, ptszInText); if (hklCurLay == nullptr || hklToLay == nullptr) return ptszOutText; LPTSTR ptszKeybCur = GetLayoutString(hklCurLay); LPTSTR ptszKeybNext = GetLayoutString(hklToLay); if (ptszKeybCur == nullptr || ptszKeybNext == nullptr) return ptszOutText; for (DWORD i = 0; i < mir_wstrlen(ptszInText); i++) { BOOL Found = FALSE; for (DWORD j = 0; j < mir_wstrlen(ptszKeybCur) && !Found; j++) if (ptszKeybCur[j] == ptszInText[i]) { Found = TRUE; if (mir_wstrlen(ptszKeybNext) >= j) ptszOutText[i] = ptszKeybNext[j]; } if (TwoWay && !Found) for (DWORD j = 0; j < mir_wstrlen(ptszKeybNext) && !Found; j++) if (ptszKeybNext[j] == ptszInText[i]) { Found = TRUE; if (mir_wstrlen(ptszKeybCur) >= j) ptszOutText[i] = ptszKeybCur[j]; } } return ptszOutText; }