26-08-16, 05:43 PM
(آخر تعديل لهذه المشاركة : 26-08-16, 05:46 PM {2} بواسطة محمد كريّم.)
اضفت متغير بولياني في الفورم
Dim finish_closing As Boolean
حتى نخزن فيه الحالة لتجنب تنفيذ e.cancel لانها تمنع اغلاق الفورم
واستخدمت Application.Exit() بدلا من Me.Close()
هذا كود الفورم بالكامل
تعديل / هذا في حالة كان اغلاق هذا الفورم مراد به انهاء عمل البرنامج بالكامل
ويبدو ان استخدام Application.Exit() لا داعي له هنا
استبدله بـ
e.Cancel = False
Dim finish_closing As Boolean
حتى نخزن فيه الحالة لتجنب تنفيذ e.cancel لانها تمنع اغلاق الفورم
واستخدمت Application.Exit() بدلا من Me.Close()
هذا كود الفورم بالكامل
كود :
Public Class Form1
Dim finish_closing As Boolean
Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
If (finish_closing) Then
Application.Exit()
Else
e.Cancel = True
Timer2.Enabled = True
End If
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Opacity = 0
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Me.Opacity = Me.Opacity + 0.03
If Me.Opacity > 97 Then
Timer1.Enabled = False
End If
End Sub
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
Me.Opacity -= 0.1
If Me.Opacity < 0.03 Then
finish_closing = True
Me.Close()
End If
End Sub
End Classتعديل / هذا في حالة كان اغلاق هذا الفورم مراد به انهاء عمل البرنامج بالكامل
ويبدو ان استخدام Application.Exit() لا داعي له هنا
استبدله بـ
e.Cancel = False

