I am using the jvDocking components and have been unable to figure out how to enable close buttons on the tabs of forms that have been docked together as a set of tabs. I have tried various combinations of options such as:
tJVDoclient.EnableCloseButton := True;
And
tjvDockVSnetStyle.TabServeroption.ShowClosebuttonOnTabs := True;
tjvDockVSnetStyle.TabServeroption.ShowClosebuttonOnGrabber := False;
I am using Delphi XE2 Update 4.
Does anyone have any ideas as to why I can't seem to get the close button to appear on tabs?
Thank you!
It should be shown with CERTAIN docking styles, if you set the ShowCloseButtonOnTabs property to true. It's inside the TabServerOption section of the Dock Style Component (ie TJvDockVIDStyle).
I just tried it though, and it's possible there is a bug in this component as it does not work any more.
Related
I've earched for it but couldn't find anything. Is there any way to add a hint or tooltip with FireMonkey? Are there any components available that enable this?
Ideally I am looking for something like this (a callout type tooltip):
To the moderators who have placed this question on hold: I am looking for lines of source code on how to achieve this, not a software to buy/use. There are currently (AFAIK) no source code components that enable doing this, so there is no risk of "opinionated anwers or spam".
This is how I finally did it: to create a hint for a Button that looks like this:
Add a button to a form. Then add a TPopup. Drop a CalloutPanel inside it and optionally set the align to AlClient. The drop a TLabel on that CalloutPanel and write your hint text.
Your structure should look like this:
Then go to the TPopup and set PlacementTarget to Button1 (your button). Next, go to Placement and select BottomCenter:
Next add a handler for the MouseEnter and MouseLeave events on the button:
procedure TForm1.Button1MouseEnter(Sender: TObject);
begin
Popup1.IsOpen := True;
end;
procedure TForm1.Button1MouseLeave(Sender: TObject);
begin
Popup1.IsOpen := False;
end;
That should do it.
You can use FloatAnimation and Opacity property to make a hint.
Add a button to a form. Then add CalloutPanel (or any shape) inside.
Next drop a TLabel on the CalloutPanel to write your hint text. I set CalloutPanel.Visible property to False at the Form Creating moment. Then attach a TFloatAnimation to a CalloutPanel.Opacity property.
Next set some TFloatAnimation properties:
Because of Duration Hint appears smoothly.
Then create Button events OnMouseEnter and OnMouseLeave .
procedure TForm1.Button1MouseEnter(Sender: TObject);
begin
CalloutPanel1.Visible := true;
end;
procedure TForm1.Button1MouseLeave(Sender: TObject);
begin
CalloutPanel1.Visible := false;
end;
That's it
I am new to Delphi and FireMonkey. And I also wanted tool tips. And here is what I figured out: FireMonkey has no provision for tool tips, and this is deliberate and for good reason.
I think the big idea with FireMonkey is that you develop one and only one program. Then, without changing even one line of code, you compile a version to run on Windows, another version to run on Android, another version to run on Mac OS, etc. So without changing even one line of code, you have a version for Desktop and a version for Smartphones that work exactly the same way with the same user interface.
Therefore, FireMonkey is only going to support features that are common to both smartphones and desktops. On smartphones, there is no such thing as hovering a mouse, a finger, or anything else. Therefore, Firemonkey does not support hovering on desktops. Because there is no hovering, there can be no tooltips ('hints' in Delphi nomenclature).
So you have to decide: Do you want an app that works exactly the same in Windows and on smartphones, without changing the code and without having separate code? Or do you want all the desktop features? If you want all the desktop features, including tooltips (hints) and all the rest, then you should be using Embarcadero's VCL (Visual Component Library). Using VCL will allow you to get tooltips (hints) by just setting the 'hint' property of text boxes, buttons, and all the other controls--and without writing code.
But if you want an app that works on smartphones, you will have to use FireMonkey. VCL won't work for that.
As I mentioned, I'm still new to Delphi. So, of course, I appreciate corrections
from experienced Delphi developers.
I am looking for a alternative to Raize components' tab control.
I would like to have the ability to add close button at the top of each page and I want to use slanted tabs and colors on the tabs. Oh, and I'm using FireMonkey 2.
//I know that raize does not support firmonkey.
Firemonkey has it's own TTabControl in the Common Controls page (by default). You can style this using a TStylebook. For example, I'm quite confident it's possible to add a close button onto the tab itself.
After all, FMX is a vector-based framework and so all visual elements must exist within the style. You'll probably want to load a style into a TStylebook for this, as I'm unable to find a way to load the default style into one. Navigate down to tabitemstyle, and from there you'll be able to tweak the visual appearance of it. Simply add a close button as you'd like (alignment, layout, etc).
Back in your application code, you'll be looking to use the FindStyleResource routine in order to setup the code (XE2 uses FindBinding and as such you'd set the BindingName property instead). I'm going to assume your close button is called 'CloseButton' (without the quotes);
var
MyTab : TTabItem;
begin
MyTab := ((TabItem1 as TTabItem).FindStyleResource('CloseButton') as TButton).OnClick := TabClose;
end;
You'd want to add that code when you initially create the tab, or if creating all the tabs at design time, you'll want to run it at FormCreate. You're basically telling it that when CloseButton is clicked, that you want to call the notify event/procedure TabClose. This procedure is identical to a button click.
You could go so far as changing the StyleName property of the tab to be CloseButton+Index_of_tab.
Now, as for the code to close the tab itself, something like this untested example may work, though you'll want to iterate on it.
procedure TForm1.TabClose(Sender: TObject);
var
_mytab : Integer;
_activetab : Integer;
begin
_activetab := ((Sender as TTabItem).Parent as TTabControl).ActiveTab.Index;
_mytab := ((Sender as TTabItem).Parent as TTabControl).ActiveTab.Index;
((Sender as TTabItem).Parent as TTabControl).Tabs[_MyTab].Free;
((Sender as TTabItem).Parent as TTabControl).TabIndex := _activetab;
end;
Now, this is the clever part, and exploits the design of the framework. When you click on a style element that's inside another element, by default, it'll select the parent element. In this example, it'll select the tab that contains the close button the user clicked on. From this, it'll then close that tab (technically, it'll free it, I've not dealt with tabs much in development so you'll want to look into the proper method of 'closing' them).
There is one problem with this though; You'll probably want to find a better way of detecting the previously active tab if you wish to switch back to it. Right now, it'll simply open the tab that was after the tab you just closed (since the tabcount is now 1 less, the active tab index selects the next physical tab). You'll probably be able to do this by splitting the _activetab code off elsewhere.
I've done similar things with some of my own programs, and this is how I usually create 'hybrid' components. You're essentially exploiting the modular design of the framework to make it do what you want it to do, without having to rely on third party components.
Since FMX is a pretty young framework there aren't many 3rd party component vendors that support it yet.
I haven't seen any 3rd party TabControl component for FMX and a quick Google search suggests there aren't any. So you might be out of luck.
I know this is an old query but in case anyone is still looking for tabs with close buttons and slanted tab sides, check out TMSSoftware's TTMSFMXTabSet. I'm using it in a current development project and it is working fine.
A MainMenu option in my app calls:
TStyleManager.SetStyle('Ruby Graphite');
It properly changes the style in my XE2 (Update 3) application almost everywhere. Here's the problem:
I have a TPageControl with 3 TabSheets, each containing a TFrame. The above call properly changes the style of the currently visible TabSheet's components to 'Ruby Graphite'.
However, when I click to switch to another tabsheet, all of its components are invisible until I move my mouse over them. When I return to the original TabSheet, its components too are now not visible until I hover over them.
I tried explicitly calling .Refresh and .Repaint on the frames themselves, but that didn't make the components on them visible.
What's weird is that executing:
TStyleManager.SetStyle('Windows');
returns the style to the standard, with all components visible.
The TTabSheet is on a panel which is on a panel, if that matters. And, I'm using some 3rd party components (not in these frames) that are threaded. I believe that I have disabled them though.
Any suggestions on how to force the visual components on a formerly hidden tab to become visible after changing the style from Windows?
EDIT: Link to short screen video that shows the refresh problem: http://tinyurl.com/sostyle.
I have also on occasion found that the software doesn't respond when clicking on the icons (like maximize) in the upper right corner. There's just something weird going on that is over my head. So far, I've been unable boil this down to a small example from the 40,000 lines of code in the application.
Here's a solution and a direction to try that worked for me on Delphi XE4.
I have found that I get the same issues when I minimize a form that is set to use the TStyleManager and sets styles dynamically during the execution of the application.
Another problem besides the redraw problem that I noticed is one that involves the form style not being set to a sizeable when the form is restored from being minimized to the taskbar or a trayicon. The sizeable form border problem and the redraw problem seem to be linked.
I overcame the redraw problem and the border resizing problem by adding an event handler for the OnClick event of the TrayIcon component and calling RecreateWnd for the form that uses the TStyleManager.
Currently it looks like this, with the jtiApp component being a TJvTrayIcon component:
procedure TMainForm.jtiAppClick(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if not Visible then
begin
WindowState := wsNormal;
RecreateWnd;
Show;
end;
end;
That seems to take care of the redraw problem and the border settings for the recreated form. I'm not sure if that's a JVCL issue or with the TStyleManager but that fix worked when it was an issue dealing with a restore from the tray via a TrayIcon component.
I hope that helps with your issue and others who view this solution.
Using Delphi 2009 on Windows XP to develop desktop application.
Is there any way to make a windows dialog modal to a tab, instead of application. How can I achieve this? Threads? any frameworks supporting this?
Something similar to
Thanks in advance.
Kind Regards,
Pavan.
One way is to simulate this is:
Temporarily disable all child controls of the tab sheet
Create a Form
Set its Parent to the tab sheet
Set FormStyle := fsStayOnTop
Set BorderStyle := bsNone
This way you have a dialog on top of a tab sheet and it's the only thing that users can interact with on this tab sheet, but it doesn't block the main form ui or other tab sheets.
You might be able to use something like this to make a window modal
WindowList : Pointer;
WindowList := DisableTaskWindows(MyForm.Handle);
and
EnableTaskWindows(WindowList);
to un-modal it. This should allow you to simulate a modal form.
I have a Delphi 7 application that has two views of a document (e.g. a WYSIWYG HTML edit might have a WYSIWYG view and a source view - not my real application). They can be opened in separate windows, or docked into tabs in the main window.
If I open a modal dialog from one of the separate forms, the main form is brought to the front, and is shown as the selected window in the windows taskbar. Say the main form is the WYSIWYG view, and the source view is poped out. You go to a particular point in the source view and insert an image tag. A dialog appears to allow you to select and enter the properties you want for the image. If the WYSIWYG view and the source view overlap, the WYSIWYG view will be brought to the front and the source view is hidden. Once the dialog is dismissed, the source view comes back into sight.
I've tried setting the owner and the ParentWindow properties to the form it is related to:
dialog := TDialogForm.Create( parentForm );
dialog.ParentWindow := parentForm.Handle;
How can I fix this problem? What else should I be trying?
Given that people seem to be stumbling on my example, perhaps I can try with a better example: a text editor that allows you to have more than one file open at the same time. The files you have open are either in tabs (like in the Delphi IDE) or in its own window. Suppose the user brings up the spell check dialog or the find dialog. What happens, is that if the file is being editing in its own window, that window is sent to below the main form in the z-order when the modal dialog is shown; once the dialog is closed, it is returned to its original z-order.
Note: If you are using Delphi 7 and looking for a solution to this problem, see my answer lower down on the page to see what I ended up doing.
I'd use this code... (Basically what Lars said)
dialog := TDialogForm.Create( parentForm );
dialog.PopupParent := parentForm;
dialog.PopupMode := pmExplicit;
dialog.ShowModal();
I ultimately ended up finding the answer using Google Groups. In a nutshell, all the modal dialogs need to have the following added to them:
procedure TDialogForm.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.Style := Params.Style or WS_POPUP;
Params.WndParent := (Owner as TWinControl).Handle;
end;
I'm guessing this does the equivalent of Lars' and Marius' answers in Delphi 7.
Is the dialog shown using ShowModal or just Show? You should probably set the PopupMode property correct of the your dialog. pmAuto would probably your best choice. Also see if you need to set the PopupParent property.
First of all, I am not completely sure I follow, you might need to provide some additional details to help us understand what is happening and what the problem is. I guess I am not sure I understand exactly what you're trying to accomplish and what the problem is.
Second, you shouldn't need to set the dialog's parent since that is essentially what is happening with the call to Create (passing the parent). The dialogs you're describing sound like they could use some "re-thinking" a bit to be honest. Is this dialog to enter the properties of the image a child of the source window, or the WYSIWYG window?
I'm not sure I quite understand what you are getting at, but here's a few things I can suggest you can try...
This behaviour changes between different versions of Delphi. I'd suggest that this is due to the hoops they jumped through to support Windows Vista in Delphi 2007.
If you are using Delphi 2007, try removing the line from the project source file that sets the Application.MainFormOnTaskBar boolean variable.
With this removed, you should be able to use the various Form's BringToFront / SendToBack methods to achieve the Z-ordering that you are after.
I suspect that what you've discovered has been discussed on this link
Of course, I may have just missed your point entirely, so apologies in advance!