1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
procedure TFRGeneral.MNGeneralHotkeysUpdateClick(Sender: TObject);
var
i, j, k, CurrAutokey:integer;
Htkey :TShortCut;
HotKeyList:TStringList;
begin
HotKeyList:=TStringList.Create;
if TSGeneralHotkeys.Showing then
TSGeneralHotkeys.SetFocus;
with TSGeneralHotkeys do
begin
for j := 0 to ControlCount-1 do
if (Controls[j].ClassType = THotKey) then
begin
{ //not allow hotkeys for reserved functions
if (THotKey(Controls[j]).HotKey = CTRL_ALT_F5) or (THotKey(Controls[j]).HotKey = CTRL_ALT_F6) or
(THotKey(Controls[j]).HotKey = CTRL_ALT_F7) (*or (THotKey(Controls[j]).HotKey = CTRL_ALT_F10)*) then
THotKey(Controls[j]).HotKey :=0; }
if (THotKey(Controls[j]).HotKey = 0) then
THotKey(Controls[j]).Modifiers := [hkCtrl];
HotKeyList.Add(IntToStr(j)+'='+ShortCutToText(THotKey(Controls[j]).HotKey));
end;
for j:=0 to HotKeyList.Count-2 do
begin
if Length(Trim(HotKeyList.ValueFromIndex[j]))=0 then //if nthg entered, goto next hotkey ctrl
continue;
for k:=j+1 to HotKeyList.Count-1 do
begin
if Length(Trim(HotKeyList.ValueFromIndex[k]))=0 then
continue;
if (HotKeyList.ValueFromIndex[j] = HotKeyList.ValueFromIndex[k])and(HotKeyList.ValueFromIndex[j] <> '0') then
begin
MessageDlg(siLangGeneral.GetTextOrDefault('IDS_SELECT_HOTKEYS'(*'No two hotkeys can be identical!'*))+#13+#10+siLangGeneral.GetTextOrDefault('IDS_CHANGE_HOTKEYS'(*'Please change one of them.'*)), mtError, [mbOK], 0);
THotKey(Controls[StrToInt(HotKeyList.Names[k])]).Show;
THotKey(Controls[StrToInt(HotKeyList.Names[k])]).SetFocus;
exit;
end;
end;
end;
end;
if (CDTGeneralApplication.State in [dsEdit]) then
begin
DTGeneralApplication.ParamByName('UserNo').AsInteger := UserNo;
CDTGeneralApplication.FieldByName('USERGENERALHOTKEYS').AsString := 'Add=' +ShortCutToText(HKGeneralAdd.HotKey)+
';Edit=' +ShortCutToText(HKGeneralEdit.HotKey)+
';Update=' +ShortCutToText(HKGeneralUpdate.HotKey)+
';Delete=' +ShortCutToText(HKGeneralDelete.HotKey)+
';Cancel=' +ShortCutToText(HKGeneralCancel.HotKey)+
';Print=' +ShortCutToText(HKGeneralPrint.HotKey)+
';UserGroup=' +ShortCutToText(HKGeneralUserGroup.HotKey)+
';Components=' +ShortCutToText(HKGeneralComponents.HotKey)+
';Settings=' +ShortCutToText(HKGeneralSettings.HotKey)+
';Debug=' +ShortCutToText(HKGeneralDebug.HotKey);
CurrAutokey := CDTGeneralApplication.FieldByName('Autokey').AsInteger;
for i:=1 to FMPlanipro.Hotkeys.Count do
UnregisterHotKey(Handle,i);
if (HKGeneralPopup.HotKey <> CTRL_ALT_F5) and (HKGeneralPopup.HotKey <> CTRL_ALT_F6) and (HKGeneralPopup.HotKey <> CTRL_ALT_F7) {and (HKGeneralPopup.HotKey <> CTRL_ALT_F10)} then //reserved in Planipro
CDTGeneralApplication.FieldByName('USERGENERALHOTKEYS').AsString := CDTGeneralApplication.FieldByName('USERGENERALHOTKEYS').AsString + ';Popup=' +ShortCutToText(HKGeneralPopup.HotKey)
else
CDTGeneralApplication.FieldByName('USERGENERALHOTKEYS').AsString := CDTGeneralApplication.FieldByName('USERGENERALHOTKEYS').AsString + ';Popup=93';
CDTGeneralApplication.ApplyUpdates(0);
CDTGeneralApplication.Close;
DatasetOps(CDTGeneralApplication, '');
if CDTGeneralApplication.Locate('Autokey',CurrAutokey ,[]) then
begin
FMPlanipro.HotKeys.Clear;
FMPlanipro.HotKeys.Assign(AnsiSplitStrings(CDTGeneralApplication.fieldByName('USERGENERALHOTKEYS').AsString,';',nil));
for i:=0 to FMPlanipro.Hotkeys.Count-1 do
begin
Htkey := TextToShortCut(FMPlanipro.Hotkeys.ValueFromIndex[i]);
FMPlanipro.SetPlaniproHotKey(Htkey,i+1);
end;
end;
end;
EnableDisableHotkeys(MNGeneralHotkeysUpdate);
CHBMenu(MNGeneralHotkeysUpdate);
FreeAndNil(HotKeyList);
end; |
Partager