Главная страница | назад





Article #18032: Preventing changing pages in a page control

 Question and Answer Database

FAQ3032D.txt   :Preventing changing pages in a page control
Category   :VCL
Platform    :Win95/NT/98
Product    :All32Bit,   

Question:
How do I prevent the change of a page in a TPageControl?


Answer:
uses
  CommCtrl;

procedure TForm1.PageControl1Changing(Sender: TObject;
  var AllowChange: Boolean);
var
  Info : TTCHitTestInfo;
  P    : TPoint;
  idx  : Integer;
begin
  GetCursorPos(P);
  Info.pt := (Sender as TPageControl).ScreenToClient(P);
  Info.flags := TCHT_ONITEM;
  idx := SendMessage((Sender as TPageControl).Handle,TCM_HITTEST,0,Integer(@Info));
  Caption := 'idx = '+IntToStr(idx);
end;


// Of course, you'd set AllowChange to False given certain
// values of idx, instead of setting the Caption...


11/24/1998 3:14:45 PM
 

Last Modified: 01-SEP-99