Design mode

julk

Newcomer
Joined
Jun 25, 2004
Messages
5
ok i know this is kind of wierd but i need
to be able to not only add new controls to my for but
they have to bet in design mode.

in other word the user of my program would go to a menu were they could choose to add a button for example, and the button would apear in the form and the button would be in design mode so that the user could drag, size the control.

has any one done this?
any help would be greatly apreciated.
 
That's not a beginner question. Let me narrow the scope...WHY does the user need to do this?
 
well my application is about pictures
i need to draw boxes arround areas and and save their position
what i fugured was to have a image in the background and just have a
design mod control be placed in the form an the user would be able to
size his box, add a new one, delete, etc.
then i need to create an XML file that will represent all the boxes in the form
but my question still stands how can i do design mode controls
???
 
Okay, let me rephrase that problem statement:

A user will load a picture onto a form (of some sort, not necessarly a windows form), and then you want them to have the ability to 'draw' a 'box' over a portion of the picture and have the postion and size of the 'box' maintained in a datasource (use specified XML file).

So this doesn't sound like a button - that would involve handling click events and such; this sounds more like a GDI+ problem.

You would want to track the 'start' position of the box when the user does a mouse-down, and the 'stop' position on the mouse-up event - during mouse-move you would want to constantly draw a 'ant-trail' box from the start position to the current mouse position to show the 'bounding-rectangle' of where they currently are. Then once the mouse-up event is fired change the ant-trail to a solid line.

Of coarse you'll need to track the mode the user was in and maintain the 'names' of the boxes somewhere, but that's outside of the scope of your question. Code Project has an example of doing an 'ant-trail' somewhere - and MSDN has plenty of examples of using GDI+ to do the drawing you're going to need to learn how to do.

Hope that helps.
 
Back
Top