Mega Code Archive

 
Categories / Delphi / VCL
 

Handling accelerators on the tabs of a TPageControl

Title: handling accelerators on the tabs of a TPageControl? { 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;