![]() |
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; |
Re: Key in ComboBox
Das geht so viel einfacher, da werden die auch automatisch aufgelistet:
![]() 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. |
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; |
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.
|
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 ? |
Re: Key in ComboBox
Das verwirrt mich doch sehr:
Delphi-Quellcode:
warum nicht so?
hotkey1 := StrToInt(MyIniFile.ReadString('hotkeys','hotkey1',''));
Delphi-Quellcode:
hotkey1 := MyIniFile.ReadInteger('hotkeys','hotkey1',0);
Zitat:
|
Re: Key in ComboBox
Zitat:
Zitat:
|
Re: Key in ComboBox
Meine Frage ist :
Zitat:
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. |
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