home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD1078510192000.psc / CResize.cls < prev    next >
Encoding:
Visual Basic class definition  |  2000-09-03  |  3.8 KB  |  131 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "CResize"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15.  
  16. '   THE RESEIZE CLASS
  17. '   ~~~~~~~~~~~~~~~~~
  18.  
  19. 'You are free to use this class in your own projects n give
  20. 'me some credits when you do. Dont forget to visit my web
  21. 'site k?
  22.  
  23. '                               --- Author, Muhammad Abubakar
  24. '                                       <joehacker@yahoo.com>
  25. '                                       http://go.to/abubakar
  26.  
  27. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  28.  
  29. 'Key codes:
  30. '1  ->  top only
  31. '2  ->  left only
  32. '3  ->  top and left
  33. '4  ->  height only
  34. '5  ->  width only
  35. '6  ->  height and width
  36. '-----------------------
  37. Option Explicit
  38.  
  39. Enum eParams
  40.     RS_TopOnly = 1
  41.     RS_LeftOnly = 2
  42.     RS_Top_Left = 3
  43.     RS_HeightOnly = 4
  44.     RS_WidthOnly = 5
  45.     RS_Height_Width = 6
  46. End Enum
  47. Private Type cInfo
  48.     cControl As Control
  49.     cHeight As Integer
  50.     cWidth As Integer
  51.     cTop As Integer
  52.     cLeft As Integer
  53.     cInfo As Integer
  54. End Type
  55.  
  56. Private cArray() As cInfo
  57. Private Count As Integer
  58.  
  59. Private FormHeight As Integer
  60. Private FormWidth As Integer
  61.  
  62. Public Property Let hParam(ByVal fh As Integer)
  63.     FormHeight = fh
  64.         
  65. End Property
  66. Public Property Let wParam(ByVal fw As Integer)
  67.     FormWidth = fw
  68. End Property
  69. Public Sub Map(rCont As Control, SizeInfo As eParams)
  70.     Count = Count + 1
  71.     ReDim Preserve cArray(Count)
  72.     Set cArray(Count).cControl = rCont
  73.     cArray(Count).cInfo = SizeInfo
  74.     
  75.     Select Case SizeInfo
  76.         Case 1:
  77.             cArray(Count).cTop = FormHeight - rCont.Top
  78.         Case 2:
  79.             cArray(Count).cLeft = FormWidth - rCont.Left
  80.         Case 3:
  81.             cArray(Count).cTop = FormHeight - rCont.Top
  82.             cArray(Count).cLeft = FormWidth - rCont.Left
  83.         Case 4:
  84.             cArray(Count).cHeight = FormHeight - rCont.Height
  85.         Case 5:
  86.             cArray(Count).cWidth = FormWidth - rCont.Width
  87.         Case 6:
  88.             cArray(Count).cHeight = FormHeight - rCont.Height
  89.             cArray(Count).cWidth = FormWidth - rCont.Width
  90.         Case Else:
  91.             Exit Sub
  92.     End Select
  93.     
  94. End Sub
  95.  
  96. Public Sub rSize(cForm As Form)
  97.     
  98.     On Error Resume Next
  99.     Dim i As Integer, a As Integer, b As Integer
  100.     For i = 1 To Count
  101.         Select Case cArray(i).cInfo
  102.             Case 1:
  103.                 cArray(i).cControl.Top = cForm.Height - cArray(i).cTop
  104.             Case 2:
  105.                 cArray(i).cControl.Left = cForm.Width - cArray(i).cLeft
  106.             Case 3:
  107.                 cArray(i).cControl.Top = cForm.Height - cArray(i).cTop
  108.                 cArray(i).cControl.Left = cForm.Width - cArray(i).cLeft
  109.             Case 4:
  110.                 b = cForm.Height - cArray(i).cHeight
  111.                 If b < 0 Then b = 0
  112.                 cArray(i).cControl.Height = b 'cForm.Height - cArray(i).cHeight
  113.             Case 5:
  114.                 a = cForm.Width - cArray(i).cWidth
  115.                 If a < 0 Then a = 0
  116.                 cArray(i).cControl.Width = a 'cForm.Width - cArray(i).cWidth
  117.             Case 6:
  118.                 a = cForm.Width - cArray(i).cWidth
  119.                 b = cForm.Height - cArray(i).cHeight
  120.                 If a < 0 Then a = 0
  121.                 If b < 0 Then b = 0
  122.                 cArray(i).cControl.Height = b 'cForm.Height - cArray(i).cHeight
  123.                 cArray(i).cControl.Width = a 'cForm.Width - cArray(i).cWidth
  124.             
  125.                 
  126.         End Select
  127.     Next
  128.     Exit Sub
  129. End Sub
  130.  
  131.