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

42 Visitors Online


 
...handling accelerators on the tabs of a TPageControl?
Autor: P. Below
Homepage: http://www.teamb.com
[ Print tip ]  

Tip Rating (3):  
     


{
  With menus (and labels), If you use the '&' character in the caption of a menu,
  you can access that menu item with the short cut key.
  With this code you can do the same thing with TTabSheet objects
  that are used with TPageControl objects.

  Zugriffstasten ermöglichen die Ausführung eines Menübefehls mit Hilfe der Tastatur.
  Der Benutzer braucht nur die Taste Alt und den mit dem Zeichen & kombinierten
  Buchstaben zu drücken.

  Dieser code erlaubt dieselebe Funktionalität für ein
  TTabSheet eines TPageControls.
}

// in form declaration
private
  procedure 
CMDialogChar(var Msg: TWMCHAR); message CM_DIALOGCHAR;
end;
  
type
  
TPageControlCracker = class(TPageControl);

{...}

implementation

  procedure 
TForm1.CMDialogChar(var Msg: TWMCHAR);
  var
    
i: Integer;
  begin
    if 
(Msg.keydata and $20000000) <> 0 then
    begin
      
{ Alt key is down }
      
with TPageControlCracker(PageControl1) do
        for 
i := 0 to PageCount - 1 do
        begin
          if 
IsAccel(Msg.charcode, Pages[i].Caption) then
          begin
            if 
CanChange then
            begin
              
ActivePage := Pages[i];
              Msg.Result := 1;
              Change;
              Exit;
            end{ If }
          
end;  { If }
        
end{For}
    
end{If}
    
inherited;
  end;


 

Rate this tip:

poor
very good


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