please tell me why this code is not working.
Code:// key_sample.cpp : Defines the entry point for the console application. // #include <stdafx.h> using namespace std; // Keyboard layout structure class _KeyboardLayout { public: HKL hBengali; bool bBengali; HKL hEnglish; bool bEnglish; _KeyboardLayout(); } ; _KeyboardLayout::_KeyboardLayout() { // setting default values (as not installed = false) bBengali=false; bEnglish=false; } int main() { _KeyboardLayout KeyboardLayout; // Get layout’s count TCHAR szKeyboard[KL_NAMELENGTH]; int nBuff=::GetKeyboardLayoutList(0, NULL); int nKeyboard; HKL * phkl; if((phkl = new HKL[nBuff])==NULL) { cout<<"Out of Memory !"; return 1; } // Get and parse layout items int x=::GetKeyboardLayoutList(nBuff,phkl); // iterate through list to check needed layouts for(nKeyboard=0; nKeyboard<nBuff; nKeyboard++) { ::ActivateKeyboardLayout(phkl[nKeyboard], KLF_SETFORPROCESS); GetKeyboardLayoutName(szKeyboard); if(wcscmp(szKeyboard,_T("00000445"))==0) { KeyboardLayout.bBengali=true; KeyboardLayout.hBengali=phkl[nKeyboard]; cout<<phkl[nKeyboard]; } if(wcscmp(szKeyboard,_T("00000409"))==0) { KeyboardLayout.bEnglish=true; KeyboardLayout.hEnglish=phkl[nKeyboard]; } } delete [] phkl; if(!KeyboardLayout.bBengali) cout<<"error in bengali layout"; //MessageBox(NULL,_T("Bengali keyboard layout not installed"),_T("Warning"),MB_OK|MB_ICONEXCLAMATION); if(!KeyboardLayout.bEnglish) MessageBox(NULL,_T("English (USA) keyboard layout not installed"),_T("Warning"),MB_OK|MB_ICONEXCLAMATION); else {} cout<<endl<<::LoadKeyboardLayoutW(_T("00000445"),KLF_ACTIVATE | KLF_SETFORPROCESS); if(KeyboardLayout.bBengali) { cout<<endl<<::ActivateKeyboardLayout(HKL(HKL_PREV), KLF_REORDER); //cout<<endl<<::ActivateKeyboardLayout(HKL(HKL_PREV), KLF_ACTIVATE); } //CString strLCID = _T("00000445"); //HKL hNewKeyboard = LoadKeyboardLayout(_T("00000445"),KLF_SUBSTITUTE_OK); //HKL hkl = ActivateKeyboardLayout(hNewKeyboard,0); //cout<<::PostMessage( NULL, WM_INPUTLANGCHANGEREQUEST, 1, 0x04450445 ); //cout<<endl<<GetLastError(); getchar(); getchar(); return 0; }



LinkBack URL
About LinkBacks


