Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 132,668 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,145 people online right now. Registration is fast and FREE... Join Now!




Finding circular coords in a pic box

 
Reply to this topicStart new topic

Finding circular coords in a pic box

Reverand Dave
post 4 Sep, 2008 - 05:45 AM
Post #1


D.I.C Regular

Group Icon
Joined: 27 Jul, 2008
Posts: 373



Thanked 2 times

Dream Kudos: 50
My Contributions


I'm attempting to create an analog clock with the use of a picturebox, a few shape controls, and a few line controls and am having dificulties coming up with a proper algorithm to calculate the x-y coordinates for the placement of the X1 and Y1 position of my line controls. I have the X2 and Y2 coords set to the center of the form like this:

CODE


Min.X2 = Me.Width / 2
Min.Y2 = Me.Height / 2
Sec.X2 = Me.Width / 2
Sec.Y2 = Me.Height / 2
Hrs.X2 = Me.Width / 2
Hrs.Y2 = Me.Height / 2



I could just look for the coord in the box and assign them, but I want the form to scale.
I'm looking for something so that I can set the point and move the x1 and y1 position of the hands(lines) to the next tick without too much code, but I am unfortunately not quite smart enough to figure it out. I'm going to tie it to a timer control (obviously).

I have my major time markers placed like this:

CODE



Tm(0).Left = (Sha.Width / 2) - Tm(0).Width / 2
Tm(3).Top = (Sha.Height / 2) - Tm(0).Height / 2
Tm(3).Left = (Sha.Width) - Tm(0).Width
Tm(9).Left = Sha.Left
Tm(9).Top = (Sha.Height / 2) - Tm(0).Height / 2
Tm(6).Top = Sha.Height - Tm(0).Height
Tm(6).Left = (Sha.Width / 2) - Tm(0).Width / 2
Tm(1).Top = Sha.Height * (1 / 16)
Tm(1).Left = (Sha.Width * (3 / 4)) - Tm(0).Width
Tm(11).Top = Sha.Height * (1 / 16)
Tm(11).Left = (Sha.Width * (1 / 4))
Tm(5).Top = Sha.Height * (15 / 16) - Tm(0).Height
Tm(5).Left = (Sha.Width * (3 / 4)) - Tm(0).Width
Tm(7).Top = Sha.Height * (15 / 16) - Tm(0).Height
Tm(7).Left = (Sha.Width * (1 / 4))
Tm(10).Top = Sha.Height * (1 / 4)
Tm(10).Left = (Sha.Width * (1 / 16))
Tm(8).Top = Sha.Height * (3 / 4) - Tm(0).Height
Tm(8).Left = (Sha.Width * (1 / 16))
Tm(2).Top = Sha.Height * (1 / 4)
Tm(2).Left = (Sha.Width * (15 / 16)) - Tm(0).Width
Tm(4).Top = Sha.Height * (3 / 4) - Tm(0).Height
Tm(4).Left = (Sha.Width * (15 / 16)) - Tm(0).Width


And have them scaling with the form like this:

CODE

For i = 0 To 11
Tm(i).Height = Pic.Width * 0.03
Tm(i).Width = Pic.Height * 0.03
Next i


I have all of this linked to the resize event.

I know there is a clock in the snippets, but that is not quite what I want to do here.

If anyone can wade through my convoluted post here and give me some suggestions or atleast point me in the right direction, I would be greatly appreciative.

User is offlineProfile CardPM

Go to the top of the page

AdamSpeight2008
post 4 Sep, 2008 - 08:48 AM
Post #2


LINQ D.I.C.

Group Icon
Joined: 29 May, 2008
Posts: 756



Thanked 48 times

Dream Kudos: 2125
My Contributions


The following tutorial my give you a clue of what to do. (I know it in vb.net but you maybe figure it out for vb6)
Clock Control Tutorial
User is offlineProfile CardPM

Go to the top of the page

Reverand Dave
post 4 Sep, 2008 - 10:14 AM
Post #3


D.I.C Regular

Group Icon
Joined: 27 Jul, 2008
Posts: 373



Thanked 2 times

Dream Kudos: 50
My Contributions


It's more of a start than i had before. I'll let you know if I crack it or not. Thanks Adam.
User is offlineProfile CardPM

Go to the top of the page

thava
post 4 Sep, 2008 - 05:30 PM
Post #4


D.I.C Regular

Group Icon
Joined: 17 Apr, 2007
Posts: 425



Thanked 17 times

Dream Kudos: 50
My Contributions


try this link some basics for cos and sin in drawing

http://pixwiki.bafsoft.com/mags/5/articles/circle/sincos.htm
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 05:54AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month