Solved

Disabling TabbedNoteBook Tabs...

Posted on 1998-05-11
7
899 Views
Last Modified: 2012-06-27
Hello, in my Delphi v3 app I have a TabbedNoteBook with 10 tabs. When I am in a certain one of these tabs, I wish to prevent the user from clicking on another tab. The only way he should be able to get to another tab is by pressing a specific button on the screen...not by clicking another tab. Therefore I essentially want to 'disable' the tabs when he is in this screen. I try 'TabbedNoteBook1.enabled:=false', but this not only disables the tabs, but disables every component within the tab the user is currently on - definitely not what I want. How can I just disable the tabs from being clicked but still leave the components enabled?

Cheers!
  Shawn Halfpenny
  drumme59@sprint.ca
0
Comment
Question by:aztec
7 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1344343
Hi aztec,

I think it's not possible... At least when I found out of this problem I didn't found a solution to it. But maybe somebody did... It's already a long time ago.

You should use pagecontrol which can handle this

Regards, ZiF.
0
 

Accepted Solution

by:
BigMadDrongo earned 50 total points
ID: 1344344
You need to monitor the changing event.  The tab index during the changing event is the previous tab.  What you need to do is define a global variable to store the starting tab, and in the onchange event, set the current tab to that.

E.G.

type
  MyForm(TForm)
    Tab: TTabControl
  end;

var
  MyTab: integer;
  Allowed: boolean;

procedure MyForm.TabChanging(Sender: TObject);
begin
  MyTab := Tab.TabIndex;
end;

procedure MyForm.TabChange(Sender: TObject);
begin
  if Allowed then
    exit;
  if Tab.TabIndex <> MyTab then
    Tab.TabIndex := MyTab;
end;

procedure MyForm.ButtonClick(Sender: TObject);
begin
  Allowed := True;
  Tab.TabIndex := Value;
  Allowed := False;
end;

This doesn't quite stop the users changing the tabs.  What it does do is detect the tab change and stores the initial tab.  Then it checks an allowed flag.  If this allowed flag is set to true (i.e. the change was caused by the button click) then the change happens, if the allowed flag is false, it changes the tab back to the original value.

If you want any furthur information, leave a comment.

BigMadDrongo
0
 
LVL 3

Expert Comment

by:d4jaj1
ID: 1344345
PageControl doesn't 'really' do what he wants either.  You CAN make a specific tab or page invisible using Page Control, however, you can't disable the tab, e.g., make the text light grey.  Maybe someone created a customer component to do this.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:itamar
ID: 1344346
Hi Aztec,

If you re-opens the question I know of a TabControl that does excatly what you want and more...

0
 
LVL 4

Expert Comment

by:itamar
ID: 1344347
Just forgot to say: it's shareware (about $40).
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1344348
Yep, there are customer components...
0
 

Author Comment

by:aztec
ID: 1344349
Works great...thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now