Mega Code Archive

 
Categories / Delphi / VCL
 

Preventing changing to a page in a page control

Question: How do I prevent a user from tabbing to a specific page in a page control? Answer: uses CommCtrl; procedure TForm1.PageControl1Changing(Sender: TObject; var AllowChange: Boolean); var Info : TTCHitTestInfo; Index : Integer; begin with Info do begin GetCursorPos(pt); pt := PageControl1.ScreenToClient(pt); flags := TCHT_ONITEM; end; Index := TabCtrl_HitTest(PageControl1.Handle,@Info); AllowChange := Index <> 2; // Or another test that makes sense end;