Board index » delphi » Preventing Changing to a page in a Page control Example

Preventing Changing to a page in a Page control Example

Hi all:

I have noticed several threads in this NG regarding the subject of
preventing the changing to a page in a page control, but unfortunately
none of them provide what I would call a clean solution.  The other
night I came across a Delphi FAQ (see below) on the Borland site that
appeared to provide the ideal solution to this problem.  However, on
close inspection, several items appeared very foriegn to me.  These
included: TTCHitTestInfo, TCHT_ONITEM, and TabCtrl_HitTest.  Upon
testing, it turned out they're foriegn to Delphi too!  Okay, I know I'm
not doing something right so can someone fill in the blanks.

TIA
Brian

uses
  CommCtrl;

procedure TForm1.PageControl1Changing(Sender: TObject;
 var AllowChange: Boolean);
var
  Info: TTCHitTestInfo;
  Index:Integer;
begin
  with Info do
     begin
       GetCursorPost(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

 

Re:Preventing Changing to a page in a Page control Example


Well, if you change GetCursorPost to GetCursorPos (hence remove the final
t ) it works in my test app! Note that it is important to include unit
CommCtrl not to be mixed with unit ComCtrls !!!

HTH

Sebastian Modersohn

Other Threads