本文整理汇总了C++中PRIMARYLANGID函数的典型用法代码示例。如果您正苦于以下问题:C++ PRIMARYLANGID函数的具体用法?C++ PRIMARYLANGID怎么用?C++ PRIMARYLANGID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PRIMARYLANGID函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: match_ctry_lang
/***
*BOOL match_ctry_lang - match country with language
*
*Purpose:
* ensure language and country match, choose proper values for language
* and country when matching, country ids converted to proper language id
*
*Entry:
* pwCtry - pointer to country id to match and set
* pwLang - pointer to language id to match and set
*
*Exit:
*
*Exceptions:
*
*******************************************************************************/
static BOOL match_ctry_lang(WORD *pwCtry, WORD *pwLang)
{
UINT i;
WORD wCtry = *pwCtry;
WORD wLang = *pwLang;
WORD wLangT;
/* only use base 10 two least significant digits */
wCtry = wCtry % 100;
if (wCtry > MAX_CTRY_NUM)
return FALSE;
/* see if any of the sublanguages for this country match*/
for (i = 0; i < MAX_LANG_PER_CTRY; i++)
{
if (!(wLangT = __rgrgwlang[wCtry][i]))
break;
if (PRIMARYLANGID(wLangT) == PRIMARYLANGID(wLang))
{
/* they match*/
if (!SUBLANGID(wLang))
/* don't override sublanguage*/
*pwLang = wLangT;
*pwCtry = wLangT;
return TRUE;
}
}
/* get the default language for this country*/
if (!(*pwCtry = __rgrgwlang[wCtry][0]))
/* bad country number*/
return FALSE;
return TRUE;
}
示例2: set_lang
int set_lang(void)
{
unsigned int lang_usr,lang_sys,id;
id=GetSystemDefaultLangID();
lang_sys=PRIMARYLANGID(id);
id=GetUserDefaultLangID();
lang_usr=PRIMARYLANGID(id);
if(lang_usr!=lang_sys) {
printf("warning: user language differs from system language\r\n\r\n");
printf("1. system : ");print_lang(lang_sys);
printf("2. user : ");print_lang(lang_usr);printf("Select(1-2): ");
id=getch();
if(id!=49&&id!=50) {
printf("wrong choice '%c', leaving.\r\n",id);
exit(0);
}
if(id==49) {
printf("system language\r\n");
return lang_sys;
}
else
printf("user language\r\n");
}
return lang_usr;
}
示例3: strSetCurKeyboard
void strSetCurKeyboard(void)
{
udword keyboard;
if (keyboard = GetKeyboardLayout(0))
{
if (PRIMARYLANGID(keyboard)==LANG_ENGLISH)
{
strCurKeyboardLanguage = languageEnglish;
}
else if (PRIMARYLANGID(keyboard)==LANG_FRENCH)
{
strCurKeyboardLanguage = languageFrench;
}
else if (PRIMARYLANGID(keyboard)==LANG_GERMAN)
{
strCurKeyboardLanguage = languageGerman;
}
else if (PRIMARYLANGID(keyboard)==LANG_SPANISH)
{
strCurKeyboardLanguage = languageSpanish;
}
else if (PRIMARYLANGID(keyboard)==LANG_ITALIAN)
{
strCurKeyboardLanguage = languageItalian;
}
}
else
strCurKeyboardLanguage = languageEnglish;
}
示例4: collection_c
language_c::language_c(char * setupLang, SystemDefault_c * SystemDefault) : collection_c() {
current = -1;
langDir = new char[MAX_PATH];
strcpy(langDir,SystemDefault->PrgPath);
strcat(langDir,"lang\\");
char * SerPath = new char[MAX_PATH];
strcpy(SerPath,langDir);
strcat(SerPath,"*.xml");
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
hFind = FindFirstFile(SerPath, &FindFileData);
if (hFind != INVALID_HANDLE_VALUE) {
LoadLanguageFile(FindFileData.cFileName);
while (FindNextFile(hFind,&FindFileData )) {
LoadLanguageFile(FindFileData.cFileName);
}
FindClose(hFind);
}
delete[] SerPath;
//////////////////////////////
// Detect Systemdefault
//////////////////////////////
// setup = aSetup;
int ConfigLang = hexToInt(setupLang);
current = getLangID(ConfigLang);
if (current == -1) {
int UserLang = GetUserDefaultUILanguage();
if (current == -1) {current = getLangID(UserLang);}
if (current == -1) {current = getLangIDMain(PRIMARYLANGID(UserLang));}
int SysLang = GetSystemDefaultUILanguage();
if (current == -1) {current = getLangID(SysLang);}
if (current == -1) {current = getLangIDMain(PRIMARYLANGID(SysLang));}
}
}
示例5: PRIMARYLANGID
void GHOST_ImeWin32::CreateImeWindow(HWND window_handle)
{
/**
* When a user disables TSF (Text Service Framework) and CUAS (Cicero
* Unaware Application Support), Chinese IMEs somehow ignore function calls
* to ::ImmSetCandidateWindow(), i.e. they do not move their candidate
* window to the position given as its parameters, and use the position
* of the current system caret instead, i.e. it uses ::GetCaretPos() to
* retrieve the position of their IME candidate window.
* Therefore, we create a temporary system caret for Chinese IMEs and use
* it during this input context.
* Since some third-party Japanese IME also uses ::GetCaretPos() to determine
* their window position, we also create a caret for Japanese IMEs.
*/
if (PRIMARYLANGID(input_language_id_) == LANG_CHINESE ||
PRIMARYLANGID(input_language_id_) == LANG_JAPANESE) {
if (!system_caret_) {
if (::CreateCaret(window_handle, NULL, 1, 1)) {
system_caret_ = true;
}
}
}
/* Restore the positions of the IME windows. */
UpdateImeWindow(window_handle);
}
示例6: LoadLibrary
bool Translations::SetLanguage(LanguageResource languageResource, bool showErrorMsg /*= true*/)
{
HMODULE hMod = nullptr;
bool success = false;
// Note that all messages should stay in English in that method!
// Try to load the resource dll if any
if (languageResource.dllPath) {
hMod = LoadLibrary(languageResource.dllPath);
if (hMod == nullptr) { // The dll failed to load for some reason
if (showErrorMsg) {
MessageBox(nullptr, _T("Error loading the chosen language.\n\nPlease reinstall MPC-HC."),
_T("MPC-HC"), MB_ICONWARNING | MB_OK);
}
} else { // Check if the version of the resource dll is correct
CString strSatVersion = FileVersionInfo::GetFileVersionStr(languageResource.dllPath);
CString strNeededVersion;
strNeededVersion.Format(_T("%u.%u.%u.0"), VersionInfo::GetMajorNumber(), VersionInfo::GetMinorNumber(), VersionInfo::GetPatchNumber());
if (strSatVersion == strNeededVersion) {
success = true;
} else { // The version wasn't correct
if (showErrorMsg) {
int sel = MessageBox(nullptr, _T("Your language pack will not work with this version.\n\nDo you want to visit the download page to get a full package including the translations?"),
_T("MPC-HC"), MB_ICONWARNING | MB_YESNO);
if (sel == IDYES) {
ShellExecute(nullptr, _T("open"), DOWNLOAD_URL, nullptr, nullptr, SW_SHOWDEFAULT);
}
}
// Free the loaded resource dll
FreeLibrary(hMod);
hMod = nullptr;
}
}
}
// In case no dll was loaded, load the English translation from the executable
if (hMod == nullptr) {
hMod = AfxGetApp()->m_hInstance;
// If a resource dll was supposed to be loaded we had an error
success = (languageResource.dllPath == nullptr);
}
// In case a dll was loaded, check if some special action is needed
else if (PRIMARYLANGID(languageResource.localeID) == LANG_ARABIC || PRIMARYLANGID(languageResource.localeID) == LANG_HEBREW) {
// Hebrew needs the RTL flag.
SetProcessDefaultLayout(LAYOUT_RTL);
SetWindowsHookEx(WH_CBT, RTLWindowsLayoutCbtFilterHook, nullptr, GetCurrentThreadId());
}
// Free the old resource if it was a dll
if (AfxGetResourceHandle() != AfxGetApp()->m_hInstance) {
FreeLibrary(AfxGetResourceHandle());
}
// Set the new resource
AfxSetResourceHandle(hMod);
return success;
}
示例7: switch
void GHOST_ImeWin32::MoveImeWindow(HWND window_handle, HIMC imm_context)
{
int x = caret_rect_.m_l;
int y = caret_rect_.m_t;
const int kCaretMargin = 1;
/**
* As written in a comment in GHOST_ImeWin32::CreateImeWindow(),
* Chinese IMEs ignore function calls to ::ImmSetCandidateWindow()
* when a user disables TSF (Text Service Framework) and CUAS (Cicero
* Unaware Application Support).
* On the other hand, when a user enables TSF and CUAS, Chinese IMEs
* ignore the position of the current system caret and uses the
* parameters given to ::ImmSetCandidateWindow() with its 'dwStyle'
* parameter CFS_CANDIDATEPOS.
* Therefore, we do not only call ::ImmSetCandidateWindow() but also
* set the positions of the temporary system caret if it exists.
*/
CANDIDATEFORM candidate_position = { 0, CFS_CANDIDATEPOS, { x, y },
{ 0, 0, 0, 0 } };
::ImmSetCandidateWindow(imm_context, &candidate_position);
if (system_caret_) {
switch (PRIMARYLANGID(input_language_id_)) {
case LANG_JAPANESE:
::SetCaretPos(x, y + caret_rect_.getHeight());
break;
default:
::SetCaretPos(x, y);
break;
}
}
if (PRIMARYLANGID(input_language_id_) == LANG_KOREAN) {
/**
* Chinese IMEs and Japanese IMEs require the upper-left corner of
* the caret to move the position of their candidate windows.
* On the other hand, Korean IMEs require the lower-left corner of the
* caret to move their candidate windows.
*/
y += kCaretMargin;
}
/**
* Japanese IMEs and Korean IMEs also use the rectangle given to
* ::ImmSetCandidateWindow() with its 'dwStyle' parameter CFS_EXCLUDE
* to move their candidate windows when a user disables TSF and CUAS.
* Therefore, we also set this parameter here.
*/
CANDIDATEFORM exclude_rectangle = { 0, CFS_EXCLUDE, { x, y },
{ x, y, x + caret_rect_.getWidth(), y + caret_rect_.getHeight() } };
::ImmSetCandidateWindow(imm_context, &exclude_rectangle);
}
示例8: LoadSatelliteDLL
/// <summary>
/// Loads the satellite DLL for the specified language from subdirectories
/// named with decimal LCID.
/// </summary>
/// <param name="langDesired">Desired language.</param>
/// <param name="lpszBaseDir">Directory with all the language subdirectories.</param>
/// <param name="lpszSatName">Name of the satellite DLL.</param>
/// <returns>Handle to the satellite DLL.</returns>
HMODULE LoadSatelliteDLL(LANGID langDesired, LPCTSTR lpszBaseDir, LPCTSTR lpszSatName)
{
TCHAR szSatellitePath[MAX_PATH];
TCHAR szBuffer[12];
HMODULE hMod;
// check string lengths
if (lstrlen(lpszBaseDir) + lstrlen(lpszSatName) + 15 <= MAX_PATH)
{
// try to load the library with the fully specified language
_itot(langDesired, szBuffer, 10);
wsprintf(szSatellitePath, _T("%s\\%s\\%s"), lpszBaseDir, szBuffer, lpszSatName);
hMod = LoadLibrary(szSatellitePath);
if (NULL != hMod)
{
return hMod;
}
else
{
// no luck, try the primary language ID
langDesired = PRIMARYLANGID(langDesired);
_itot(langDesired, szBuffer, 10);
wsprintf(szSatellitePath, _T("%s\\%s\\%s"), lpszBaseDir, szBuffer, lpszSatName);
hMod = LoadLibrary(szSatellitePath);
if (NULL != hMod)
{
return hMod;
}
}
}
return NULL;
}
示例9: InitCommon
void InitCommon(PLUGINDATA *pd)
{
bInitCommon=TRUE;
hInstanceDLL=pd->hInstanceDLL;
hMainWnd=pd->hMainWnd;
hWndEdit=pd->hWndEdit;
bOldWindows=pd->bOldWindows;
bAkelEdit=pd->bAkelEdit;
nMDI=pd->nMDI;
wLangModule=PRIMARYLANGID(pd->wLangModule);
hPopupEdit=GetSubMenu(pd->hPopupMenu, MENU_POPUP_EDIT);
//Initialize WideFunc.h header
WideInitialize();
//Plugin name
{
int i;
for (i=0; pd->wszFunction[i] != L':'; ++i)
wszPluginName[i]=pd->wszFunction[i];
wszPluginName[i]=L'\0';
}
xprintfW(wszPluginTitle, GetLangStringW(wLangModule, STRID_PLUGIN), wszPluginName);
xstrcpynW(wszCaptureSeparator, L"\n------------------------------------------------------------\n", MAX_PATH);
ReadOptions(OF_ALL);
}
示例10: lcid_to_rfc1766
static HRESULT lcid_to_rfc1766(LCID lcid, WCHAR *rfc1766, INT len)
{
WCHAR buffer[6 /* MAX_RFC1766_NAME */];
INT n = GetLocaleInfoW(lcid, LOCALE_SISO639LANGNAME, buffer, ARRAY_SIZE(buffer));
INT i;
if (n)
{
i = PRIMARYLANGID(lcid);
if ((((i == LANG_ENGLISH) || (i == LANG_CHINESE) || (i == LANG_ARABIC)) &&
(SUBLANGID(lcid) == SUBLANG_DEFAULT)) ||
(SUBLANGID(lcid) > SUBLANG_DEFAULT)) {
buffer[n - 1] = '-';
i = GetLocaleInfoW(lcid, LOCALE_SISO3166CTRYNAME, buffer + n, ARRAY_SIZE(buffer) - n);
if (!i)
buffer[n - 1] = '\0';
}
else
i = 0;
LCMapStringW(LOCALE_USER_DEFAULT, LCMAP_LOWERCASE, buffer, n + i, rfc1766, len);
return ((n + i) > len) ? E_INVALIDARG : S_OK;
}
return E_FAIL;
}
示例11: TaLocale_GuessBestLangID
LANGID TaLocale_GuessBestLangID (LANGID lang)
{
switch (PRIMARYLANGID(lang))
{
case LANG_KOREAN:
return MAKELANGID(LANG_KOREAN,SUBLANG_KOREAN);
case LANG_JAPANESE:
return MAKELANGID(LANG_JAPANESE,SUBLANG_DEFAULT);
case LANG_ENGLISH:
return MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US);
case LANG_CHINESE:
if (SUBLANGID(lang) != SUBLANG_CHINESE_TRADITIONAL)
return MAKELANGID(LANG_CHINESE,SUBLANG_CHINESE_SIMPLIFIED);
case LANG_GERMAN:
return MAKELANGID(LANG_GERMAN,SUBLANG_GERMAN);
case LANG_SPANISH:
return MAKELANGID(LANG_SPANISH,SUBLANG_SPANISH);
case LANG_PORTUGUESE:
return MAKELANGID(LANG_PORTUGUESE,SUBLANG_PORTUGUESE_BRAZILIAN);
}
return lang;
}
示例12: switch
HINSTANCE CMyAxLocCtrl::GetLocalizedResourceHandle(LCID lcid)
{
LPCTSTR lpszResDll;
HINSTANCE hResHandle = NULL;
switch (PRIMARYLANGID(lcid))
{
case LANG_ENGLISH:
lpszResDll = _T("myctlen.dll");
break;
case LANG_FRENCH:
lpszResDll = _T("myctlfr.dll");
break;
case LANG_GERMAN:
lpszResDll = _T("myctlde.dll");
break;
case 0:
default:
lpszResDll = NULL;
}
if (lpszResDll != NULL)
hResHandle = LoadLibrary(lpszResDll);
#ifndef _WIN32
if(hResHandle <= HINSTANCE_ERROR)
hResHandle = NULL;
#endif
return hResHandle;
}
开发者ID:terryjintry,项目名称:OLSource1,代码行数:32,代码来源:mfc-activex-controls--localizing-an-activex-control_3.cpp
示例13: FillLangListProc
static BOOL
FillLangListProc(UNUSED HANDLE module, UNUSED PTSTR type, UNUSED PTSTR stringId, WORD langId, LONG_PTR lParam)
{
langProcData *data = (langProcData*) lParam;
int index = ComboBox_AddString(data->languages, LangListEntry(IDS_LANGUAGE_NAME, langId));
ComboBox_SetItemData(data->languages, index, langId);
/* Select this item if it is the currently displayed language */
if (langId == data->language
|| (PRIMARYLANGID(langId) == PRIMARYLANGID(data->language)
&& ComboBox_GetCurSel(data->languages) == CB_ERR) )
ComboBox_SetCurSel(data->languages, index);
return TRUE;
}
示例14: getLocaleEntryIndex
/*
* binary-search our list of LANGID values. If we don't find the
* one we're looking for, mask out the country code and try again
* with just the primary language ID
*/
static int
getLocaleEntryIndex(LANGID langID)
{
int index = -1;
int tries = 0;
do {
int lo, hi, mid;
lo = 0;
hi = sizeof(langIDMap) / sizeof(LANGIDtoLocale);
while (index == -1 && lo < hi) {
mid = (lo + hi) / 2;
if (langIDMap[mid].langID == langID) {
index = mid;
} else if (langIDMap[mid].langID > langID) {
hi = mid;
} else {
lo = mid + 1;
}
}
langID = PRIMARYLANGID(langID);
++tries;
} while (index == -1 && tries < 2);
return index;
}
示例15: lcid_to_fl
static const int lcid_to_fl(LCID lcid, FL_Locale *rtn)
{
LANGID langid = LANGIDFROMLCID(lcid);
LANGID primary_lang = PRIMARYLANGID(langid);
LANGID sub_lang = SUBLANGID(langid);
int i;
// try to find an exact primary/sublanguage combo that we know about
for (i = 0; i < num_both_to_code; ++i)
{
if (both_to_code[i].id == langid)
{
accumulate_locstring(both_to_code[i].code, rtn);
return 1;
}
}
// fallback to just checking the primary language id
for (i = 0; i < num_primary_to_code; ++i)
{
if (primary_to_code[i].id == primary_lang)
{
accumulate_locstring(primary_to_code[i].code, rtn);
return 1;
}
}
return 0;
}