Nov 10, 2011

HotKey em um formulário

O evento OnKeyPress, KeyDown ou qualquer outro do genero não será disparado se o foco estiver em qualquer outro controle, mesmo estando dentro do formulário,

Para adicionar uma hotkey em um formulário, simplismente sobreescreva o Método
"ProcessCmdKey" .


 protected override bool ProcessCmdKey(ref Message msg, Keys keyData)  
     {  
       switch (keyData)  
       {  
         case Keys.F5:  
           ExecutarMetodoF5();  
           return true;  
         case Keys.F9:  
           ExecutarMetodoF9();  
           return true;  
         case Keys.F10:  
           ExecutarMetodoF10();  
           return true;  
       }  
       return base.ProcessCmdKey(ref msg, keyData);  
     }  

Pronto, qualquer tecla pressionada no formulário será capturada.

1 comment:

  1. They could be simply integrated with existing 우리카지노 platforms to accommodate varieties of|several sorts of|various varieties of} shoppers from bookmakers to lotteries and from existing giant operations to newcomers. Let Netflix Roulette, the random film and TV show generator, decide from the Netflix catalog. Take a chance on something new with Netflix randomizer.Use extra thanNetflix?

    ReplyDelete