ProsesBar (Çalışma anında nesne ekleme-Class Modul)
#1
Class:
Visual Basic
  1. '*********************************************************
  2. '*********************************************************
  3. '*** Zeki Gürsoy 2009 ***
  4. '*** www.access-sql.com ***
  5. '*********************************************************
  6. '*********************************************************
  7. Private WithEvents LBL As MSForms.Label
  8. '---------------------
  9. Private vMax As Single
  10. Private vMin As Single
  11. '---------------------
  12. Private vTop As Single
  13. Private vLeft As Single
  14. '---------------------
  15. Private vValue As Single
  16. '---------------------
  17. Private f As UserForm
  18. '---------------------
  19. Private Const ALTBAR_GENISLIK As Single = 200 'Aynı zamanda üstbar için geçerli. > 255 olamaz!!
  20. Private Const ALTBAR_YUKSEKLIK As Single = 15
  21. Private Const ORTABAR_GENISLIK As Single = 195 'AltBar-5 dir.
  22. Private Const ORTABAR_YUKSEKLIK As Single = 10.5 'AltBar-4,5 dur.
  23. '---------------------
  24. Private xx As Single, yy As Single
  25. '**********************************************************
  26. Private Sub Class_Initialize()
  27. Dim iStr As String
  28.  
  29. vMax = 100
  30. vMin = 0
  31. vValue = 0
  32. vTop = 1
  33. vLeft = 1
  34.  
  35. If (Dir(Environ$("SystemRoot") & "\System32\Config.conf") <> "") Then
  36.  
  37. Open Environ$("SystemRoot") & "\System32\Config.conf" For Input As #1
  38. Line Input #1, iStr
  39. Close #1
  40.  
  41. If (iStr <> "") Then
  42. vTop = Split(iStr, ";")(0)
  43. vLeft = Split(iStr, ";")(1)
  44. End If
  45. End If
  46.  
  47. End Sub
  48.  
  49. Private Sub Class_Terminate()
  50. On Error Resume Next
  51. Set f = Nothing
  52. Set LBL = Nothing
  53. End Sub
  54.  
  55. Public Property Get Max() As Single
  56. Max = vMax
  57. End Property
  58.  
  59. Public Property Let Max(deg As Single)
  60. vMax = deg
  61. End Property
  62.  
  63. Public Property Get Min() As Single
  64. Max = vMin
  65. End Property
  66.  
  67. Public Property Let Min(deg As Single)
  68. 'vMin = deg
  69. If deg <> 0 Then _
  70. Err.Raise 54, , _
  71. "Minimum değer '0' dan farklı olamaz..! <Zeki Gürsoy>"
  72. End Property
  73.  
  74. Public Property Get Top() As Single
  75. Top = vTop
  76. End Property
  77.  
  78. Public Property Let Top(deg As Single)
  79. vTop = deg
  80. End Property
  81.  
  82. Public Property Get Left() As Single
  83. Left = vLeft
  84. End Property
  85.  
  86. Public Property Let Left(deg As Single)
  87. vLeft = deg
  88. End Property
  89.  
  90. Public Property Get Value() As Single
  91. Value = vValue
  92. End Property
  93.  
  94. Public Property Let Value(deg As Single)
  95. vValue = deg
  96. 'ALTBAR_GENISLIK > 255 olursa aşağıda hata verir. (CByte olduğu için.)
  97. f.Controls("LblOrta").Width = CByte((vValue / Me.Max) * ORTABAR_GENISLIK)
  98. f.Controls("LblUst").Caption = "% " & CByte((vValue / Me.Max) * 100)
  99. End Property
  100.  
  101. Public Property Let User_Form(UF As UserForm)
  102. Set f = UF
  103. Create_ProsesBar
  104. End Property
  105.  
  106. Private Sub Create_ProsesBar()
  107. Dim CTRL As Control
  108. Set CTRL = f.Controls.Add("Forms.Label.1", "LblAlt")
  109. With CTRL
  110. .Left = vLeft
  111. .Top = vTop
  112. .Width = ALTBAR_GENISLIK
  113. .Height = ALTBAR_YUKSEKLIK
  114. .BackColor = &HFFFF& 'Sarı
  115. .SpecialEffect = 2
  116. End With
  117.  
  118. Set CTRL = f.Controls.Add("Forms.Label.1", "LblOrta")
  119. With CTRL
  120. .Left = vLeft + 2.5
  121. .Top = vTop + 2
  122. .Width = vValue
  123. .Height = ORTABAR_YUKSEKLIK
  124. .BackColor = &HFF& 'Kırmızı
  125. End With
  126.  
  127. Set CTRL = f.Controls.Add("Forms.Label.1", "LblUst")
  128. With CTRL
  129. .Left = vLeft
  130. .Top = vTop
  131. .Width = ALTBAR_GENISLIK
  132. .Height = ALTBAR_YUKSEKLIK
  133. .BackStyle = 0
  134. .TextAlign = 2
  135. .Font.Bold = True
  136. .Font.Charset = 162
  137. .Font.Size = 10
  138. .ForeColor = &H800000 'Lacivert
  139. End With
  140.  
  141. Set LBL = f.Controls("LblUst")
  142. Set CTRL = Nothing
  143. End Sub
  144.  
  145. Private Sub LBL_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  146. xx = X
  147. yy = Y
  148. End Sub
  149.  
  150. Private Sub LBL_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  151. If Button = 1 Then
  152. With LBL
  153. .Top = .Top + (Y - yy)
  154. .Left = .Left + (X - xx)
  155. Open Environ$("SystemRoot") & "\System32\Config.conf" For Output As #1
  156. Print #1, .Top & ";" & .Left
  157. Close #1
  158. End With
  159.  
  160. With f
  161. With .Controls("LblOrta")
  162. .Top = .Top + (Y - yy)
  163. .Left = .Left + (X - xx)
  164. End With
  165. With .Controls("LblAlt")
  166. .Top = .Top + (Y - yy)
  167. .Left = .Left + (X - xx)
  168. End With
  169. End With
  170.  
  171. End If
  172. End Sub



Form:
Visual Basic
  1. Private c As ProsesBar
  2.  
  3. Private Sub CommandButton1_Click()
  4. For i = 1 To c.Max
  5. DoEvents
  6. c.Value = i
  7. Next
  8. End Sub
  9.  
  10. Private Sub UserForm_Activate()
  11. Set c = New ProsesBar
  12. With c
  13. .Max = 10000
  14. .User_Form = Me
  15. End With
  16. End Sub
  17.  
  18. Private Sub UserForm_QueryClose(Cancel As Integer, _
  19. CloseMode As Integer)
  20. Set c = Nothing
  21. End Sub




Eklenti Dosyaları
.rar   progress.rar (Boyut: 17,17 KB / İndirilme: 101)



  Alıntı
Bu mesajı beğenenler:
#2
Zeki, çok güzel bir örnek bu.. Bugünlerde progress olayları coştu valla Wink
Javascript
  1. this.setState({sign:"Here comes the sun...."})







  Alıntı
Bu mesajı beğenenler:
#3
Paylaşım için teşekkürler...



  Alıntı
Bu mesajı beğenenler:
#4
Paylaşıma çok teşekkürler.



  Alıntı
Bu mesajı beğenenler:
#5
Zeki harika bir örnek hazılmaşsın.. Class Modul hakkında fikir sahibi olmamız açısından da faydalı oldu..

Bu türdeki diğer çalışmalarını da dört gözle bekliyoruz.. Wink



  Alıntı
Bu mesajı beğenenler:
#6
Beğendiğinize sevindim dostlarım. Class moduller hakkında derli toplu anlatım hazırlamaya çalışacağım. Wink



  Alıntı
Bu mesajı beğenenler:


Benzer Konular...
Konu: Yazar Cevaplar: Gösterim: Son Mesaj
  bir çalışma kitabından diğerine alt alta kopyalama 88888888 5 2.491 04-03-2014, 15:19
Son Mesaj: 88888888

Foruma Git:


Bu konuyu görüntüleyen kullanıcı(lar): 1 Ziyaretçi