Bring Control to Front when Selected in the Structure Pane - delphi

I would like to build a Wizard component, where I can guid the user through different pages. When the last page is reached, an action is performed.
That component should work similar as the TPageControl, where I can create sheets at design-time. Creating that 'sheets' is already done, but my problem is, that the last added sheet is always on top of the other sheets, and I cannot select another one anymore (which are behind). In the TPageControl component, I can select a sheet in the Structure Pane, and it comes to the front, where can I put controls on it.
And this is my question: How can I bring a control (my wizard sheet) to the front, when it is selected in the Structre Pane?

I have to override the TWinControl.ShowControl function. That function is fired when you click in the structure pane on the child control. Then, I just need to invoke the BringToFront function of that child.

Related

How to add a label and edit controls inside an already existing groupbox in a design mode using delphi

As one of my requirements, I have to add a label and edit field to an existing groupbox in delphi. But how many times, i add a label inside an existing groupbox it disappears or it wont get added. Is there an alternative way to do this?
Am not sure why but am able to add edit but not label
I'm going to take a wild guess here. You are adding new components without first selecting the group box in the design surface. When you do that the component becomes a child of the form and disappears beneath other controls.
Here's how to do it:
Click on the group box on the form design surface,
then double click on the label in the palette.
Alternatively:
Single click on the label in the palette,
then single click on the group box on the form design surface.
If you do get the component parent/child relationships messed up, you can inspect them in the Object TreeView (open this from the View menu). If the relationships are wrong, drag the child controls around in the Object TreeView, and drop them into their desired parents.

Style a firemonkey combobox component

Trying to get a new style on a ComboBox in FireMonkey (XE2).
But for some odd reason I cannot get the text of a ListBoxItem to show.
What I've tried is the following.
Create a new FireMonkey HD Application.
On the form I've added a ComboBox.
Right click on the ComboBox and select 'Edit custom style'
There I've added the following components
while the original one consist out of the following components
Now it seems to me that I need the TContent object (but I can't seem to find it in the toolpallete)
How can i bind my Text object to the strings that are placed in my ComboBox?
Any pointers are very welcome.
FireMonkey doesn't use a TText object to display the text. Instead it creates a copy of the list box item within the TContent (if I remember correctly).
As you've worked out you need to add a TContent to your form. The easy way to do this is to
go back to the form,
right click and select View as Text
Find the TStyleBook object and add a TContent at the appropriate point (the format for this should be obvious from the rest of the file).
No need to add any properties - defaults will be used the first time.
Right click, View as Form.
Go back into the style editor and edit away.

Show different popup menu depending on what column the mouse is over in a Delphi TListView control?

I have a Delphi 6 application that has a TJvListView control. I have a popup menu tied to that control via the control's PopupMenu property. What I would like to do is show a different popup menu based on which column the user had the mouse over when they right clicked, with the additional option to not show a popup menu at all if the current column does not need one. How can I do this?
Thanks to this detailed sample by Remy Lebeau on in-place editing in a TListView I know what row and column the mouse is over except for one wrinkle. The mouse down event where I determine the current row and column occurs after the popup menu is exited.
I now need to know two things. First, how can I get some event to fire before the popup menu shows after a right mouse click so I can record the current list view row and column and suppress the popup menu if I want to, and second, how I can show a different popup based on the current column. I am hoping to avoid having to write a bunch of mini-forms instead of using the TListView PopupMenu property and supporting code. Is there a simple solution, perhaps some fancy footwork in a sub-class I should create around TJvListView?
You could perform the detection in mousemove instead of mousedown/Click and change the popupmenu depending.
You also could remove any popupmenu and call the wished via p.pupup in mousedown as you desire.

How do I move multiple nodes at once in a TJvTreeView?

When you select multiple nodes of a JvTreeView, and then try to drag these nodes, the JvTreeView selects the node you clicked to drag, rather than initiating dragging all the selected nodes. You end up dragging only this single node.
Is it possible to drag multiple nodes in a JvTreeView? I am using Delphi 2007.
UPDATE: Oddly enough, if I hold down CTRL+SHIFT when dragging the items, I can successfully drag them all. Any ideas?
Suppose MultiSelectStyle is the default [msControlSelect], then the answer to your question is 'you don't release the control key when you're selecting the last item and beginning dragging'.
The culprit is in TJvTreeView.WMLButtonDown in JvComCtrls.pas. Code there tests if 'Ctrl' is pressed when the TreeView is MultiSelect, and clears all items and selects the clicked item if 'Ctrl' is not pressed. It should instead test if the clicked item is already selected and do nothing if it is.
You can see the broken behavior without dragging. Multi select a few items and then click a selected item with the mouse. The VCL TreeView do not select or de-select anything, while the JVTreeView, instead, de-selects all items and selects the clicked one.
Yes absolutely, I do it all the time.
Of course Multi-Select needs to be True and you may need to have a look at the TTreeView's MultiSelectStyle. That controls what type of nodes can be selected at the same time. For example if msSiblingOnly is set to true, you can only select sibblings.
Are you using dmAutomatic or dmManual. If the latter, it could be that you are doing something in the OnMouse* events that is negating the multi-selection you made earlier.

"Hello, world!" example for DevExpress QuantumGrid?

I successfully installed the latest QuantumGrid from DevExpress, but I've never worked with this grid before, and I don't know how to get started. I find that the HLP file isn't really a tutorial, and the demos are so rich to the point where I can't get started quickly and see if QuantumGrid fits my needs.
Would someone happen to have a really basic example on how to create a small, non-DB-bound, non-hierarchized, but user-editable grid to host a couple of columns and fill the grid with a few rows?
Thank you.
Place a grid on a form, then delete its default GridView and add a TableView. Add a few columns to TableView and then associate your GridLevel with this new view. Place a button on form and add this code to its click handler.
cxGrid1TableView1.DataController.BeginFullUpdate;
try
cxGrid1TableView1.DataController.RecordCount := 3;
cxGrid1TableView1.DataController.SetValue(0,0,'Data1');
cxGrid1TableView1.DataController.SetValue(1,0,'Data2');
cxGrid1TableView1.DataController.SetValue(2,0,'Data3');
finally
cxGrid1TableView1.DataController.EndFullUpdate;
end;
RecordIndex corresponds to the row index and ItemIndex corresponds to the column index. I hope this helps you to get started.
Create a table
view(gridlevel->create view->table)
Create columns(double click cxgrid
and add)
Set property(inner controls like
DateEdit) if you want. default
property is textedit)
You can insert/delete via
TableView.DataController.Insert/TableView.DataController.Delete*
or use navigator(View->OptionsView->Navigator)
You should look at demos("quantumgrid directory"\Demos\Delphi), demos are more helpful than help files :)
Thanks guys for the help. For those interested in getting started with this grid object, here (what I think) are the steps presented above:
(idursun)
Add a TcxGrid object to the form
In the Structure object in the IDE, right-click on cxGrid1, and select "Delete View"
Right-click on cxGrid1, and select "Editor"
Click on the "Views" tab, click on "Add View...", and select "Table" in the drop-down list
In the "Columns" tab on the right, click on "Add", and add a few columns
Still in this dialog box, go back to the "Structure" tab on the left
Right-click on cxGridLevel1, and choose "Select View" to associate the Level with this new TableView. Close the dialog
In the form, add a button, and paste this code to its Click event:
cxGrid1TableView1.DataController.BeginFullUpdate;
try
cxGrid1TableView1.DataController.RecordCount := 3;
cxGrid1TableView1.DataController.SetValue(0,0,'Data1');
cxGrid1TableView1.DataController.SetValue(1,0,'Data2');
cxGrid1TableView1.DataController.SetValue(2,0,'Data3');
finally
cxGrid1TableView1.DataController.EndFullUpdate;
end;
(barism)
Add a TxGrid object to the form
Within this new cxGrid1 object in the form, right-click its cxGrid1Level object, and select "Create View > Table"
In the Structure object in the IDE, right-click on cxGrid1, and select "Editor..."
In the Columns tab on the right, click on Add to add a couple of columns. Close this dialog
To add data to the grid, either write code, or right-click on cxGrid1 and select "Edit Layout and Data"

Resources