6 Replies - 1800 Views - Last Post: 27 August 2011 - 09:29 AM Rate Topic: -----

#1 cdaly2001   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 26-August 11

Dragging an object in a limited area

Posted 26 August 2011 - 01:08 AM

Hi,

I want to create a dial which is basically a circle that I can drag around in a circular motion. Ive looked at using the code in an earlier post which allows you to drag items around a screen but I cant figure out how to confine the movement so it only allows the user to drag this circle around in a circular motion. Any coordinate altering I do just looks snappy.

Any suggestions?

Thanks in advance for any suggestions offered

Chris

Is This A Good Question/Topic? 0
  • +

Replies To: Dragging an object in a limited area

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14092
  • View blog
  • Posts: 56,460
  • Joined: 12-June 08

Re: Dragging an object in a limited area

Posted 26 August 2011 - 08:08 AM

Well... the simplest way would be to hijack the 'paint' event in your form. have it draw a bitmap of your dial.
Then have a counter for orientation and what not.
Then start tracking the mouse clicks. Temporarily store the mouse down event, and when the mouse moves see which direction that is going. Update the orientation in the paint event while this happens. When the mouse button is up stop. You could make this into a user control so you can plunk it down and return a value from the dial.

Side note - make sure the dial at least goes to 11.
Was This Post Helpful? 0
  • +
  • -

#3 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14092
  • View blog
  • Posts: 56,460
  • Joined: 12-June 08

Re: Dragging an object in a limited area

Posted 26 August 2011 - 09:09 PM

You might want to check this tutorial out.. some handsome devil made it.

http://www.dreaminco...controls-knobs/
Was This Post Helpful? 1
  • +
  • -

#4 _HAWK_   User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1162
  • View blog
  • Posts: 4,444
  • Joined: 02-July 08

Re: Dragging an object in a limited area

Posted 26 August 2011 - 09:21 PM

Clever, modi, clever! I was thinking about a Matrix - same same-ish. The first clever was for the handsome devil part - btw! Nice tutorial.
Was This Post Helpful? 0
  • +
  • -

#5 cdaly2001   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 26-August 11

Re: Dragging an object in a limited area

Posted 27 August 2011 - 03:10 AM

View Postmodi123_1, on 26 August 2011 - 09:09 PM, said:

You might want to check this tutorial out.. some handsome devil made it.

http://www.dreaminco...controls-knobs/



Rotate a graphic!!! Damn its so easy when someone tells you how.

Thanks a lot for that your a simple genius.
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14092
  • View blog
  • Posts: 56,460
  • Joined: 12-June 08

Re: Dragging an object in a limited area

Posted 27 August 2011 - 08:23 AM

Ha.. no problem. There's clearly some tweaking that needs to go in graphics wise (that flickering could drive a man insane), but over all it gets a firm starting point. If you get a chance I would love to see what your control looks like when done. Throw up a graphic at least!
Was This Post Helpful? 0
  • +
  • -

#7 _HAWK_   User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1162
  • View blog
  • Posts: 4,444
  • Joined: 02-July 08

Re: Dragging an object in a limited area

Posted 27 August 2011 - 09:29 AM

I always use a picturebox for my drawing - I don't get any flickering when rotating my images. I also handle when to paint and not the system.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1