home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / Righello207379732007.psc / Ruler.ctl < prev   
Text File  |  2007-01-23  |  23KB  |  655 lines

  1. VERSION 5.00
  2. Begin VB.UserControl Ruler 
  3.    Alignable       =   -1  'True
  4.    AutoRedraw      =   -1  'True
  5.    BackStyle       =   0  'Transparent
  6.    ClientHeight    =   315
  7.    ClientLeft      =   0
  8.    ClientTop       =   0
  9.    ClientWidth     =   4815
  10.    BeginProperty Font 
  11.       Name            =   "Verdana"
  12.       Size            =   8.25
  13.       Charset         =   0
  14.       Weight          =   400
  15.       Underline       =   0   'False
  16.       Italic          =   0   'False
  17.       Strikethrough   =   0   'False
  18.    EndProperty
  19.    PropertyPages   =   "Ruler.ctx":0000
  20.    ScaleHeight     =   315
  21.    ScaleMode       =   0  'User
  22.    ScaleWidth      =   4815
  23.    ToolboxBitmap   =   "Ruler.ctx":003B
  24.    Begin VB.PictureBox picRulerSxBot 
  25.       Appearance      =   0  'Flat
  26.       AutoSize        =   -1  'True
  27.       BackColor       =   &H80000005&
  28.       BorderStyle     =   0  'None
  29.       ForeColor       =   &H80000008&
  30.       Height          =   225
  31.       Left            =   1560
  32.       Picture         =   "Ruler.ctx":034D
  33.       ScaleHeight     =   225
  34.       ScaleWidth      =   165
  35.       TabIndex        =   2
  36.       Top             =   120
  37.       Width           =   165
  38.    End
  39.    Begin VB.PictureBox picRulerDx 
  40.       Appearance      =   0  'Flat
  41.       AutoSize        =   -1  'True
  42.       BorderStyle     =   0  'None
  43.       ForeColor       =   &H80000008&
  44.       Height          =   120
  45.       Left            =   2310
  46.       Picture         =   "Ruler.ctx":048B
  47.       ScaleHeight     =   8
  48.       ScaleMode       =   3  'Pixel
  49.       ScaleWidth      =   11
  50.       TabIndex        =   3
  51.       Top             =   120
  52.       Width           =   165
  53.    End
  54.    Begin VB.PictureBox picRulerSxTop 
  55.       Appearance      =   0  'Flat
  56.       AutoSize        =   -1  'True
  57.       BorderStyle     =   0  'None
  58.       ForeColor       =   &H80000008&
  59.       Height          =   120
  60.       Left            =   870
  61.       Picture         =   "Ruler.ctx":0575
  62.       ScaleHeight     =   8
  63.       ScaleMode       =   3  'Pixel
  64.       ScaleWidth      =   11
  65.       TabIndex        =   1
  66.       Top             =   30
  67.       Width           =   165
  68.    End
  69.    Begin VB.PictureBox picRighello 
  70.       AutoRedraw      =   -1  'True
  71.       BackColor       =   &H00FFFFFF&
  72.       BorderStyle     =   0  'None
  73.       FillStyle       =   2  'Horizontal Line
  74.       BeginProperty Font 
  75.          Name            =   "Verdana"
  76.          Size            =   6.75
  77.          Charset         =   0
  78.          Weight          =   400
  79.          Underline       =   0   'False
  80.          Italic          =   0   'False
  81.          Strikethrough   =   0   'False
  82.       EndProperty
  83.       Height          =   255
  84.       Left            =   60
  85.       ScaleHeight     =   255
  86.       ScaleWidth      =   4695
  87.       TabIndex        =   0
  88.       Top             =   0
  89.       Width           =   4695
  90.       Begin VB.Line Line1 
  91.          BorderColor     =   &H80000010&
  92.          BorderStyle     =   3  'Dot
  93.          DrawMode        =   6  'Mask Pen Not
  94.          Visible         =   0   'False
  95.          X1              =   2010
  96.          X2              =   2010
  97.          Y1              =   60
  98.          Y2              =   270
  99.       End
  100.    End
  101.    Begin VB.Menu mnuMenu 
  102.       Caption         =   "Scala"
  103.       Visible         =   0   'False
  104.       Begin VB.Menu mnuMode 
  105.          Caption         =   "Centimetri"
  106.          Index           =   0
  107.       End
  108.       Begin VB.Menu mnuMode 
  109.          Caption         =   "Inch"
  110.          Index           =   1
  111.       End
  112.       Begin VB.Menu mnuMode 
  113.          Caption         =   "Pixel"
  114.          Index           =   2
  115.       End
  116.       Begin VB.Menu mnuMode 
  117.          Caption         =   "Twip"
  118.          Index           =   3
  119.       End
  120.    End
  121. End
  122. Attribute VB_Name = "Ruler"
  123. Attribute VB_GlobalNameSpace = False
  124. Attribute VB_Creatable = True
  125. Attribute VB_PredeclaredId = False
  126. Attribute VB_Exposed = True
  127. Attribute VB_Ext_KEY = "PropPageWizardRun" ,"Yes"
  128. Option Explicit
  129.  
  130. ''Basato su codice di MystikalSoft, riadattato da
  131. ''Daniele Binaghi, www.pecorElettriche.it:
  132. ''- aggiunti cursori, con relative proprietα ed eventi
  133. ''- modificato indicatore di posizione, sostituendo con oggetto linea
  134. ''- aggiunte pagine proprietα generale e cursori
  135. ''- aggiunta gestione del minimo per la scala
  136.  
  137. Public Enum rlrBorderStyle
  138.     rlrNoBorder = 0
  139.     rlrSunken = 1
  140.     rlrSunkenOuter = 2
  141.     rlrRaised = 3
  142.     rlrRaisedInner = 4
  143.     rlrBump = 5
  144.     rlrEtched = 6
  145. End Enum
  146. Public Enum rlrOrientationConstants
  147.     rlrHorizontal = 0
  148.     rlrVertical = 1
  149. End Enum
  150.  
  151. Private Const BI_RGB = 0&
  152. Private Const DIB_RGB_COLORS = 0 '  tabella colori in RGB
  153. Private Const pixR As Integer = 3
  154. Private Const pixG As Integer = 2
  155. Private Const pixB As Integer = 1
  156.  
  157. Private Type BITMAPINFOHEADER '40 bytes
  158.     biSize As Long
  159.     biWidth As Long
  160.     biHeight As Long
  161.     biPlanes As Integer
  162.     biBitCount As Integer
  163.     biCompression As Long
  164.     biSizeImage As Long
  165.     biXPelsPerMeter As Long
  166.     biYPelsPerMeter As Long
  167.     biClrUsed As Long
  168.     biClrImportant As Long
  169. End Type
  170.  
  171. Private Type RGBQUAD
  172.     rgbBlue As Byte
  173.     rgbGreen As Byte
  174.     rgbRed As Byte
  175.     rgbReserved As Byte
  176. End Type
  177.  
  178. Private Type BITMAPINFO
  179.     bmiHeader As BITMAPINFOHEADER
  180.     bmiColors As RGBQUAD
  181. End Type
  182.  
  183. Private Declare Function GetDIBits Lib "gdi32" (ByVal aHDC As Long, ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As Long, lpBits As Any, lpBI As BITMAPINFO, ByVal wUsage As Long) As Long
  184. Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
  185. Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
  186. Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
  187. Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
  188.  
  189. Private Type RECT
  190.     Left As Long
  191.     Top As Long
  192.     Right As Long
  193.     Bottom As Long
  194. End Type
  195.  
  196. Public Enum RulerModeConst
  197.     Millimetri = 0
  198.     Inch = 1
  199.     Pixel = 2
  200.     Twips = 3
  201. End Enum
  202.  
  203. Private Type POINTAPI
  204.         X As Long
  205.         Y As Long
  206. End Type
  207. Private Declare Function ClientToScreen Lib "user32" (ByVal hWnd As Long, lpPoint As POINTAPI) As Long
  208. Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
  209.  
  210. 'Valori predefiniti proprietα:
  211. Const m_def_Minimo = 0
  212. Const m_def_Locked = False
  213. Const m_def_Position = False
  214. Const m_def_RulerScaleMode = 0
  215. Const m_def_BorderStyle = 2
  216. Const m_Def_Orientation = 0
  217. 'Variabili proprietα:
  218. Dim m_Minimo As Single
  219. Dim m_Locked As Boolean
  220. Dim m_Position As Boolean
  221. Dim m_MarginColor As OLE_COLOR
  222. Dim m_lMargineSx As Long
  223. Dim m_lMargineDx As Long
  224. Dim m_lRulerSxTop As Long
  225. Dim m_lRulerSxBot As Long
  226. Dim m_lRulerDx As Long
  227. Dim m_BorderStyle As rlrBorderStyle
  228. Dim m_bPositionVisible As Boolean
  229. Dim m_Orientation As rlrOrientationConstants
  230. Dim m_RulerScaleMode As Variant
  231. Dim X1 As Single
  232. Dim RScale As Long
  233. 'Dichiarazioni di eventi:
  234. Event Click()
  235. Event DblClick()
  236. Event MargineSxChanged(X As Long)
  237. Event MargineDxChanged(X As Long)
  238. Event RulerSxBotChanged(X As Long) 'MappingInfo=picRulerSxBot,picRulerSxBot,-1,MouseMove
  239. Event RulerSxBotMouseDown()
  240. Event RulerSxBotMouseUp()
  241. Event RulerSxTopChanged(X As Long) 'MappingInfo=picRulerSxTop,picRulerSxTop,-1,MouseMove
  242. Event RulerSxTopMouseDown()
  243. Event RulerSxTopMouseUp()
  244. Event RulerDxChanged(X As Long) 'MappingInfo=picRulerDx,picRulerDx,-1,MouseMove
  245. Event RulerDxMouseDown()
  246. Event RulerDxMouseUp()
  247.  
  248. Public Property Get BorderStyle() As rlrBorderStyle
  249. Attribute BorderStyle.VB_Description = "Restituisce o imposta lo stile del bordo di un oggetto"
  250.     BorderStyle = m_BorderStyle
  251. End Property
  252.  
  253. Public Property Let BorderStyle(New_Val As rlrBorderStyle)
  254.     m_BorderStyle = New_Val
  255.     picRighello.Cls
  256.     EdgeSubClass picRighello.hWnd, New_Val
  257.     pDrawRuler
  258.     PropertyChanged "BorderStyle"
  259. End Property
  260.  
  261. Public Property Get Position() As Boolean
  262. Attribute Position.VB_Description = "Visualizza o nasconde l'indicatore di posizione del cursore"
  263. Attribute Position.VB_ProcData.VB_Invoke_Property = "Generale"
  264.     Position = m_bPositionVisible
  265. End Property
  266.  
  267. Public Property Let Position(Visible As Boolean)
  268.     m_bPositionVisible = Visible
  269.     Line1.Visible = Visible
  270.     PropertyChanged "Position"
  271. End Property
  272.  
  273. Public Property Get RulerSxTop() As Single
  274. Attribute RulerSxTop.VB_ProcData.VB_Invoke_Property = "Cursori"
  275.     RulerSxTop = m_lRulerSxTop / RScale
  276. End Property
  277.  
  278. Public Property Let RulerSxTop(X As Single)
  279. Dim lX As Long
  280.     lX = CLng(X * RScale)
  281.     If lX > m_lRulerDx Then lX = m_lRulerDx
  282.     picRulerSxTop.Left = lX - m_Minimo * RScale - 8
  283.     m_lRulerSxTop = lX
  284.     PropertyChanged "RulerSxTop"
  285. End Property
  286.  
  287. Public Property Get MargineSx() As Single
  288. Attribute MargineSx.VB_ProcData.VB_Invoke_Property = "Cursori"
  289.     MargineSx = m_lMargineSx / RScale
  290. End Property
  291.     
  292. Public Property Let MargineSx(X As Single)
  293.     On Error Resume Next
  294.     m_lMargineSx = CLng(X * RScale)
  295.     If Err Then m_lMargineSx = UserControl.Width
  296.     On Error GoTo 0
  297.     Call pDrawRuler(True)
  298.     PropertyChanged "MargineSx"
  299. End Property
  300.  
  301. Public Property Get MargineDx() As Single
  302. Attribute MargineDx.VB_ProcData.VB_Invoke_Property = "Cursori"
  303.     MargineDx = m_lMargineDx / RScale
  304. End Property
  305.  
  306. Public Property Let MargineDx(X As Single)
  307.     On Error Resume Next
  308.     m_lMargineDx = CLng(X * RScale)
  309.     If Err Then m_lMargineDx = UserControl.Width
  310.     On Error GoTo 0
  311.     Call pDrawRuler(True)
  312.     PropertyChanged "MargineDx"
  313. End Property
  314.  
  315. Public Property Get RulerSxBot() As Single
  316. Attribute RulerSxBot.VB_ProcData.VB_Invoke_Property = "Cursori"
  317.     RulerSxBot = m_lRulerSxBot / RScale
  318. End Property
  319.  
  320. Public Property Let RulerSxBot(X As Single)
  321. Dim lX As Long
  322.     lX = CLng(X * RScale)
  323.     If lX > m_lRulerDx Then lX = m_lRulerDx
  324.     picRulerSxBot.Left = lX - m_Minimo * RScale - 8
  325.     m_lRulerSxBot = lX
  326.     PropertyChanged "RulerSxBot"
  327. End Property
  328.  
  329. Public Property Get RulerDx() As Single
  330. Attribute RulerDx.VB_ProcData.VB_Invoke_Property = "Cursori"
  331.     RulerDx = m_lRulerDx / RScale
  332. End Property
  333.  
  334. Public Property Let RulerDx(X As Single)
  335. Dim lX As Long
  336.     lX = CLng(X * RScale)
  337.     If lX < m_lRulerSxTop Or lX < m_lRulerSxBot Then
  338.         lX = m_lRulerSxTop
  339.         If lX < m_lRulerSxBot Then lX = m_lRulerSxBot
  340.     End If
  341.     picRulerDx.Left = lX - m_Minimo * RScale - 8
  342.     m_lRulerDx = lX
  343.     PropertyChanged "RulerDx"
  344. End Property
  345.  
  346. Public Sub FormattaTesto()
  347.     RaiseEvent RulerSxTopChanged(m_lRulerSxTop - m_Minimo * RScale)
  348.     RaiseEvent RulerSxBotChanged(m_lRulerSxBot - m_Minimo * RScale)
  349.     RaiseEvent RulerDxChanged(m_lRulerDx - m_Minimo * RScale)
  350. End Sub
  351.  
  352. Private Sub pDrawRuler(Optional Clear As Boolean)
  353. Dim Sincr As Single 'Scalemode is in TWIPS 1440 per inch
  354. Dim I As Integer 'Number of segment across form
  355. Dim iMinimo As Integer 'Parte intera del minimo
  356. Dim iDecimale As Integer 'Parte decimale del minimo
  357.     Sincr = RScale / 10
  358.     iMinimo = Fix(m_Minimo)
  359.     iDecimale = Int(Abs(m_Minimo - iMinimo) * 10) + 1
  360.     With picRighello
  361.         If Clear Then .Cls
  362.         If m_Orientation = rlrVertical Then
  363.             picRighello.Line (0, 0)-(picRighello.ScaleWidth, m_lMargineSx - m_Minimo * RScale), m_MarginColor, BF
  364.             picRighello.Line (0, m_lMargineDx - m_Minimo * RScale)-(picRighello.ScaleWidth, picRighello.ScaleHeight), m_MarginColor, BF
  365.             Do While Sincr < .ScaleHeight
  366.                 'Number of sections
  367.                 For I = iDecimale To 10
  368.                     'Size of Tics
  369.                     If I = 10 Then
  370.                         picRighello.Line (0, Sincr)-(.ScaleHeight, Sincr)
  371.                         .CurrentX = 0
  372.                         picRighello.Print CStr(Int(Sincr / RScale) + iMinimo)
  373.                         iDecimale = 1
  374.                     ElseIf I = Int(10 * 0.5) Then '50%
  375.                         picRighello.Line (.ScaleWidth - (.ScaleWidth * 0.5), Sincr)-(.ScaleWidth, Sincr)
  376.                     Else
  377.                         picRighello.Line (.ScaleWidth - (.ScaleWidth * 0.125), Sincr)-(.ScaleWidth, Sincr)
  378.                     End If
  379.                     Sincr = Sincr + (RScale / 10)
  380.                 Next
  381.             Loop
  382.         Else
  383.             picRighello.Line (0, 0)-(m_lMargineSx - m_Minimo * RScale, picRighello.ScaleHeight), m_MarginColor, BF
  384.             picRighello.Line (m_lMargineDx - m_Minimo * RScale, 0)-(picRighello.ScaleWidth, picRighello.ScaleHeight), m_MarginColor, BF
  385.             Do While Sincr < .ScaleWidth
  386.                 'Number of sections
  387.                 For I = iDecimale To 10
  388.                     'Size of Tics
  389.                     If I = 10 Then
  390.                         picRighello.Line (Sincr, 0)-(Sincr, .ScaleHeight)
  391.                         .CurrentY = 0
  392.                         picRighello.Print " " + CStr(Int(Sincr / RScale) + iMinimo)
  393.                         iDecimale = 1
  394.                     ElseIf I = Int(10 * 0.5) Then '50%
  395.                         picRighello.Line (Sincr, .ScaleHeight - (.ScaleHeight * 0.5))-(Sincr, .ScaleHeight)
  396.                     Else
  397.                         picRighello.Line (Sincr, .ScaleHeight - (.ScaleHeight * 0.125))-(Sincr, .ScaleHeight)
  398.                     End If
  399.                     Sincr = Sincr + (RScale / 10)
  400.                 Next
  401.             Loop
  402.         End If
  403.     End With
  404. End Sub
  405.  
  406. Public Sub MouseMoved(X As Single, Y As Single)
  407.     picRighello.AutoRedraw = False
  408.     If m_bPositionVisible Then
  409.         If m_Orientation = rlrHorizontal Then
  410.             Line1.X1 = X
  411.             Line1.X2 = X
  412.         Else
  413.             Line1.Y1 = Y
  414.             Line1.Y2 = Y
  415.         End If
  416.     End If
  417.     Line1.Visible = m_bPositionVisible
  418.     picRighello.AutoRedraw = True
  419. End Sub
  420.  
  421. Private Sub picRulerDx_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  422.     RaiseEvent RulerDxMouseDown
  423. End Sub
  424.  
  425. Private Sub picRulerDx_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  426. Dim PosCur As POINTAPI
  427. Dim PosPic As POINTAPI
  428. Dim lX As Long
  429.     If Button > 0 Then
  430.         GetCursorPos PosCur
  431.         ClientToScreen picRighello.hWnd, PosPic
  432.         lX = (PosCur.X - PosPic.X) * Screen.TwipsPerPixelX
  433.         If picRulerDx.Left = lX Then Exit Sub
  434.         If lX < m_lRulerSxTop - m_Minimo * RScale Then lX = m_lRulerSxTop - m_Minimo * RScale
  435.         If lX < m_lRulerSxBot - m_Minimo * RScale Then lX = m_lRulerSxBot - m_Minimo * RScale
  436.         If lX > UserControl.Width - 196 Then lX = UserControl.Width - 196
  437.         picRulerDx.Left = lX - 8
  438.         m_lRulerDx = lX + m_Minimo * RScale
  439.         picRighello.Refresh
  440.         RaiseEvent RulerDxChanged(lX)
  441.     End If
  442. End Sub
  443.  
  444. Private Sub picRulerDx_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  445.     RaiseEvent RulerDxMouseUp
  446. End Sub
  447.  
  448. Private Sub picRulerSxTop_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  449.     RaiseEvent RulerSxTopMouseDown
  450. End Sub
  451.  
  452. Private Sub picRulerSxTop_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  453. Dim PosCur As POINTAPI
  454. Dim PosPic As POINTAPI
  455. Dim lX As Long
  456.     If Button > 0 Then
  457.         GetCursorPos PosCur
  458.         ClientToScreen picRighello.hWnd, PosPic
  459.         lX = (PosCur.X - PosPic.X) * Screen.TwipsPerPixelX
  460.         If picRulerSxTop.Left = lX Then Exit Sub
  461.         If lX < 0 Then lX = 0
  462.         If lX > m_lRulerDx - m_Minimo * RScale Then lX = m_lRulerDx - m_Minimo * RScale
  463.         picRulerSxTop.Left = lX - 8
  464.         m_lRulerSxTop = lX + m_Minimo * RScale
  465.         picRighello.Refresh
  466.         RaiseEvent RulerSxTopChanged(lX)
  467.         RaiseEvent RulerSxBotChanged(picRulerSxBot.Left)
  468.     End If
  469. End Sub
  470.  
  471. Private Sub picRulerSxTop_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  472.     RaiseEvent RulerSxTopMouseUp
  473. End Sub
  474.  
  475. Private Sub mnuMode_Click(Index As Integer)
  476.     RulerScaleMode = Index
  477. End Sub
  478.  
  479. Private Sub picRulerSxBot_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  480.     RaiseEvent RulerSxBotMouseDown
  481. End Sub
  482.  
  483. Private Sub picRulerSxBot_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  484. Dim PosCur As POINTAPI
  485. Dim PosPic As POINTAPI
  486. Dim lX As Long
  487. Dim lSopraX As Long
  488. Dim lMin As Long
  489.     If Button > 0 Then
  490.         GetCursorPos PosCur
  491.         ClientToScreen picRighello.hWnd, PosPic
  492.         lX = (PosCur.X - PosPic.X) * Screen.TwipsPerPixelX
  493.         If picRulerSxBot.Left = lX Then Exit Sub
  494.         lMin = m_Minimo * RScale
  495.         If lX < 0 Then lX = 0
  496.         If lX > m_lRulerDx - lMin Then lX = m_lRulerDx - lMin
  497.         If Y > 6 Then
  498.             lSopraX = lX - m_lRulerSxBot + lMin
  499.             lSopraX = m_lRulerSxTop + lSopraX
  500.             If lSopraX < 0 + lMin Then lSopraX = 0 + lMin
  501.             If lSopraX > m_lRulerDx - lMin Then
  502.                 lSopraX = m_lRulerDx - lMin
  503.                 lX = lSopraX - (m_lRulerSxTop - m_lRulerSxBot)
  504.             End If
  505.             picRulerSxTop.Left = lSopraX - lMin - 8
  506.             m_lRulerSxTop = lSopraX
  507.         End If
  508.         picRulerSxBot.Left = lX - 8
  509.         m_lRulerSxBot = lX + lMin
  510.         picRighello.Refresh
  511.         UserControl.Refresh
  512.         RaiseEvent RulerSxTopChanged(lSopraX - lMin)
  513.         RaiseEvent RulerSxBotChanged(lX)
  514.     End If
  515. End Sub
  516.  
  517. Private Sub picRulerSxBot_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  518.     RaiseEvent RulerSxBotMouseUp
  519. End Sub
  520.  
  521. Private Sub picRighello_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  522.     If Button = 2 Then
  523.         Dim I As Integer
  524.         For I = 0 To mnuMode.Count - 1
  525.             mnuMode(I).Checked = False
  526.         Next I
  527.         mnuMode(RulerScaleMode).Checked = True
  528.         UserControl.PopupMenu mnuMenu
  529.     End If
  530. End Sub
  531.  
  532. Private Sub UserControl_Initialize()
  533.     RScale = 570
  534.     picRulerSxTop.ScaleMode = vbPixels
  535.     pTrimPicture picRulerSxTop, vbRed
  536.     picRulerSxBot.ScaleMode = vbPixels
  537.     pTrimPicture picRulerSxBot, vbRed
  538.     picRulerDx.ScaleMode = vbPixels
  539.     pTrimPicture picRulerDx, vbRed
  540. End Sub
  541.  
  542. Private Sub UserControl_InitProperties()
  543.     m_RulerScaleMode = m_def_RulerScaleMode
  544.     m_BorderStyle = m_def_BorderStyle
  545.     m_Position = m_def_Position
  546.     m_Locked = m_def_Locked
  547.     m_Orientation = m_Def_Orientation
  548.     m_Minimo = m_def_Minimo
  549. End Sub
  550.  
  551. Private Sub UserControl_Resize()
  552.     picRighello.Move 64, 0, UserControl.Width - 128, UserControl.ScaleHeight - 92
  553.     If m_Orientation = rlrHorizontal Then
  554.         picRulerSxTop.Top = 0
  555.         picRulerSxBot.Top = UserControl.ScaleHeight - 208
  556.         picRulerDx.Top = picRulerSxBot.Top
  557.         Line1.X2 = Line1.X1
  558.         Line1.Y1 = 0
  559.         Line1.Y2 = picRighello.ScaleHeight
  560.     Else
  561.         Line1.X1 = 0
  562.         Line1.X2 = picRighello.ScaleWidth
  563.         Line1.Y2 = Line1.Y1
  564.     End If
  565.     UserControl.Cls
  566.     Call pDrawRuler(True)
  567. End Sub
  568.  
  569. Private Sub UserControl_Show()
  570.     Call pDrawRuler(True)
  571. End Sub
  572.  
  573. Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
  574.     BorderStyle = PropBag.ReadProperty("BorderStyle", m_def_BorderStyle)
  575.     picRighello.BackColor = PropBag.ReadProperty("BackColor", &HFFFFFF)
  576.     picRighello.ForeColor = PropBag.ReadProperty("ForeColor", &H80000012)
  577.     m_MarginColor = PropBag.ReadProperty("MarginColor", vbButtonFace)
  578.     Orientation = PropBag.ReadProperty("Orientation", m_Def_Orientation)
  579.     Minimo = PropBag.ReadProperty("Minimo", m_def_Minimo)
  580.     RulerScaleMode = PropBag.ReadProperty("RulerScaleMode", m_def_RulerScaleMode)
  581.     MargineSx = PropBag.ReadProperty("MargineSx", 0)
  582.     MargineDx = PropBag.ReadProperty("MargineDx", UserControl.Width / RScale)
  583.     RulerSxBot = PropBag.ReadProperty("RulerSxBot", 0)
  584.     RulerSxTop = PropBag.ReadProperty("RulerSxTop", 0)
  585.     RulerDx = PropBag.ReadProperty("RulerDx", UserControl.Width / RScale)
  586.     Position = PropBag.ReadProperty("Position", m_def_Position)
  587.     UserControl.MousePointer = PropBag.ReadProperty("MousePointer", 0)
  588.     Set MouseIcon = PropBag.ReadProperty("MouseIcon", Nothing)
  589.     UserControl.Enabled = PropBag.ReadProperty("Locked", Not m_def_Locked)
  590. End Sub
  591.  
  592. Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
  593.     Call PropBag.WriteProperty("BorderStyle", m_BorderStyle, m_def_BorderStyle)
  594.     Call PropBag.WriteProperty("BackColor", picRighello.BackColor, &HFFFFFF)
  595.     Call PropBag.WriteProperty("ForeColor", picRighello.ForeColor, &H80000012)
  596.     Call PropBag.WriteProperty("MarginColor", m_MarginColor, vbButtonFace)
  597.     Call PropBag.WriteProperty("Orientation", m_Orientation, m_Def_Orientation)
  598.     Call PropBag.WriteProperty("Minimo", m_Minimo, m_def_Minimo)
  599.     Call PropBag.WriteProperty("RulerScaleMode", m_RulerScaleMode, m_def_RulerScaleMode)
  600.     Call PropBag.WriteProperty("MargineSx", m_lMargineSx / RScale, 0)
  601.     Call PropBag.WriteProperty("MargineDx", m_lMargineDx / RScale, UserControl.Width / RScale)
  602.     Call PropBag.WriteProperty("RulerSxBot", m_lRulerSxBot / RScale, 0)
  603.     Call PropBag.WriteProperty("RulerSxTop", m_lRulerSxTop / RScale, 0)
  604.     Call PropBag.WriteProperty("RulerDx", m_lRulerDx / RScale, UserControl.Width / RScale)
  605.     Call PropBag.WriteProperty("Position", m_Position, m_def_Position)
  606.     Call PropBag.WriteProperty("MousePointer", UserControl.MousePointer, 0)
  607.     Call PropBag.WriteProperty("MouseIcon", MouseIcon, Nothing)
  608.     Call PropBag.WriteProperty("Locked", m_Locked, m_def_Locked)
  609. End Sub
  610.  
  611. Private Sub pTrimPicture(ByVal pic As PictureBox, ByVal transparent_color As Long)
  612. ' Restrict the form to its "transparent" pixels.
  613. Const RGN_OR = 2
  614. Dim bitmap_info As BITMAPINFO
  615. Dim pixels() As Byte
  616. Dim bytes_per_scanLine As Integer
  617. Dim pad_per_scanLine As Integer
  618. Dim transparent_r As Byte
  619. Dim transparent_g As Byte
  620. Dim transparent_b As Byte
  621. Dim wid As Integer
  622. Dim hgt As Integer
  623. Dim X As Integer
  624. Dim Y As Integer
  625. Dim start_x As Integer
  626. Dim stop_x As Integer
  627. Dim combined_rgn As Long
  628. Dim new_rgn As Long
  629.     ' Prepare the bitmap description.
  630.     With bitmap_info.bmiHeader
  631.         .biSize = 40
  632.         .biWidth = pic.ScaleWidth
  633.         ' Use negative height to scan top-down.
  634.         .biHeight = -pic.ScaleHeight
  635.         .biPlanes = 1
  636.         .biBitCount = 32
  637.         .biCompression = BI_RGB
  638.         bytes_per_scanLine = ((((.biWidth * .biBitCount) + 31) \ 32) * 4)
  639.         pad_per_scanLine = bytes_per_scanLine - (((.biWidth * .biBitCount) + 7) \ 8)
  640.         .biSizeImage Orientation)
  641.     MBLong)
  642. ' Restrict t(.biWidth * P MBLong)
  643. ' udCur.X - PosPic.X) * Screen.TwipsPosPic.X) * Screen.Twic 4
  644.     RulerScaleMode = Index
  645. End Sub
  646. inter", Us Sub
  647. inter", Us Wter", Us Sub
  648. intea, &H8000T
  649. intea, &H800.Twic 4
  650.     RulerScaleMRPINFO
  651. Dim pixels() As Byte
  652. Dimn( Subi2
  653. DeMR
  654. Dim pixels() B* P MBLols() B* P Mels() B* P MBLols() B* P Mels() B* P MBLols() B* PlerScaleMRPINFO
  655. Dim pixels() AsItpXg,kProp rEItp /  n