Bonjour à tous
J'ai ajouté des touches 'hotkeys' à mon app de delphi, afin qu'un utilisateur puisse lui-meme les personalisées. Mais meme si les touches sont sauvées correctement dans la base de donné, avec le clavier elles ne marchent pas, à l'exception de deux, 'Settings' et 'Debug', qui sont dans les codes suivants:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
procedure TFRGeneral.DisplayHotkeys;
var
   i : integer;
   HotkeyList : TStringList;
begin
     HotkeyList := TStringList.Create;
     {set focus to tabsheet, otherwise the focused hotkeybox does not take the hkCtrl as modifier when cancel}
     if TSGeneralHotkeys.Showing then
        TSGeneralHotkeys.SetFocus;
     AnsiSplitStrings(CDTGeneralApplication.FieldByName('USERGENERALHOTKEYS').AsString,';',HotkeyList);
     for i := 0 to HotkeyList.Count-1 do
         begin
            //ShowMEssage(THotKey(Self.FindComponent('HKGeneral'+HotkeyList.Names[i])).Name+'='+HotkeyList.ValueFromIndex[i]);
            if ((HotkeyList.ValueFromIndex[i]) = '' ) then
               begin
                    THotKey(Self.FindComponent('HKGeneral'+HotkeyList.Names[i])).Modifiers :=[];
                    THotKey(Self.FindComponent('HKGeneral'+HotkeyList.Names[i])).Modifiers := [hkCtrl];
                    //THotKey(Self.FindComponent('HKGeneral'+HotkeyList.Names[i])).HotKey := TextToShortCut('CTRL');
                    if (HotkeyList.Names[i] = 'UserGroup') then
                       THotKey(Self.FindComponent('HKGeneral'+HotkeyList.Names[i])).HotKey := TextToShortCut('CTRL+ALT+F5');
                    if (HotkeyList.Names[i] = 'Components') then
                       THotKey(Self.FindComponent('HKGeneral'+HotkeyList.Names[i])).HotKey := TextToShortCut('CTRL+ALT+F6');
                    if (HotkeyList.Names[i] = 'Settings') then
                       THotKey(Self.FindComponent('HKGeneral'+HotkeyList.Names[i])).HotKey := TextToShortCut('CTRL+ALT+F7');
                    if (HotkeyList.Names[i] = 'Debug') then
                       THotKey(Self.FindComponent('HKGeneral'+HotkeyList.Names[i])).HotKey := TextToShortCut('CTRL+ALT+F10');
               end
            else
               THotKey(Self.FindComponent('HKGeneral'+HotkeyList.Names[i])).HotKey := TextToShortCut(HotkeyList.ValueFromIndex[i]);
         end;
 
     if  HotkeyList.Count = 0 then
         begin
              HKGeneralUserGroup.HotKey := TextToShortCut('CTRL+ALT+F5');
              HKGeneralComponents.HotKey := TextToShortCut('CTRL+ALT+F6');
              HKGeneralSettings.HotKey := TextToShortCut('CTRL+ALT+F7');
              HKGeneralDebug.HotKey := TextToShortCut('CTRL+ALT+F10');
         end;
 
     FreeAndNil(HotkeyList);
end;
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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;
Pour le 'Settings', c'est Ctrl+Alt+F7, et 'Debug', Ctrl+Alt+F10, c'est seulement ces deux qui marchent.
Quelqu'un peut m'aider svp?