Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Interface and Graphics > Load Shape At Runtime in a PictureBox


Reply
 
Thread Tools Display Modes
  #1  
Old 06-26-2012, 05:58 AM
mathprof mathprof is offline
Regular
 
Join Date: May 2003
Posts: 91
Default Load Shape At Runtime in a PictureBox


How can I load (create) a shape (circle) at runtime in a picturebox?

I know that I can use the circle method to do this but I need the circle shape with its
properties.

That is, when the shape is created it should be part of the picturebox and not the form.
Kind of like when I click and drag the shape from the the toolbox (as opposed to double clicking on the shape control)

Thanks.
Reply With Quote
  #2  
Old 06-26-2012, 12:16 PM
Cerian Knight's Avatar
Cerian Knight Cerian Knight is offline
Multi-Technologist

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 3,740
Default

Try right-clicking on a Shape control and select 'Cut', then right-click on a PictureBox and select 'Paste'. The Shape control is now embedded and you can work with both as necessary.
__________________
"May the code that you write never work in ways that you didn't expect; and may the code that you didn't write never require you to maintain it". - Ancient Chinese Proverb
Reply With Quote
  #3  
Old 06-26-2012, 12:38 PM
Gruff's Avatar
Gruff Gruff is offline
Bald Mountain Survivor

Super Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA
Posts: 5,882
Default

If you need to move a control into a picturebox (Or Frame, Form, or ssTab) at run-time you would set the container property to be the picturebox.
__________________
Burn the land and boil the sea
You can't take the sky from me


~T
Reply With Quote
  #4  
Old 06-26-2012, 01:32 PM
Cerian Knight's Avatar
Cerian Knight Cerian Knight is offline
Multi-Technologist

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 3,740
Default

For runtime creation within the PictureBox, I was playing with this code (works, but may need adjustment):
Code:
'Manually add a PictureBox control to a form first, then run this code
Private Sub Form_Activate()
Dim Shape1 As VB.Shape
Set Shape1 = Controls.Add("VB.Shape", "Shape1", Form1)
Set Shape1.Container = Picture1
Shape1.Visible = True
Shape1.Shape = 3 'Circle
End Sub
You should be able to extend this to any number of Shapes by creating a control array.
__________________
"May the code that you write never work in ways that you didn't expect; and may the code that you didn't write never require you to maintain it". - Ancient Chinese Proverb

Last edited by Cerian Knight; 06-26-2012 at 01:46 PM.
Reply With Quote
  #5  
Old 06-26-2012, 01:56 PM
mathprof mathprof is offline
Regular
 
Join Date: May 2003
Posts: 91
Default Container

Thanks.
Great idea.
Reply With Quote
Reply

Tags
runtime, shape


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->