Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi UpperCase Problem (https://www.delphipraxis.net/112820-uppercase-problem.html)

Logic 27. Apr 2008 23:39


UpperCase Problem
 
Hallo,

mit der UpperCase-funktion mache ich ja bekannterweise aus klein geschriebenen Buchstaben, große ^^

Aber was ich gerne hätte, dass auch z.b. aus einem ß ein ? wird, also ne Art Shift-Tasten Funktion.

Kann mir da jemand weiterhelfen, ohne, dass ich selbst die Codes umwandeln muss?

Gruß
Logic

toms 28. Apr 2008 05:38

Re: UpperCase Problem
 
Hallo,

Das kannst du mit MapVirtualKey / ToAscii realisieren.
(funktioniert auch mit alt gr + ....)

Delphi-Quellcode:
function GetCharFromVirtualKey(Key: Word): string;
var
   KBDState: TKeyboardState;
   asciiRes: Byte;
begin
   GetKeyboardState(KBDState) ;
   SetLength(Result, 2) ;
   asciiRes := ToAscii(key, MapVirtualKey(key, 0), KBDState, @Result[1], 0) ;
   case asciiRes of
     0: Result := ''; // The specified virtual key has no translation for the current state of the keyboard.
     1: SetLength(Result, 1) ; // One Windows character was copied to the buffer.
     2:; // Two characters were copied to the buffer. This usually happens when a dead-key character (accent or diacritic) stored in the keyboard layout cannot be composed with the specified virtual key to form a single character.
   end;
end;

procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  Caption := GetCharFromVirtualKey(Key) ;
end;

mkinzler 28. Apr 2008 05:39

Re: UpperCase Problem
 
Da wirst du wohl nicht herumkommen.


Alle Zeitangaben in WEZ +1. Es ist jetzt 04:06 Uhr.

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