Solved

Disabling TabbedNoteBook Tabs...

Posted on 1998-05-11
7
902 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi XE10, MySQL Query 4 143
drawing animated level bar based on numbers 3 97
Convert a string into a TDateTime 5 60
Controlled Assessment GCSE - desperate help needed 4 84
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 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