Paul Dardeau 1 Posted Saturday at 01:07 AM Hi, I'd like to find a way to allow the user to select a VCL edit box at runtime and move and/or resize it (similar to how Delphi does form builder at design time). I just need this capability for text boxes. This is for charts where I'd like the user to be able to edit title, add annotations, and move/resize the annotations. Does such a thing exist? Any suggestions? Thank you in advance! Share this post Link to post
Anders Melander 1830 Posted Saturday at 03:57 AM Let me teach you a trick: https://www.google.com/search?q=delphi+move+control+runtime https://www.google.com/search?q=delphi+resize+control+runtime Share this post Link to post
Paul Dardeau 1 Posted Saturday at 01:34 PM (edited) 9 hours ago, Anders Melander said: Let me teach you a trick: https://www.google.com/search?q=delphi+move+control+runtime https://www.google.com/search?q=delphi+resize+control+runtime I did many searches and did not find any good answers, hence my post here. Edited Saturday at 01:36 PM by Paul Dardeau Make more friendly Share this post Link to post
Anders Melander 1830 Posted Saturday at 01:46 PM Just now, Paul Dardeau said: I did many searches and did not find any good answers, hence my post here. Sorry if I offended your superior intellect. As far as I can see both of the searches above returns a plethora of relevant answers to your question, which you are not exactly the first to ask. So what's preventing you from using any of them? Share this post Link to post
Paul Dardeau 1 Posted Saturday at 02:40 PM 34 minutes ago, Anders Melander said: As far as I can see both of the searches above returns a plethora of relevant answers to your question, which you are not exactly the first to ask. So what's preventing you from using any of them? The first link that I examined is this: https://www.thoughtco.com/how-to-move-and-resize-controls-at-run-time-4092542 It uses a non-standard way for the user to resize the control. The user must hold shift key to resize. The article concludes by saying that you might want to add 8 sizing handles. It gives no code or tips on how to do that. I then looked at these: https://tips.delphidabbler.com/tips/92 https://tips.delphidabbler.com/tips/93 There are no images to show what it looks like and very little explanation. I'm not new to programming, but I am new to Delphi and specialized Windows UI custom code. I looked at this thread: https://stackoverflow.com/questions/813693/how-to-draw-on-a-tpanel I saw someone mention about using Raize Components (TRzPanel in particular). Great! I google search "Raize Components" and it appears they (Raize) no longer offer those components for sale. In same thread, someone mentions to use TMS TAdvPanel (part of their VCL Components). I search for documentation about TAdvPanel and I can only see basic documentation. This thread and some of the others do have code, but few comments or discussion about the code. Part of the reason I was drawn to Delphi is the 'Rapid' part of application development. If I have to spent a lot of time figuring out old code to do something that seems relatively common, that goes against the grain of rapid development (in my opinion). One of the things I was hoping to hear from others in this forum post are things like "I've used 3rd party component X and it worked great" or "I built my own by subclassing Y and adding functionality Z". I find comments like "Let me teach you a trick: <google search links>" to be condescending. I introduced myself by saying that I'm new to Delphi. Share this post Link to post
Anders Melander 1830 Posted Saturday at 03:10 PM Just now, Paul Dardeau said: Part of the reason I was drawn to Delphi is the 'Rapid' part of application development. If I have to spent a lot of time figuring out old code to do something that seems relatively common, that goes against the grain of rapid development (in my opinion). It's not "relatively common". In my 30 years with Delphi I think I've only had a need to do it (resize a control with the mouse) once and that was for a run-time form designer. Moving a control can be done with something like 10 lines of code. Resize is harder. The Raize controls are owned by Embarcadero now and can probably be installed via GetIt. https://blogs.embarcadero.com/konopka-signature-vcl-controls-version-7/ 9 minutes ago, Paul Dardeau said: I then looked at these: https://tips.delphidabbler.com/tips/92 https://tips.delphidabbler.com/tips/93 That's not how I would do it but it's certainly a possibility. Why not try it instead of just giving up? 10 minutes ago, Paul Dardeau said: One of the things I was hoping to hear from others in this forum post are things like "I've used 3rd party component X and it worked great" or "I built my own by subclassing Y and adding functionality Z". Okay then: I googled the problem, read a lot of examples, tried some different solutions and then wrote some code based on the experience I just acquired. Worked great! Better? 15 minutes ago, Paul Dardeau said: I find comments like "Let me teach you a trick: <google search links>" to be condescending. I introduced myself by saying that I'm new to Delphi. Fair enough. Sorry about that. I guess I just don't understand that approach to problem solving. Share this post Link to post
Paul Dardeau 1 Posted Saturday at 03:56 PM 38 minutes ago, Anders Melander said: Why not try it instead of just giving up? Giving up? Au contraire! I'm just getting started! 😀 I suspect that my initial post may have agitated you since you thought I was giving up without trying. Sorry for that (if that's the case). I did try playing with various snippets of code I had found and had the 'move' functionality done in a matter of minutes. As you say, the resizing is more involved. I started with the question because I'd like to leverage best practices and not waste time going down a rabbit hole unnecessarily. I'm not opposed to doing that when required (and I do like the learning aspects of doing that). 1 Share this post Link to post
Stano 143 Posted yesterday at 09:39 AM (edited) Maybe this link will help. It's a Czech forum. But me use Slovak. https://forum.delphi.cz/index.php/topic,13715.msg81490.html#msg81490 See post: « Odpověď #4 kdy: 22-05-2013, 21:29:24 » Edited yesterday at 09:46 AM by Stano Share this post Link to post
bravesofts 16 Posted 13 hours ago try use this here: TSizeControl the github code here: Github Code any updates i will post it here, if possible Share this post Link to post
Paul Dardeau 1 Posted 5 hours ago Thank you to everyone who provided suggestions! I have a working prototype that provides the desired functionality. I created a custom control (TSizeableLabel derived from TCustomControl) that "wraps" a TLabel. The TLabel is passed as an argument to TSizeableLabel's constructor and TSizeableLabel makes itself the parent of the label. It also makes it's size just a little bit bigger than the size of the label. The extra size is to accommodate the 8 size handles that are drawn to enable resizing. I'm planning to put my prototype in a public github repo soon. Share this post Link to post