bool LocalizeMenuItem(TMenuItem* sControl,int Mode,IDCMapLocalStrings* Strs) { if(!Strs)Strs = g_pLocalStrings; dcmapWCSTR wstr; String Name = sControl->Name; if(Mode==0) { Strs->SelectSection("Menues"); int len = Name.Length(); Name.Delete(len-3,len); } if(!sControl->SubMenuImages) sControl->SubMenuImages = InterfaceModule->MenuImageList; wstr = Strs->GetSectionStringW(WideToString(Name).c_str()); if(wstr[0])sControl->Caption = wstr; wstr = Strs->GetSectionStringW(WideToString(Name+".Hint").c_str()); if(wstr[0])sControl->Hint = wstr; wstr = Strs->GetSectionStringW(WideToString(Name+".Shortcut").c_str()); if(wstr[0])sControl->ShortCut = TextToShortCut(wstr); wstr = Strs->GetSectionStringW(WideToString(Name+".Glyph").c_str()); if(wstr[0]) { sControl->ImageIndex = InterfaceModule->GetMenuImage(wstr); } return true; }
//--------------------------------------------------------------------------- TShortCut TTVPMainForm::GetHotKeyFromOption(TShortCut def, const tjs_char * optname) { tTJSVariant val; if(TVPGetCommandLine(optname, &val)) { TShortCut sc; ttstr str(val); if(str == TJS_W("")) { sc = (TShortCut)0; } else { sc = TextToShortCut(str.AsAnsiString()); if(sc == 0) TVPThrowExceptionMessage(TVPInvalidCommandLineParam, optname, str); } return sc; } return def; }
//--------------------------------------------------------------------------- bool TShortCuts::Load() { TStringList *list0=new TStringList; TStringList *list=new TStringList; try{ TIniFile *ini=new TIniFile(IniName); ini->ReadSectionValues(IniSect,list0); if(list0->Count) { int count=atoi(list0->Values["Count"].c_str()); for(int num=0;num<count;num++) { AnsiString pref=list0->Values[AnsiString("Name")+num]; AnsiString sc=list0->Values[AnsiString("ShortCut")+num]; if(pref.Length()&&sc.Length()) { list->Add(pref); list->Add(sc); } } list0->Clear(); } if(list->Count) { AnsiString error,nullstr; for(TShortCutOwner *sco=shortcutowners.begin().operator ->(),*endsco=shortcutowners.end().operator ->();sco<endsco;sco++) { AnsiString pref=sco->GetPrefixedStr(); int ind=list->IndexOf(pref); if(ind<0||ind>=list->Count-1) continue; AnsiString str=list->Strings[ind+1]; TShortCut sc=0; if(isdigit(*str.c_str())){ sc=atoi(str.c_str()); }else if(str!=noneStr) { try{ sc=TextToShortCut(str); }catch(...){} } list->Delete(ind); list->Delete(ind); if(!ChangeShortCut(sco,sc,error)) { ClearAllShortCuts(sc); ChangeShortCut(sco,sc,error); } } for(int i=0;i<list->Count;i+=2) { AnsiString pref=list->Strings[i]; AnsiString str=list->Strings[i+1]; TShortCut sc=0; if(isdigit(*str.c_str())){ sc=atoi(str.c_str()); }else if(str!=noneStr) { try{ sc=TextToShortCut(str); }catch(...){} } SetShortCut(sc,pref); } } delete ini; }catch(...){ delete list; delete list0; return false; } delete list; delete list0; return true; }