Auteur
Origineel door Kainam, in deze draad
Omschrijving
Als je deze code koppelt aan een TApplicationEvents.OnMessage, dan wordt de punt op je numerieke toetsenbord altijd vertaald naar de DecimalSeparator zoals die op dat moment staat ingesteld.
Uses clause
Windows, Messages, System, SysUtils
Code
Zet de volgende code bij de implementatie van je TApplicationEvents.OnMessage Event Handler:
Code:
case Msg.Message of
// Catch the KeyDown and KeyUp events
WM_KEYDOWN, WM_KEYUP:
begin
// Check if the Decimal key is pressed, in combination with an active
// NumlockKey
if (Msg.wparam = VK_DECIMAL) and (Odd(GetKeyState(VK_NUMLOCK))) then
begin
// Alter the Message by replacing the Decimalkey with the Decimalseperator
Msg.wparam := Lobyte(VkKeyScan(DecimalSeparator));
// Virtual key of the decimal separator
Msg.lparam := MakeLParam(LoWord(msg.lparam),
(HiWord(Msg.lparam) and $FE00) + MapVirtualKey(Msg.wparam, 0));
end;
end;
end;
Bookmarks