TPageControl component in Delphi 2006 - delphi

Is there an option to use same components (check boxes, TEdits, etc.) on different tabs on TPageControl component?

Not directly, no because each page is a separate object. If you want to use the same controls on every page, use TTabControl instead.
If you need to use TPageControl, there are ways to dynamically move controls between pages but usually it is simpler to just copy and paste.

Related

Firemonkey and dockable forms

Is it possible to have dockable forms in FireMonkey, as I have inspected the forms properties, and there is no such property to do that.
Is there any workaround to accomplish that?
There's nothing built in, as far as I know but it shouldn't be too difficult to add in yourself. Just bear in mind that any form can parent any control on another form:
On the child form, add any controls inside a container (e.g. a TLayout).
Create the child form.
Set the Parent property of the TLayout (etc.) to the parent form (or, more probably a container on the parent form so you can set the child TLayout's alignment to alClient).
If you want to show the placement during a drag operation, experiment with the various effec ts included.
Unlike VCL, the Firemonkey does not have a built-in dockable interface for creating dock forms. But there is a commercial component for creating a complete dockable interface in FMX. The component implements dockable forms only. So far, the docked document panels are not supported (like the visual studio IDE does) and no docked toolbars. But in general, they have all the necessary functionality, including auto-hide panels and the ability to be saved/restored in/from XML.
https://www.devmachines.com/firedocking-overview.html

How Do I Merge Two Existing Components Together?

How can I merge two VCL components together so I can access both of their properties?
For example, I want to merge a TImage and a TPanel into one, I require that the TPanel is the base component, so the TImage will be child to the TPanel.
Is it possible to do this?
I've been trying to do this in Delphi 2010 via Component > New VCL Component but it creates non-visual components when I require a visual component.
What can I do to change this?
If I understand correctly I think you want to merge two components together and expose the properties for both?
If this is what you are looking for, I asked a similar question for joining a TImage and TScrollBox together which can be found here:
Component Creation - Joining Components Together?
SetSubComponent was the key to achieving this, it may be worth while reading the comments and answers from the link above to understand more.
The Delphi language does not support multiple inheritance of implementation, only multiple inheritance of interface. Thus you cannot simply merge together two classes in the way you hope.
What you are proposing sounds a bit odd anyway. Both TPanel and TImage have their own visual surfaces. The only plausible thing I can imagine is that you could make the TImage a child of the TPanel. Derive a new component from TPanel. That component would create and own a TImage. Make the parent of the TImage sub control be the panel. Any properties and events of the TImage control that you want to surface in your control would have to be done manually. This is composition rather than inheritance.
You might use a TFrame to create a component that exists of other visual components at design time, e.g. a TPanel with a TImage upon it. This is probably not exactly what you want: the properties are not 'merged' together, you must design your own properties and methods to make this newly created component behave as you want it to. The functionality you desire (changing visual features depending on the spot of the mouse) needs to be built only once into the frame.

Alternative for TCategoryPanelGroup or TPageControl

Does an alternative exist for TCategoryPanelGroup or TPageControl? My problem is I use a CategoryPanelGroup on a PageControl, therefore there is an enormous flicker which I can not prevent (using DoubleBuffered, disabling a ParentBackground and other things).
I use TPageControl as panels, to show/hide groups of controls.
If you don't need to show tabs, don't use a page control.

Delphi: Managing multiple instances of TFrames

In this article there is an explanation of how to use TFrames as an alternative to TTabSheets in a Delphi PageControl.
I've been pondering a similar exercise, which the above doesn't seem to provide the solution for, and for which my solution seems to be overly complicated.
The requirement is for a tabbed interface, where each tab can be one of a number of different designs. Each design is implemented as a TFrame.
Due to the nature of the application being designed, we may have multiple copies of any frame open at any particular moment (with the content of each tab differing, but not the design) so that the user can compare the details of 2/3 different items at the same time.
For example in one session we may have 3 tabs open, all of Frame design A.
On another occasion we may have 3 tabs open each of Frame A, B and C.
The design needs to be flexible enough that we can add Frames to the design on request.
At the moment the solution that I have is to have separate TLists managing each type of Frame that we have open, with perhaps a master TList to keep track of the tabs that are open. As I said, over complicated.
Does anyone have a suggestion of how this could be handled more simply?
I'd probably leave out the master TList of frame instances.
If you need them you'll be able to get them by interrogating the TPageControl directly or through each of your individual TLists for each frame type.
Apart from that your approach sounds reasonable.
I have an application that manages frames on a single panel with my own menu control to control which frame is visible. When I need to make a frame visible I simple set visible:=false for every frame on the panel except for the one that I want. I am in control of what goes onto the panel so I know that at the very least each control is a Tframe and I can get to each frame by iterating over the Panel's Controls property. I then use interfaces to communicate between my main form and my frames.
Now if you want to use a standard windows tabbed interface you could still use the page control as you have suggested, you know that each TtabSheet has a single Tframe on it and you can check it's type and work with it as required. I don't see why you'd need a Tlist because if you really need to get at the "list of Tframes" you could build it dyamically anyway by iterating over the TtabSheets in the page control.
An alternative which would work similarly to my first approach, but gets you nice Windows tabs, would be to use a TtabControl instead of a TpageControl. With the TtabControl you basically just get a Tstrings instance (in the Tabs property) which represents all of the tabs. Since it's a Tstrings you can associate an object (ie your Tframe) with each item and hence each tab. When you click a tab you hide everything and show the correct Tframe. You also have your list because it's attached to the TtabControl via the Tabs property. You just have to handle the visibility of the frames yourself.
We use a TPageControl and create runtime a TTabSheet descendant, which has a new property for our own TFrame (we do not need to scan through .Controls or .Components to search our frame each time).

Delphi control that could mimic "Add-ons|Extension list" of Firefox?

My aim is to update the look of the GUI in my app. Currently my GUI contains a lot of listboxes which are used to edit some objects in an old fashioned way, that is, user double-clicks an item and a dialog is shown to modify the corresponding object.
I think a good modern approach is how Firefox displays the extensions installed (a snapshot below).
My question is about how to build such a GUI in Delphi(win32) easily? Are there any components you use mimicing such behaviour or will I just need to code this from stratch using panels? (IMO a very cumbersome job I'd like to avoid - the selection logic, resizings, etc...)
You can do something similar (not exactly) with standard components; TDBCtrlGrid, TSpeedButton,...
alt text http://img8.imageshack.us/img8/9585/imagen29ox3.png
If you're using Delphi 2007 or Delphi 2009, you might be able to do something similar using TCategoryButtons (from the 'Additional' component palette page). Drop it on a form and right click to display the popup menu, and then click "Categories Editor...". Add a category with the resulting dialog, set it's caption, and optionally set up Items it contains. Not exactly the same, but it might do what you need.
You could also use a dialog with a TTreeView (if you have categories of objects) or TListView to emulate the Delphi 2007 Projects->Options dialog. Clicking an item in the TreeView or ListView displays the proper page of a TPageControl to configure the object.
I mostly agree with Lars, but I would use a frame for each item instead of a panel. That would separate into its own file, and you would get easy designtime support for it.
Using a TFrame for each list item and put them all Aligned Top on a TScrollBox might work. Also see TDBCtrlGrid which does something like that in combination with datasets.
It can be done with existing Delphi controls.
For instance in the TCustomListBox control you can create your own OnDrawItem event to draw your own list item. You also need to create your own OnMeasureItem to change the item height.
In some cases it is very limited, so if you want more freedom you will need to do it from scratch.

Resources