Control Selection & Resizing at runtime

  • Thread starter Thread starter for1248
  • Start date Start date
F

for1248

I have a common mousemove/down/up handler for any control placed on the panel
at runtime .It's Working fine .

I need for moving and resizing controls (labels/textboxes/checkboxes/etc) and
shape controls (LineShape ,RectangleShape, OvalShape which are from
powerpacks.dll ) which i place on the Panel which are generated at runtime .


Is there any Class for creating Control Selection and Resizing Handles for
my controls which are present on the panel at runtime ??????

I want to show the selection if user presses the control and able to resize
those controls with resizing handles for Any Typeof control . ?????


' If i release the mouse button after resizing it has to update the size or
location of that control same like in vs2005 design time environment but
here at runtime .

plzzz ,



Thanks & Regards
 
Hi,
there is no built in way to do this with .net however since you capture the
mouse up down and move events you shouldn't have any problem coding this
kind of thing. I've made a few ResizerRects as i call em, just make a class
which has a rectangle and however many grab handles you want, then just
handle resizing that rectangle as desired (grabhandle, Size property...)
once you have this simple control set up to behave how you want it, you just
need to create one for each object dragged onto the form and use it as a
sort of container, this makes sure that no matter what kind of object is
dragged onto the form, moving and resizing is always handled the same way
I'll look through my backups to see if i can find you an example (old
machines in bits for now).

Regards,

Michael Powell
Ramuseco ltd .Net Consulting

P.S
you may find the ControlPaint class useful, check it out.
 
Hii ,

Thanks For replying ,

This is the thing which i want for runtime . I used that thing but it
is of type controls inherits from COntrol .


Thanks
 
Thanks For Replying ,


That ControlPaint is very useful ,But i am getting only 3 squares at
different places not on control edges .Only at a particular place
those are coming not for individual controls at that location .


Thanks
For1248
 
Hii ,

I will come with a nice reply ,Sorry for the previous one .I am doing
practicles on that thing now i understood something ,

I will be back .Please reply me

Thanks
For1248
 
HI Powell ,

Now i am able to draw rectangles on any particular control if i
click , but the thing is it is not able to recognize the
LineShape,RectangleShape,OvalShape which are from
VisualBasic.PowerPacks.Dll if click on those shapes ,but recognizing
controls of type Control
if i click a button on toolstrip it creates Rectangle
While creating like this on panel ::
Dim shc As ShapeContainer = New ShapeContainer()
shc.Location = New System.Drawing.Point(0, 0)
shc.Margin = New System.Windows.Forms.Padding(0)
shc.Name = "ShapeContainer1"
Rect = New RectangleShape(shc)
Rect.Location = New System.Drawing.Point(ihorizontal,
ivertical)
Rect.Size = New Size(70, 40)
Rect.Name = "RectangleShape1"
Rect.Enabled = False
CurrentPanel= SampleForm.Panel1.Controls("Page" &
CurrentPanelNo)
cs.WireControl(Rect) --- Used from CodePRoject PICKBOX
project --not working on shapes
CurrentPanel.Controls.Add(shc) --------------- Adding to
Current Panle
g = CurrentPanel.CreateGraphics
'AddHandler ctr.MouseDown, AddressOf Ctr_MouseDown
AddHandler Rect.MouseClick, AddressOf Ctr_MouseClick
'AddHandler ctr.MouseLeave, AddressOf Ctr_MouseLeave
'AddHandler ctr.MouseUp, AddressOf Ctr_MouseUp


while Ctr_MouseClick i am writing this thing to get handle around
that control
If TypeOf sender Is TextBox Then
ctr = DirectCast(sender, TextBox)
ControlPaint.DrawSelectionFrame(g, True, Rectangle.Inflate(Box,
boxsize, boxsize), Box, Color.DarkBlue)
ControlPaint.DrawGrabHandle(g, New Rectangle(ctr.Left - 6,
ctr.Top - 6, boxsize, boxsize), True, True)
ControlPaint.DrawGrabHandle(g, New Rectangle(ctr.Left +
ctr.Width / 2 - 6, ctr.Top - 6, boxsize, boxsize), True, True)
ControlPaint.DrawGrabHandle(g, New Rectangle(ctr.Left +
ctr.Width, ctr.Top - 6, boxsize, boxsize), True, True)
ControlPaint.DrawGrabHandle(g, New Rectangle(ctr.Left - 6,
ctr.Top + ctr.Height, boxsize, boxsize), True, True)
ControlPaint.DrawGrabHandle(g, New Rectangle(ctr.Left +
ctr.Width / 2 - 6, ctr.Top + ctr.Height, boxsize, boxsize), True,
True)
ControlPaint.DrawGrabHandle(g, New Rectangle(ctr.Left +
ctr.Width, ctr.Top + ctr.Height, boxsize, boxsize), True, True)
ElseIf TypeOf sender Is LineSelection Then ----- Not
Recognizing the click
Line = CType(sender, LineShape)
.......


But not Working .........



Thanks & Regards ,
For1248
 
Back
Top