Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Key in ComboBox (https://www.delphipraxis.net/130008-key-combobox.html)

thomas2009 2. Mär 2009 13:28

Re: Key in ComboBox
 
Nun funktioniert :
Delphi-Quellcode:
//...
             if Combobox1.Items[Combobox1.ItemIndex] = 'F1' then begin key := vk_F1; end
        else if Combobox1.Items[Combobox1.ItemIndex] = 'F2' then begin key := vk_F2; end
        else if Combobox1.Items[Combobox1.ItemIndex] = 'F3' then begin key := vk_F3; end
        else if Combobox1.Items[Combobox1.ItemIndex] = 'F4' then begin key := vk_F4; end
        else if Combobox1.Items[Combobox1.ItemIndex] = 'F5' then begin key := vk_F5; end
        else if Combobox1.Items[Combobox1.ItemIndex] = 'F6' then begin key := vk_F6; end
        else if Combobox1.Items[Combobox1.ItemIndex] = 'F7' then begin key := vk_F7; end
        else if Combobox1.Items[Combobox1.ItemIndex] = 'F8' then begin key := vk_F8; end
        else if Combobox1.Items[Combobox1.ItemIndex] = 'F9' then begin key := vk_F9; end
        else if Combobox1.Items[Combobox1.ItemIndex] = 'F10' then begin key := vk_F10; end
        else if Combobox1.Items[Combobox1.ItemIndex] = 'F11' then begin key := vk_F11; end
        else if Combobox1.Items[Combobox1.ItemIndex] = 'F12' then begin key := vk_F12; end

        else if Combobox1.Items[Combobox1.ItemIndex] = 'RETURN' then begin key := VK_RETURN; end
        else if Combobox1.Items[Combobox1.ItemIndex] = 'SPACE' then begin key := VK_SPACE; end
// ...
        else if Combobox1.ItemIndex < 35 then begin

          key := Ord(Combobox1.Items[Combobox1.ItemIndex][1]); end;

jaenicke 2. Mär 2009 13:41

Re: Key in ComboBox
 
Das geht so viel einfacher, da werden die auch automatisch aufgelistet:
http://fhasovic.blogspot.com/2004/08...key-codes.html
Die entsprechenden Zahlenwerten kann man auch einfach als Objekt zu dem String einfügen statt sichtbar.
Und man kann natürlich auch nur die gewünschten Wertebereiche auflisten lassen.

thomas2009 2. Mär 2009 15:38

Re: Key in ComboBox
 
Nun habe ich noch ein Problem
Wenn ich die Hotkey als String in ini Datei speichern möchte, dann welchen Wert muss ich speichern?

Hotkey_id ?
wenn ja, wie kann ich zum Beispiel beim Programm-Start die Hotkey nach dem Laden von Ini-Datei registrieren ?

Delphi-Quellcode:
var
  IniFile1 : TIniFile;
  hotkey1: Integer;
begin

FName := ExtractFilePath(Application.ExeName) + 'test.ini';
IniFile1 := TIniFile.Create(FName);
hotkey1 := StrToInt(MyIniFile.ReadString('hotkeys','hotkey1',''));
RegisterHotKey( ???
...

IniFile1.free;

DeddyH 2. Mär 2009 15:44

Re: Key in ComboBox
 
Man hat Dich schon einmal gefragt, wieso Du den Hotkey als String speichern willst. Das macht doch keinen Sinn, da es sich um eine Zahl handelt.

thomas2009 2. Mär 2009 15:50

Re: Key in ComboBox
 
Zahl kann man in String konvertieren und dann in ini speichern
Beim laden von String in Integer wieder zurücksetzen. wo ist das Problem ?

Satty67 2. Mär 2009 15:51

Re: Key in ComboBox
 
Das verwirrt mich doch sehr:
Delphi-Quellcode:
hotkey1 := StrToInt(MyIniFile.ReadString('hotkeys','hotkey1',''));
warum nicht so?
Delphi-Quellcode:
hotkey1 := MyIniFile.ReadInteger('hotkeys','hotkey1',0);
Zitat:

Zitat von thomas2009
wo ist das Problem ?

In INIs kann man direkt Zahlen speichern, also warum die Umwandlung in einen String?

DeddyH 2. Mär 2009 15:56

Re: Key in ComboBox
 
Zitat:

Zitat von thomas2009
Nun habe ich noch ein Problem
Wenn ich die Hotkey als String in ini Datei speichern möchte, dann welchen Wert muss ich speichern?

Zitat:

Zitat von thomas2009
wo ist das Problem ?

Du widersprichst Dir selbst :mrgreen:

thomas2009 2. Mär 2009 20:10

Re: Key in ComboBox
 
Meine Frage ist :
Zitat:

Zitat von thomas2009
wie kann ich zum Beispiel beim Programm-Start die Hotkey nach dem Laden von Ini-Datei registrieren ?

Ich möchte also die in INI-Datei gespeicherte Hotkey, registrieren

mein Versuch hat nicht geklappt:
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
          Key : Word;
          Modifiers: UINT;
            FName: String;
  IniFile1 : TIniFile;
  hotkey1: Integer;
begin

FName := ExtractFilePath(Application.ExeName) + 'test.ini';
IniFile := TIniFile.Create(FName);
hotkey1 := StrToInt(MyIniFile.ReadString('hotkeys','hotkey1',''));
          Modifiers := 0;
          key := hotkey1;
          Hotkey_id := GlobalAddAtom('MyHotKey_1');
          RegisterHotKey(Handle, Hotkey_id, Modifiers, Key);
IniFile1.free;
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 08:07 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz