[VB6] - Rotation a windowless controls.-VBForums
Results 1 to 4 of 4

Thread: [VB6] - Rotation a windowless controls.

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2015
    Posts
    863

    [VB6] - Rotation a windowless controls.

    Code:
    Option Explicit
    
    Private Type XFORM
      eM11 As Single
      eM12 As Single
      eM21 As Single
      eM22 As Single
      eDx As Single
      eDy As Single
    End Type
    
    Private Declare Function SetGraphicsMode Lib "gdi32" (ByVal hdc As Long, ByVal iMode As Long) As Long
    Private Declare Function SetWorldTransform Lib "gdi32" (ByVal hdc As Long, lpXform As XFORM) As Long
    Private Declare Function ModifyWorldTransform Lib "gdi32" (ByVal hdc As Long, lpXform As XFORM, ByVal iMode As Long) As Long
    Private Const MWT_IDENTITY = 1
    Private Const MWT_LEFTMULTIPLY = 2
    Private Const MWT_RIGHTMULTIPLY = 3
    
    Private Const GM_ADVANCED = 2
    Private Const GM_COMPATIBLE = 1
    
    Private Sub Form_Load()
        SetGraphicsMode Me.hdc, GM_ADVANCED
    End Sub
    
    Private Sub Form_Paint()
        Dim mtx1 As XFORM, mtx2 As XFORM, c As Single, s As Single, p As IPicture
        ModifyWorldTransform Me.hdc, mtx1, MWT_IDENTITY
        Me.Line (0, 0)-(Me.ScaleWidth, Me.ScaleHeight), Me.BackColor, BF
        c = Cos(hsbAngle.Value / 100)
        s = Sin(hsbAngle.Value / 100)
        mtx1.eM11 = c: mtx1.eM12 = s: mtx1.eM21 = -s: mtx1.eM22 = c: mtx1.eDx = Me.ScaleWidth / 2: mtx1.eDy = Me.ScaleHeight / 2
        mtx2.eM11 = 1: mtx2.eM22 = 1: mtx2.eDx = -Me.ScaleWidth / 2: mtx2.eDy = -Me.ScaleHeight / 2
        SetWorldTransform Me.hdc, mtx1
        ModifyWorldTransform Me.hdc, mtx2, MWT_LEFTMULTIPLY
    End Sub
    
    Private Sub hsbAngle_Change()
        Me.Refresh
    End Sub
    Attached Files Attached Files

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    16,732

    Re: [VB6] - Rotation a windowless controls.

    Interesting approach and haven't seen this post of yours. Don't know how I missed it. I will have to download your sample project and play with it, but maybe you can answer this question before I do...

    It appears the entire hDC is modified by the XFORM. Could this logic be applied to individual windowless controls? In other words, some controls 'rotated' 90 degrees, others 45 degrees, etc. I would think subclassing the form may be needed or some other method to invalidate specific rectangles?
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    16,732

    Re: [VB6] - Rotation a windowless controls.

    Unfortunately, within VB you really don't have any control over the Paint event within the Paint event. If the user minimizes the form and restores it, for example, every windowless control will be 'refreshed'. Within the Form_Paint event, one does not have the ability to individually handle each bounding rectangle of each windowless control.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Tags for this Thread

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.