1. Steen Jakobsen
  2. PowerBuilder
  3. Saturday, 14 May 2022 04:25 AM UTC

Hi everyone,

 

How can I place a close button on each tabpage (or the selected tab) in a tabcontrol. Just like the tabs in a browser and many applications.

I know this is a classic question and a feature request for many many years. I just need it badly now.

Maybe finding the x,y of the active tabpage and dynamically place a control at the end.. I just have no clue on how to find the x,y,width of the tab.

 

Any clue is most appreciated.

//Steen :-)

 

ps. This is a standard feature in VS since 2005  .. I'm very happy with Appeons deliveries I just need this

pps. The pbultimatesuite  is an absolute no-go 

Accepted Answer
Steen Jakobsen Accepted Answer Pending Moderation
  1. Friday, 27 May 2022 11:31 AM UTC
  2. PowerBuilder
  3. # Permalink
Hi John .. this is how I do it today. Thank you.
Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 26 May 2022 04:53 AM UTC
  2. PowerBuilder
  3. # 1

I continue to be blown away by the solutions that Roland comes up with... Nicely done, Roland! As soon as I saw it, I immediately had to dig into his code to learn how it was done, and of course, I learned a lot in the process. The PB Community benefits greatly from your numerous contributions, Roland. Thank you!

My geeky side wanted to see what it would take to extend Roland's proof-of-concept with some additional capabilities:

  • Support alternate tab position settings in addition to TabsOnTop.
  • Support multi-line tabs.
  • Support tabs that utilize perpendicular text.
  • Automatically disable the Tax X "button" when only one tab remains and enable it when more than one tab exists.
  • Tweak the user interface to integrate better when the tab page navigation (left/right) control appears.
  • Add a tooltip for the Tab X "button".
  • Ensures proper operation in 64-bit.

This took several evenings of experimentation. I've attached below an "enhanced" version of the original sample app & objects that accomplishes all of the above. Here are a couple of screen shots:

I had to reduce the size of the "X" slightly in order to make it fit.

For some time now, PB has provided tooltip support in DataWindows. However, I needed a tooltip that worked with a static text control. I started with a version of a non-visual tooltip object created by Aart Onkenhout (Thank you, Aart!) around 2005 and updated his code to use Unicode Windows API calls instead of ANSI as it was originally coded many years ago, and also got it to work in 64-bit.

The command buttons you see make it easy to "load up" the tab control with additional tab pages for testing and also manage the tooltip functionality.

Enjoy!

Attachments (1)
Comment
  1. Steen Jakobsen
  2. Friday, 27 May 2022 06:19 AM UTC
Nice work John :-)

And yes Roland is a GREAT inspiration.
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Friday, 20 May 2022 18:04 PM UTC
  2. PowerBuilder
  3. # 2

My 2cts here is that - once we get tabbed windows - the best thing to do, is get away completely from tab controls. They behave funny, have bugs and just try doing a setredraw(false) of a tab and see how that doesn't do anything to controls inside of it.

Of course that's going to be a lot of refactoring, but it might be worth it.

regards,

MiguelL

Comment
  1. Steen Jakobsen
  2. Saturday, 21 May 2022 04:17 AM UTC
Yes... a completely missing feature ...I wonder why Appeon and forgotten it now that they have taken PB to the next level .. just without tabcontrols.

  1. Helpful
  1. Roland Smith
  2. Thursday, 26 May 2022 12:31 PM UTC
The PB tab control is based on the Windows 'Win32 Tab Control' which hasn't changed in over 20 years.

https://docs.microsoft.com/en-us/windows/win32/controls/tab-controls
  1. Helpful 1
  1. Steen Jakobsen
  2. Friday, 27 May 2022 06:21 AM UTC
I really hope that Appeon is reading also.. I do think it is time for an update to the tab-control.



Appeon, any comment ?
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Friday, 20 May 2022 15:44 PM UTC
  2. PowerBuilder
  3. # 3

The attached picture and PB 2019 app has an X button that is located in the upper right corner of the tab control.

When you move the mouse over it, the background color changes. Click it to delete the current tab. When the tab control resizes with the window, the X button automatically stays in the correct position.

I used the SetParent Windows API function to make the parent of the X button (really a statictext object) be the tab control. That makes the upper left corner of the tab control the 0,0 position.

It isn't possible to add a control to the tab buttons themselves. You could use tab pictures but you couldn't determine if the clicked event was due to the picture being clicked.

Attachments (2)
Comment
  1. Steen Jakobsen
  2. Friday, 20 May 2022 15:46 PM UTC
Thanks Roland :-)
  1. Helpful
  1. Steen Jakobsen
  2. Saturday, 21 May 2022 04:18 AM UTC
I just want to express that I'm grateful for your work Roland.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Saturday, 21 May 2022 12:30 PM UTC
Hi Steven ... I agree!

I think that we need to start a collection & then send Roland some more Mountain Dew. ;-)
  1. Helpful 1
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Wednesday, 18 May 2022 14:28 PM UTC
  2. PowerBuilder
  3. # 4

I know you're frustrated, Steen.

Are you willing to consider an alternative UI that provides identical functionality?

As a quick test, I added the same, small Static Text control to each of three tab pages as shown below:

It's a red uppercase T in 12 point Webdings2, in case anyone is interested in those details.

In the clicked event of each of these, I called a window function:

// Ask the window to close the parent tab page of this static text control.
of_CloseTab(Parent)

Here's the window's of_CloseTab object function:

Integer li_index, li_num_tabpages
UserObject luo_tabpage

// A valid reference to the tab page user object to be closed is required.
If Not IsValid(auo_tabpage) Then Return -1

li_num_tabpages = UpperBound(tab_1.Control)

// We cannot (should not) close the tab if it is the only one.
If li_num_tabpages < 2 Then
   MessageBox("Close Tab Request","Unable to close this tab, as it is the only one.",Exclamation!,OK!)
   Return -1
End If

// Find the requested tab page in the tab control's Control array.
For li_index = 1 To li_num_tabpages
   // Cast tab page reference to a user object.
   luo_tabpage = tab_1.Control[li_index]
   
   If luo_tabpage <> auo_tabpage Then Continue
   
   // Found the requested tab page. Close it.
   tab_1.CloseTab(luo_tabpage)
   
   // Did we just close the last tab page?
   li_num_tabpages = UpperBound(tab_1.Control)
   If li_index <= li_num_tabpages Then
      // No - Select the tab page that was after the one that was closed.
      tab_1.SelectTab(li_index)
   Else
      // Yes - Select the tab page that preceded the one that was closed.
      tab_1.SelectTab(li_num_tabpages)
   End If
   
   // Success.
   Return 1
Next

// No action taken.
Return 0

Of course, you can make this much more rugged/sophisticated, check for unsaved data, etc., but here I just wanted to make the close tab functionality work... and it does. Click on the red "X", and...

If you have an ancestor tab page user object, it would be easier to implement (not that what I've done is difficult).

I think it's pretty obvious you're not going to be able to do what you're wanting in the exact manner you've expressed, so it may be time to move on and come up with a reasonable alternative. Maybe not what I've proposed, but something that does what you need it to do.

Best regards, John

Comment
  1. John Fauss
  2. Thursday, 19 May 2022 03:44 AM UTC
That's good to know, Roland. Thank you for passing that information along. I threw the above example together in about 30 minutes last night, so I wasn't concerned with faithfully reproducing the look and feel of existing apps... I'll file this away for future use.
  1. Helpful 1
  1. Steen Jakobsen
  2. Thursday, 19 May 2022 04:34 AM UTC
Hi Roland,

Sounds absolutely great.. I really hope you will be able to pull this off. If think many of us will be very grateful :-)
  1. Helpful
  1. Steen Jakobsen
  2. Thursday, 19 May 2022 07:20 AM UTC
Roland,

How do I get the correct x,y of the tab control page to put the X control ? and what happens when the tab pages are scrolled horizontally, an event ?
  1. Helpful
There are no comments made yet.
Mark Goldsmith Accepted Answer Pending Moderation
  1. Tuesday, 17 May 2022 20:15 PM UTC
  2. PowerBuilder
  3. # 5

Hi Steen,

I have some thoughts on how you might be able to accomplish this in the interim but have a few questions first:


How many tabs are you likely to have opened by the user? Is it unlimited?
Are there pictures currently on the tabs?
Are you okay with having the tabs being fixed width?
Are you okay with NOT having RaggedRight, Perpendicular text or Multiline (may be able to work around Multiline)?
Are you okay with the text of the tabs being right justified?

This may go nowhere if any of the above constraints are deal breakers for you. If not, while the look and feel may not be exactly what you want it may be sufficient/ acceptable given how much you seem to need this at the moment and until Appeon makes this functionality available.

Regards,

Mark

Comment
  1. Steen Jakobsen
  2. Wednesday, 18 May 2022 11:52 AM UTC
Hi Mark,



I really appreciate your help. But the implementation needs many of the features your approach will not support.

So basically the only way is to spend 1800 USD on a tab control if I want to be able to close a tab-page.

I find it very annoying not to be able to close a tab page since it is standard behaviour of most languages except PB and expected feature in many applications.

(Imagine a web browser that was unable to close at tab page! I dont think it would survive very long)



I'm very happy with Appeon, That being said, In my view, It is clearly a mistake on Appeon roadmap not to make the X button that many many of us needs and referring to a new feature some 1.5 - 2 years away go spend 1800 USD to get it.





  1. Helpful
  1. Mark Goldsmith
  2. Wednesday, 18 May 2022 13:41 PM UTC
You're welcome Steen and I can appreciate your frustration...that's a high price to pay just for that piece of functionality. If you have a change of heart just let me know.
  1. Helpful 2
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Tuesday, 17 May 2022 07:57 AM UTC
  2. PowerBuilder
  3. # 6

Brad Wery has implemented that. It's available in Ultimate Suite for PB. Of course it's not free...

The above screenshot is from NotepadPB.

A modern tab control was available in Advanced Gui. But it is missing the close button as you want it.

By the way, Roland Smith and Brad Wery did contributed to advanced gui sample. The close tab is implemented only as a "global" close button on the right...

Andreas.

Comment
  1. Roland Smith
  2. Wednesday, 18 May 2022 03:48 AM UTC
The image I posted earlier was from one of my apps that uses PB Ultimate Suite. The one with the red X is a really early version.
  1. Helpful 1
  1. Andreas Mykonios
  2. Wednesday, 18 May 2022 04:11 AM UTC
Qwerybuilder was using those exact tab controls. Unfortunately when I decided to buy qwerybuilder I left powertothebuilder controls for later... And then the price changed...
  1. Helpful
There are no comments made yet.
Steen Jakobsen Accepted Answer Pending Moderation
  1. Tuesday, 17 May 2022 04:53 AM UTC
  2. PowerBuilder
  3. # 7

.. So there is no solution to get a modern tab control i guess. 

Comment
  1. John Fauss
  2. Tuesday, 17 May 2022 05:34 AM UTC
You could create your own and share it with the Community.

A user-drawn "simulated" tab control with tab pages was the norm prior to the actual tab control being added to PB in version 5, as Chris alluded to. It worked pretty well, especially since there was no alternative. I'm not saying it's easy, but it's doable. You might even be able to find an old implementation posted on the web to help you get jump-started.
  1. Helpful
  1. Steen Jakobsen
  2. Tuesday, 17 May 2022 05:43 AM UTC
Yes. But I really think PB should provide a modern tab-control. It seems odd that one have to create such a basic thing from scratch or pay 1800 usd extra to get it.



PB does so many things and Appeon is doing GREAT job enhancing PB. But it seems that this one have been forgotten.



Please Appeon .. :-)
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Sunday, 15 May 2022 01:56 AM UTC
  2. PowerBuilder
  3. # 8

Something like the attached.

Attachments (1)
Comment
  1. Steen Jakobsen
  2. Sunday, 15 May 2022 06:19 AM UTC
Yes :-)

I guss many people are wanr it. Very simple.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Sunday, 15 May 2022 13:49 PM UTC
Hi Roland ... Yes, and a new modern tab page look would be nice as well. ;-)
  1. Helpful 1
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Saturday, 14 May 2022 16:42 PM UTC
  2. PowerBuilder
  3. # 9

Hi Steven;

   The way I did this back in the PB 3.0-4.0 days in the early days of my framework was to write my own Visual User Object as a Tab Control / Tab Page combination where I could control the GUI 100% (including the X button on the TP).

  Your right.. this feature has been requested since way back in the PowerSoft days.

Regards ... Chris

Comment
  1. John Fauss
  2. Tuesday, 17 May 2022 05:39 AM UTC
Do you still have a copy in your archives you could blow the bit-dust off of, Chris? Granted, it's not the solution that Steen is wanting, but a possible solution to a problem is better than NO solution.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Tuesday, 17 May 2022 12:37 PM UTC
Hi John... No, unfortunately. I removed the UO's after PB 5.0 was released as PB 5.x now had it's own built-in TC/TP.

Regards .. Chris
  1. Helpful
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Saturday, 14 May 2022 15:52 PM UTC
  2. PowerBuilder
  3. # 10

Hi Steen, It is on our roadmap to add a tabbed document interface in the revisions of PB 2022, but for now you would need to do a workaround.

Comment
  1. Armeen Mazda @Appeon
  2. Sunday, 15 May 2022 02:49 AM UTC
Yes, what he wants is on our roadmap for revision of PB 2022.
  1. Helpful
  1. Steen Jakobsen
  2. Sunday, 15 May 2022 06:23 AM UTC
Armeen,



My request is shared by many people who have to buy a ton of useless controls to get that one little X on the tab control tages.

It seems a little thing but in many applications it is a BIG thing. Imagine a browser without the ability to close a tab - that browser would not make it in the competition.



Please add the little X to that ab control pages :-)



About the tabbed MDI. There are several good workarounds for that
  1. Helpful
  1. Steen Jakobsen
  2. Monday, 30 May 2022 06:13 AM UTC
Hi Armeen,



Do you have any plans for enhancing the tab-control to match modern requirements ?

(The implementation in pb is 20 years old)



Thanks
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.