whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

159 Visitors Online


 
...Operate the numeric keypad always as if NumLock is engaged?
Autor: P. Below
Homepage: http://www.teamb.com
[ Print tip ]  

Tip Rating (4):  
     


procedure TForm1.AppOnMessage(var Msg: TMsg; var Handled: Boolean);
var
  
ccode: Word;
begin
  case 
Msg.Message of
    
WM_KEYDOWN, WM_KEYUP:
      begin
        if 
(GetKeyState(VK_NUMLOCK) >= 0)  {NumLock not active} and
          
((Msg.lParam and $1000000) = 0)  {not a gray key} then
        begin
          
ccode := 0;
          case Msg.wParam of
            
VK_HOME: ccode   := VK_NUMPAD7;
            VK_UP: ccode     := VK_NUMPAD8;
            VK_PRIOR: ccode  := VK_NUMPAD9;
            VK_LEFT: ccode   := VK_NUMPAD4;
            VK_CLEAR: ccode  := VK_NUMPAD5;
            VK_RIGHT: ccode  := VK_NUMPAD6;
            VK_END: ccode    := VK_NUMPAD1;
            VK_DOWN: ccode   := VK_NUMPAD2;
            VK_NEXT: ccode   := VK_NUMPAD3;
            VK_INSERT: ccode := VK_NUMPAD0;
            VK_DELETE: ccode := VK_DECIMAL;
          end{Case}
          
if ccode <> 0 then
            
Msg.wParam := ccode;
        end{If}
      
end{Case Msg.Message}
  
end{Case}
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  
Application.OnMessage := AppOnMessage;
end;


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners