Solved

Disabling TabbedNoteBook Tabs...

Posted on 1998-05-11
7
898 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 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

21 Experts available now in Live!

Get 1:1 Help Now