I'm building a VCL Forms Application in RAD Studio using C++. On the Form, I have a TImage object named Image2. I can add a picture to it like this:
Image2->Canvas->Draw(0, 0, Image1->Picture->Graphic);
Now, I want to add another picture on top of it (not replacing the present picture, but adding to it). How do I do this?
Also, is there a way to do this and be able to use the mouse to move around and add the second picture wherever I want it?
The main thing - I want to add the new picture to the existing, not simply replace it.
Related
In TlistView Dynamic appearance I added a few object appearanced to the item.
I have a TextObjectAppearence and an ImageObjectAppearence.
I want to set the image to be a background for the text meaning the text should be on top of the image.
I tried right-clicking on the image object and selecting SendToBack but it doesn't seem to work.
At run-time, there's also not any way to call ListItemImage.sendtoback etc.
what is the right way of doing it?
I've attached a screenshot of the two items overlapping...
The only way I found is to open fmx file in text mode and to move the various objects in the order needed (first is the deeper)
I need to add a clickable button with a custom image on top of the TMapView, is this possible?
ps: even if I leave the TImage on top of the view, the map overlays it, that is, the button appears quickly until the map rendering overlays it...
edit ps2: There is no code for the example, I simply put a TImage on the Form, either as a child of TMapView, or as a child of TForm, when I test it on android, when opening the app the image appears quickly before the map and then when the map starts to appear it overlays the image...
edit ps3: I don't know if a TImage is the correct way to do this, is this any component to leave on top of the map, that keeps showing up, serving as a button? Just like on Google Maps...
You can't show anything on TMapView because of "z-order" problem. I looked for while to find a solution.
See : Delphi object over TMapView
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.
My goal is to create a simple forms editor like the one that we find on Delphi IDE.
Right now the user can select and add the components making it parent of a TPanel that is the holder of the form. For simplicity, please consider also TPanel as the visual components added to the form.
I have 2 missing parts I want to find out ideas/code to help complete:
1 - how to move the created visual component? The same effect that in IDE for moving the visual component, for example Tpanel, around, chaning its top and left position
2 - how to draw that hooks for the component with focus on the form editor
3 - how to resize using the hooks
I only want the part related to handle the visual part. I am not generating DFM or anything like that.
Simply put your moving code needs to do this:
When the mouse goes down, check if the mouse position is over a control that can be dragged. If so, then set a variable named FDragControl to refer to that control. This code lives in an OnMouseDown event handler.
When the mouse moves, if FDragControl is not nil, move the control. This code lives in an OnMouseMove event handler.
When the mouse goes up, set FDragControl to nil.
That's pretty much all there is to it. The main nuance is that you must also remember the X, Y values of the mouse when the drag commenced. So in your OnMouseDown handler you write:
FStartMousePos := Point(X, Y);
FStartDragControlPos := Point(FDragControl.Left, FDragControl.Top);
And then in the OnMouseMove your position code reads:
FDragControl.Left := FStartDragControlPos.X + (X-FStartX);
FDragControl.Top := FStartDragControlPos.Y + (Y-FStartY);
You will also need to capture the mouse when you start dragging.
The resizing code is similar. Again, you need to decide in the OnMouseDown that you are resizing rather than dragging, but the code still involves handling mouse down, move and up events.
As for painting, you need to force a repaint whenever one of your event handlers changes a property that will influence the visual appearance of your form. You can use the value of FDragControl to decide whether or not to use special drawing of your control and indicate that it is being dragged. And likewise for resizing.
I've not coded up a full working implementation since your question is high level and conceptual. The implementation is down to you.
// I have made this an answer as I have just read your latest update which really should have been made as an edit to your original question but, anyway.
You can download the Cindy Components Pack and use the cyResizer Component which will do pretty much everything you need and is very customisable as well.
You can download it from here: http://sourceforge.net/projects/tcycomponents/
Searching more for an answer I could find these articles:
How to Move and Resize Controls at Run Time
http://delphi.about.com/library/weekly/aa102505a.htm
How to Add Size Handles to Controls being Resized at Run-Time
http://delphi.about.com/library/weekly/aa110105a.htm
Pretty much with all the information to complete this task with source code example.
These articles show how to implement and use a TMover class. I have done it and work correctly.
I have also downloaded the TcyComponents Pack and used the TcyResizer. It is a full featured form editor with pretty much everything that is required for a Delphi like forms editor. I recommend. It comes with source code and works fine with XE2 version.
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.