CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2004
    Posts
    28

    Rotating Forms. Is it possible?

    I have couple of shapes in a form that I'd like to rotate. Is this possible? I couldn't find any info about it, except rotating text or a bitmap. I am asking strictly about rotating a shape on a form!

  2. #2
    Join Date
    Apr 2004
    Posts
    17
    yes, it is possible. rotate every point from the shape over one centre (the centre could be e.g. the first point from your shape and you can rotate the other 3 points). use normal rotation matrix. actually the principle is always the same, this means it is the same like rotating text, bitmaps and so on in 2D.

    (x1,y1)---------(x2,y2)
    | |
    | |
    | |
    (x3,y3)---------(x4,y4)

    your shape and you want to rotate over (x1,y1),
    so you need transformed coordinates for (x2,y2);(x3,y3),(x4,y4).
    using the rotation matrix in 2D is simple:
    rotation matrix on angle PHI is defined like this:

    | cos(PHI) sin(PHI)|
    |-sin(PHI) cos(PHI)|

    so in pseudo code rotating a line counterclockwise (positive angle) looks like(where newx and newy are the second coordinates):

    newx = oldx * cos(PHI) + oldy * sin(PHI)
    newy = oldy * cos(PHI) - oldx * sin(PHI)

    n.b. sin and cos functions in VB are working with radians, so you must convert the angle in to degrees

    regards,
    typecast

  3. #3
    Join Date
    Apr 2004
    Posts
    17
    one think i've figured even ... :-)
    ready forms in vb don't have actually 4x2 coordinates, they have left, top, height and width. maybe you should draw the form yourself ...
    when you must rotate your form only on 90 degreese, then you just need to swap the height and width.

    hope this helps,
    typecast

  4. #4
    Join Date
    Apr 2004
    Posts
    28
    That's what I was going to ask, the shapes have only Left, Top, Height and Width properties.

    I think I'll have to draw directly on the form using Line, Circle methods.
    Thanks

    PS Basicaly, I think, no form in Windows can be rotated (I emphasize, forms not images in a picture box)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured