Recent

Author Topic: TPageControl and nboShowCloseButtons?  (Read 13192 times)

Avishai

  • Hero Member
  • *****
  • Posts: 1021
TPageControl and nboShowCloseButtons?
« on: June 08, 2011, 02:11:08 pm »
In TPageControl under "Options" there is "nboShowCloseButtons" and there is "OnCloseTabClicked" Event .  I set "nboShowCloseButtons:= True" but I do not see a CloseButton.  I also can not trigger "OnCloseTabClicked" Event.  What am I missing?
Lazarus Trunk / fpc 2.6.2 / Win32

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: TPageControl and nboShowCloseButtons?
« Reply #1 on: June 08, 2011, 02:56:14 pm »
Here - Lazarus 0.9.31 r31122M FPC 2.5.1 x86_64-linux-qt - works.
See screenshot. Maybe you have old version of Lazarus or your platform is not supported or other reason.
OnCloseTabClicked event is fired but tab is not closed. Probably it must be done by programmer. But I don't know how because event has only parameter Sender: TObject.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

fabienwang

  • Sr. Member
  • ****
  • Posts: 449
  • Lazarus is the best
    • My blog
Re: TPageControl and nboShowCloseButtons?
« Reply #2 on: June 08, 2011, 02:59:28 pm »
nboShowCloseButtons affects GTK2 and QT widgetsets.
It does nothing on Windows widgetset as windows cannot do it natively :)
I'm using Arch Linux.
Known for: CPickSniff, OpenGrabby
Contributed to: LazPaint

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: TPageControl and nboShowCloseButtons?
« Reply #3 on: June 08, 2011, 03:11:17 pm »
Thanks guys.  I think that is a first for me.  Usually I am told "that only works in Windows" :)  Now I find something that doesn't work in Windows.
Lazarus Trunk / fpc 2.6.2 / Win32

Dibo

  • Hero Member
  • *****
  • Posts: 1057
Re: TPageControl and nboShowCloseButtons?
« Reply #4 on: June 08, 2011, 04:41:12 pm »
By the way: Some time ago I looked for CSV kompoent and I found this screenshot:
http://wiki.lazarus.freepascal.org/Image:Example.png
This is windows and page control have close buttons. Is it just fpGUI? Anyone know?

fabienwang

  • Sr. Member
  • ****
  • Posts: 449
  • Lazarus is the best
    • My blog
Re: TPageControl and nboShowCloseButtons?
« Reply #5 on: June 08, 2011, 05:44:37 pm »
no Dibo, theses are linux screenshots with a vista theme. And the closes buttons are into gedit (nothing related to lazarus unfortunately)
I'm using Arch Linux.
Known for: CPickSniff, OpenGrabby
Contributed to: LazPaint

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: TPageControl and nboShowCloseButtons?
« Reply #6 on: June 08, 2011, 06:53:15 pm »
NotePad++ has close buttons on the Tabs in Windows.  I wonder how they did it.  I will see if I can find out.  If I find anything, I will post it.
Lazarus Trunk / fpc 2.6.2 / Win32

Sora-Kun

  • Full Member
  • ***
  • Posts: 162
  • I can smell your presence ...
    • Sora-Kun
Re: TPageControl and nboShowCloseButtons?
« Reply #7 on: June 09, 2011, 11:37:54 pm »
Hi,
  Notepad++ is made in C++, as i can see from the source code.
However, you can have the [X] button on the tabsheets, when you build your application using the Qt LCLWidget, it's done by going to Project -> Project Options -> Build Mode, and change the Macro Value of LCLWidgetType to Qt.
However, there is a small bug, when you have 2 tabsheets, when you press the [X] button of the non-active page, the active one will close.
However, you must code the close action by your self. Lazarus wont do it for you.

Sincerely,
LinkOS.
if nothing suites you, make it your self!
The Revolution, Genesis. The next generation IDE.
If you want to help, PM me.

Made in Lazarus.
Soon, in The WWW.

mcsquirrel

  • Newbie
  • Posts: 1
  • German IT guy
    • My ancient homepage
Re: TPageControl and nboShowCloseButtons?
« Reply #8 on: January 21, 2017, 01:47:50 pm »
Hi,

I just stumbled here, having the same problem on Windows when coding a cross-platform application. However, I've chosen to stay with the default LCLWidgetType and (as a workaround or additional feature) allow to close tabs on mouse middle-click.

Therefor, you just need to react to the OnMouseUp event of the TPageControl and find out which tab has been clicked:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.PageControl1MouseUp(Sender: TObject; Button: TMouseButton;
  2.   Shift: TShiftState; X, Y: Integer);
  3. var
  4.   p: TPOINT;
  5.   i: Integer;
  6. begin
  7.   // Close tab on middle click
  8.   if Button = mbMiddle then begin
  9.     p.x := X;
  10.     p.y := Y;
  11.     i := PageControl1.TabIndexAtClientPos(p);
  12.     if i = -1 then exit;
  13.     PageControl1.Pages[i].Free;
  14.   end;
  15. end;
  16.  

Works like a charm!
Manuel

PS: Initially, I had tried sending a TCM_HITTEST message along with a TTCHitTestInfo structure containing the mouse coordinates to Windows (as suggested in some Delphi forums), but somehow always got -1 as a result in Lazarus. Thus I found the TabIndexAtClientPos function within Lazarus sources which does essentially the same, but seems to work on any platform - just tested on Windows and Mac :)
Delphi 6 PE hobbyist (2001-2016), switched to Lazarus 1.6.2 for cross-platform coding (2017+).

 

TinyPortal © 2005-2018