i am using Delphi XE7 Firemonkey.
I would like to move around TTabItems of a TTabControl component like modern Webbrowsers do with their tabs.
I found some tutorials but those are for VCL (http://www.swissdelphicenter.com/de/showcode.php?id=963)
What i also found is TChromeTabs (http://www.easy-ip.net/tchrometabs.html) but this was also made for VCL only.
Any help is greatly appreciated
You'll first need to set the DragMode on each of your TTabItems to dmAutomatic. From there a TTabItems OnDragDrop procedure is what you will need to write code for. I've provided a quick snippet on how to get your source and destination TTabItems. What you want to achieve when the "drop" is performed is up to you:
OnDragDrop
//This is your TTabItem that is being dragged
TTabItem(Data.Source).Index//Index of this object in your TTabControl
//This is your TTabItem that is being "dropped" to
TTabItem(Sender).Index//Index of this object in your TTabControl
Also if you assign this code to the OnDragMove of your TTabItem you will get a blue drag highlight showing what tab this is currently on:
OnDragMove
Operation:=TDragOperation.Move;
Hope this helps
Related
I use this code: How to make a combo box with fulltext search autocomplete support? to create custom TComboBox control with searching.
Everything was working fine but I decided to add bitmaps (pictures) into it using this method: ComboBox Simple with Bitmap
But when I added the second code I lost the searching functionality. To enable Owner drawing I added csOwnerDrawFixed style to control in constructor
constructor TComboBox.Create(AOwner: TComponent);
begin
...
Style := csOwnerDrawFixed; ; << Added to enable owner draw
end;
How can I combine these two codes? The strange thing is when I run the project I can see the control redrawing correctly first time but then all data are lost and no drawing is done.
#Rohit Gupta: Actually it is pretty easy to merge that 2 codes: simply place 2nd code into 1st one and rename class :)
I did this but the code is not working - painting the control causes freezing of software and I could not solve this issue that is why I asked for help.
#Warren P: you are right, the better is to create custom control which handles everything.
I created my own control which is basically TEdit with owner draw and TListBox with owner draw and TSpeedButton which works fine:
I need to do some tweaking now and finished control will be available on my blog.
If someone is interested then grab it later on http://unsigned.sk/blog/ (I will post comment here once finished).
Thanks to all for ideas!
I have done some FireMonkey stuff in XE2, in this case I'm having troubles with a customized TListBox.
In XE2 I built this customized TListBox by removing it's background and surrounding rectangle (basically I only need the 'grouping of child items' functionality provided by TListBox. This was simple, drop a TListBox, hit 'edit custom style', select the background rectangle, edit the fill and the stroke and you're golden.
Now we're moving to XE5 and I cannot reproduce the same behavior. Using the style book editor I can see the background (which is now TStyleObject and not TRectangle), but I cannot make the changes I could make before. I see tutorials on how to add stuff to a TListBox, but not on how to take default behavior away.
Can someone explain how to achieve this specific behavior, or point me towards a good tutorial?
Try changing the StyleLookup property of the list box to transparentlistboxstyle
I'm attempting to create an application menu and toolbar in Delphi XE3 that looks like the following (from a program I have):
I'm able to replicate a portion of this look by doing the following:
Create a new VCL Forms application
Add a TMainMenu and insert template menus for File/Edit/etc.
Add a TCoolBar to the form
Add a TToolBar to the TCoolBar
Add a TToolButton to the TToolBar for each of File/Edit/etc. and choose the Group property
Delete the Menu property from the form (so no program menu shows)
Assign the MenuItem property for each TToolButton to the corresponding File/Edit/etc.
Add a second TToolBar to the TCoolBar beneath the first one
Here's what it looks like:
It's somewhat similar but is still missing all the style elements to modify the look of the new application menu.
My question is, does anyone know of how to achieve a similar look, perhaps with a third-party component library? It seems likely that the original developer used a third-party VCL library. I'd like the drop shadow in addition to the styled menus and TCoolBar.
I've tried Raize Components, TMS Advanced Toolbars & Menus, and am in the process of trying DevExpress VCL components. None of them seem to provide a solution, but perhaps I'm not familiar enough with them yet to figure it out.
Delphi has come with an ActionBands demo that can show you how to obtain this appearance "out of the box" for your menus using TActionMainMenuBar (and TActionToolBar). Just change the Style menu to XP Style in the demo:
The rest of your steps seem pretty well complete. For the images on the menu items and toolbar buttons, see the use of ImageList components in association with the TActions on the menu and toolbar in the demo.
I am starting on my first application using delphi (using delphi XE 2) and I'm trying to piece my way through creating the GUI right now.
I'm trying to use a TpageControl to keep things separated and simple but when I try to place a component on a tabsheet it shows on all of them. According to what I have read the components placed on each given tab are only supposed to show in that one.
Basically I want each tab to operate as a separate form. Does anyone have any tips and/or tutorials on working with the Tpagecontrol in order to do what I have described?
Thanks.
Just have a look at the structure and you will see why this happens.
Button1 and Button2 seems to be related to TabSheet1, but looking at the structure you will see, that the parent of Button1 is Form1 and the parent of Button2 is TabSheet1.
If you switch to TabSheet2 Button1 is still visible, but Button2 is not.
But you can drag drop the controls within the structure panel from actual parent to a new parent.
To thwart the nit-pickers, let me start with, I searched here with this and could not find an answer, and yes, also I did scroll through the "Similar questions."...
Adding shortcuts to a TForm
I want to drag and drop some shortcuts from the Desktop to a TForm in my application. I am using Anders Melander's brilliant Drag Drop Suite (DDS).
I tried putting a TImage on the form but the DDS does not drop to an Image so I added a TPanel with a TImage on it. I could then drop on the panel and assign the image to the TImage.Picture. Problem was the Panel has no Transparent Property so the shortcut on the form looks clunky with the visible Panel behind it.
I need to be able to drop to the TImage or make the underlying TPanel transparent.
Can anyone help with code-snippets for either of those options, or better yet, a method of dropping a Shortcut directly on to my Form.
Thanks
Coincidentally I needed to make a TWinControl (the base for every visible control with a window handle, including TPanel) transparent. I found numerous results and applied them to this answer.
It's been a while since I implemented drag and drop, but I assume you call some API and pass it the handle of the panel? That answers the question why you can't use TImage. TImage is a graphic control, a control without a handle, that relies on its parent for recieving messages and drawing itself.
It should be possible to use the form, though, since that has a handle too.
If the TImage is directly on the TForm, then let the TForm handle the drop, no TPanel needed. OLE Drag&Drop operations (which Ander's components implement) provide coordinates where dragging and dropping occurs. The TForm should be able to detect when a drag is over the area occupied by the TImage and what type of data is being dragged, and only allow dropping of supported types within that area, extracting the dropped data and updating the TImageas needed, and denying anything else that does not match that criteria.