home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 6_2008-2009.ISO / data / zips / Transform_215714792009.psc / Transform / Form1.frm next >
Text File  |  2009-07-09  |  9KB  |  248 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   8985
  5.    ClientLeft      =   3720
  6.    ClientTop       =   1125
  7.    ClientWidth     =   12465
  8.    ClipControls    =   0   'False
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   599
  11.    ScaleMode       =   3  'Pixel
  12.    ScaleWidth      =   831
  13.    StartUpPosition =   2  'CenterScreen
  14.    Begin VB.PictureBox picDest2 
  15.       Appearance      =   0  'Flat
  16.       AutoRedraw      =   -1  'True
  17.       AutoSize        =   -1  'True
  18.       BackColor       =   &H00FFFFFF&
  19.       BorderStyle     =   0  'None
  20.       ClipControls    =   0   'False
  21.       ForeColor       =   &H80000008&
  22.       Height          =   8655
  23.       Left            =   105
  24.       ScaleHeight     =   577
  25.       ScaleMode       =   3  'Pixel
  26.       ScaleWidth      =   809
  27.       TabIndex        =   2
  28.       Top             =   105
  29.       Width           =   12135
  30.       Begin VB.Shape shpRightBottom 
  31.          BorderColor     =   &H00FFFFFF&
  32.          DrawMode        =   7  'Invert
  33.          FillColor       =   &H00FF000A&
  34.          FillStyle       =   0  'Solid
  35.          Height          =   255
  36.          Left            =   11880
  37.          Top             =   0
  38.          Width           =   255
  39.       End
  40.       Begin VB.Shape shpLeftBottom 
  41.          BorderColor     =   &H00FFFFFF&
  42.          DrawMode        =   7  'Invert
  43.          FillColor       =   &H0000FF00&
  44.          FillStyle       =   0  'Solid
  45.          Height          =   255
  46.          Left            =   11880
  47.          Top             =   8400
  48.          Width           =   255
  49.       End
  50.       Begin VB.Shape shpLeftTop 
  51.          BorderColor     =   &H00FFFFFF&
  52.          DrawMode        =   7  'Invert
  53.          FillColor       =   &H0000FFFF&
  54.          FillStyle       =   0  'Solid
  55.          Height          =   255
  56.          Left            =   0
  57.          Top             =   8400
  58.          Width           =   255
  59.       End
  60.       Begin VB.Shape shpRightTop 
  61.          BorderColor     =   &H00FFFFFF&
  62.          DrawMode        =   7  'Invert
  63.          FillColor       =   &H000000FF&
  64.          FillStyle       =   0  'Solid
  65.          Height          =   255
  66.          Left            =   0
  67.          Top             =   0
  68.          Width           =   255
  69.       End
  70.    End
  71.    Begin VB.PictureBox picSrc 
  72.       Appearance      =   0  'Flat
  73.       AutoRedraw      =   -1  'True
  74.       BackColor       =   &H00FFFFFF&
  75.       BorderStyle     =   0  'None
  76.       ForeColor       =   &H80000008&
  77.       Height          =   8655
  78.       Left            =   105
  79.       Picture         =   "Form1.frx":0000
  80.       ScaleHeight     =   577
  81.       ScaleMode       =   3  'Pixel
  82.       ScaleWidth      =   809
  83.       TabIndex        =   0
  84.       Top             =   105
  85.       Width           =   12135
  86.    End
  87.    Begin VB.PictureBox picDest 
  88.       Appearance      =   0  'Flat
  89.       AutoRedraw      =   -1  'True
  90.       AutoSize        =   -1  'True
  91.       BackColor       =   &H00FFFFFF&
  92.       BorderStyle     =   0  'None
  93.       ForeColor       =   &H80000008&
  94.       Height          =   8655
  95.       Left            =   105
  96.       ScaleHeight     =   577
  97.       ScaleMode       =   3  'Pixel
  98.       ScaleWidth      =   809
  99.       TabIndex        =   1
  100.       Top             =   105
  101.       Width           =   12135
  102.    End
  103. End
  104. Attribute VB_Name = "Form1"
  105. Attribute VB_GlobalNameSpace = False
  106. Attribute VB_Creatable = False
  107. Attribute VB_PredeclaredId = True
  108. Attribute VB_Exposed = False
  109. Dim LeftTopX As Single, LeftTopY As Single
  110. Dim RightTopX As Single, RightTopY As Single
  111. Dim LeftBottomX As Single, LeftBottomY As Single
  112. Dim RightBottomX As Single, RightBottomY As Single
  113.  
  114. Dim IsLeftTopOn As Boolean
  115. Dim IsRightTopOn As Boolean
  116. Dim IsLeftBottomOn As Boolean
  117. Dim IsRightBottomOn As Boolean
  118. Dim cLeftTopX, cLeftBottomX, cRightTopX, cRightBottomX
  119. Dim cLeftTopY, cLeftBottomY, cRightTopY, cRightBottomY
  120.  
  121. Private Declare Function SetStretchBltMode Lib "gdi32" (ByVal hdc As Long, ByVal nStretchMode As Long) As Long
  122. Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
  123.  
  124. Private Sub TransformVertical()
  125.     On Error Resume Next
  126.     
  127.     picDest.Cls
  128.     
  129.     
  130.     SetStretchBltMode picDest.hdc, 3
  131.     For i = 0 To picDest.ScaleHeight
  132.         cRightTopX = shpRightTop.Left - (i / (picSrc.ScaleWidth / (shpRightTop.Left - shpLeftTop.Left)))
  133.         cRightBottomX = shpRightBottom.Left + (i / (picSrc.ScaleWidth / (picSrc.ScaleWidth - (shpRightBottom.Left - (shpLeftBottom.Left - picSrc.ScaleWidth)))))
  134.         StretchBlt picDest.hdc, cRightTopX, i, cRightBottomX - cRightTopX, 1, picSrc.hdc, 0, i, picSrc.ScaleHeight, 1, vbSrcCopy
  135.     Next
  136.         
  137. End Sub
  138.  
  139. Private Sub TransformHorizontal()
  140.     On Error Resume Next
  141.     
  142.     picDest2.Cls
  143.     
  144.     SetStretchBltMode picDest2.hdc, 3
  145.     For i = 0 To picDest2.ScaleWidth
  146.         
  147.         cRightTopY = shpRightTop.Top - (i / (picDest2.ScaleHeight / (shpRightTop.Top - shpRightBottom.Top)))
  148.         cRightBottomY = shpLeftTop.Top + (i / (picDest2.ScaleHeight / (picDest2.ScaleHeight - (shpLeftTop.Top - (shpLeftBottom.Top - picDest2.ScaleHeight)))))
  149.         
  150.         StretchBlt picDest2.hdc, i, cRightTopY, 1, cRightBottomY - cRightTopY, picDest.hdc, i, 0, 1, picSrc.ScaleWidth, vbSrcCopy
  151.     Next
  152.     
  153. End Sub
  154.  
  155. Private Sub Form_Load()
  156.     
  157.     picSrc.PaintPicture picSrc.Picture, 0, 0, picSrc.ScaleWidth, picSrc.ScaleHeight
  158.     
  159.     picDest2_MouseMove 1, 0, shpLeftBottom.Left + 1, shpLeftTop.Top + 1
  160.     picDest2_MouseDown 1, 0, shpLeftBottom.Left + 1, shpLeftTop.Top + 1
  161.     
  162. End Sub
  163.  
  164. Private Sub picDest_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
  165.     Me.Caption = picDest.Point(x, y)
  166. End Sub
  167.  
  168. Private Sub picDest2_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  169.     If Button = 1 Then
  170.     
  171.         If IsInObject(shpLeftTop, x, y) = True Then
  172.             LeftTopX = x - shpLeftTop.Left
  173.             LeftTopY = y - shpLeftTop.Top
  174.             IsLeftTopOn = True
  175.         End If
  176.         
  177.         If IsInObject(shpRightTop, x, y) = True Then
  178.             RightTopX = x - shpRightTop.Left
  179.             RightTopY = y - shpRightTop.Top
  180.             IsRightTopOn = True
  181.         End If
  182.         
  183.         If IsInObject(shpLeftBottom, x, y) = True Then
  184.             LeftBottomX = x - shpLeftBottom.Left
  185.             LeftBottomY = y - shpLeftBottom.Top
  186.             IsLeftBottomOn = True
  187.         End If
  188.         
  189.         If IsInObject(shpRightBottom, x, y) = True Then
  190.             RightBottomX = x - shpRightBottom.Left
  191.             RightBottomY = y - shpRightBottom.Top
  192.             IsRightBottomOn = True
  193.         End If
  194.         
  195.     End If
  196. End Sub
  197.  
  198. Private Sub picDest2_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
  199.     If (IsLeftTopOn) Or (IsRightTopOn) Or (IsLeftBottomOn) Or (IsRightBottomOn) Then
  200.         TransformHorizontal
  201.         TransformVertical
  202.     End If
  203.     If Button = 1 Then
  204.         If IsLeftTopOn = True Then
  205.             shpLeftTop.Left = x - LeftTopX
  206.             shpLeftTop.Top = y - LeftTopY
  207.         End If
  208.         
  209.         If IsRightTopOn = True Then
  210.             shpRightTop.Left = x - RightTopX
  211.             shpRightTop.Top = y - RightTopY
  212.         End If
  213.         
  214.         If IsLeftBottomOn = True Then
  215.             shpLeftBottom.Left = x - LeftBottomX
  216.             shpLeftBottom.Top = y - LeftBottomY
  217.         End If
  218.         
  219.         If IsRightBottomOn = True Then
  220.             shpRightBottom.Left = x - RightBottomX
  221.             shpRightBottom.Top = y - RightBottomY
  222.         End If
  223.         
  224.     End If
  225. End Sub
  226.  
  227. Private Sub picDest2_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
  228.     IsLeftTopOn = False
  229.     IsRightTopOn = False
  230.     IsLeftBottomOn = False
  231.     IsRightBottomOn = False
  232. End Sub
  233. Private Function IsInObject(Object As Object, x, y) As Boolean
  234.     If ((y > Object.Top) And (y < Object.Height + Object.Top)) And _
  235.     ((x > Object.Left) And (x < Object.Width + Object.Left)) Then
  236.         IsInObject = True
  237.     Else
  238.         IsInObject = False
  239.     End If
  240. End Function
  241.  
  242. Private Sub HideShowShapes(TrueOrFalse As Boolean)
  243.     shpLeftBottom.Visible = TrueOrFalse
  244.     shpLeftTop.Visible = TrueOrFalse
  245.     shpRightBottom.Visible = TrueOrFalse
  246.     shpRightTop.Visible = TrueOrFalse
  247. End Sub
  248.