T
Ich will eine Undofunktion für Texteditor bauen.
Ich hab mir dafür jetzt ne eigene Key-String Funktion gebastelt.
Vielleicht kann die der eine oder andere auch mal brauchen.
AnsiString MyKeyToAnsi(Word Key, TShiftState Shift)
{
if(Key == 32) return " ";
if(Shift.Empty()){
AnsiString a1[48] ={"^","1","2","3","4","5","6","7","8","9","0","ß","´","q","w","e","r","t","z","u","i","o","p","ü","+","a","s","d","f","g","h","j","k","l","ö","ä","#","<","y","x","c","v","b","n","m",",",".","-"};
Word w1[48] ={220,49,50,51,52,53,54,55,56,57,48,219,221,81,87,69,82,84,90,85,73,79,80,186,187,65,83,68,70,71,72,74,75,76,192,222,191,226,89,88,67,86,66,78,77,188,190,189};
for(int x=0; x<48; x++)
if(w1[x] == Key)
return a1[x];
}
if(Shift.Contains( ssShift )){
AnsiString a2[48] ={"°","!","\"","§","$","%","&","/","(",")","=","?","`","Q","W","E","R","T","Z","U","I","O","P","Ü","*","A","S","D","F","G","H","J","K","L","Ö","Ä","'",">","Y","X","C","V","B","N","M",";",":","_"};
Word w2[48] ={220,49,50,51,52,53,54,55,56,57,48,219,221,81,87,69,82,84,90,85,73,79,80,186,187,65,83,68,70,71,72,74,75,76,192,222,191,226,89,88,67,86,66,78,77,188,190,189};
for(int x=0; x<48; x++)
if(w2[x] == Key)
return a2[x];
}
if(Shift.Contains( ssAlt )){
AnsiString a3[11] ={"²","³","{","[","]","}","\\","@","€","~","|"};
Word w3[11] ={50,51,55,56,57,48,219,81,69,187,226};
for(int x=0; x<11; x++)
if(w3[x] == Key)
return a3[x];
}
//Rückgabewerte sind nur zur Veranschaulichung
//Sollten für die persönlichen Bedürfnisse
//angepasst werden
if(Shift.Contains(ssCtrl)){
if(Key == 88) return "Ausschneiden";
if(Key == 67) return "Kopieren";
if(Key == 86) return "Einfügen";
}
if(Key == 13) return "\r\n";
if(Key == 8) return "Delete";
if(Key == 46) return "Entfernen";
if(Key == 36) return "Pos1";
if(Key == 35) return "Zeilen Ende";
if(Key == 33) return "Bild up";
if(Key == 34) return "Bild down";
if(Key == 38) return "Up Arrow";
if(Key == 37) return "Left Arrow";
if(Key == 39) return "Right Arrow";
if(Key == 40) return "Down Arrow";
/*Unrelevant zum editieren*/
//if(Key == 16) return "Umschalten";
//if(Key == 20) return "Umschalten groß";
//if(Key == 18) return "Alt";
//if(Key == 17) return "Steuerung";
//if(Key == 91) return "Windowstaste";
//if(Key == 45) return "Einfügen";
//if(Key == 144)return "Num";
//Die Rechnerseite der Tastatur
//Falls Num an ist
//Falls nicht werden weiter oben stehende
//Ergebnisse zurückgegeben
AnsiString a4[15] ={"0","1","2","3","4","5","6","7","8","9","/","*","-","+",","};
Word w4[15] ={96,97,98,99,100,101,102,103,104,105,111,106,109,107,110};
for(int x=0; x<15; x++)
if(w4[x] == Key)
return a4[x];
return "";
}
Viel spaß