منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : ممكن تعديل بسيط على هذا المشروع
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
انا عاوز اول لما تفتح s.txt Form1 show and Form Hide
عملت موضوع لاكن لم يتم الحل الموضوع القديم
كود المشروع

كود :
Imports System.Runtime.InteropServices
Public Class Form
    Dim Selectd As Integer, Big As Long
    Private Const AW_BLEND = &H1
    Private Declare Function AnimateWindow Lib "user32" (ByVal hwnd As Int32, ByVal dwTime As Int32, ByVal dwFlags As Int32) As Boolean
    Dim winHide As Integer = &H1
    Dim winBlend As Integer = &H1

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        Static a As Integer
        a = a + 1
        If a = 25 Then
            AnimateWindow(Me.Handle.ToInt32, CInt(1), winHide Or winBlend)
            Timer2.Enabled = False
            For Each c As Process In Process.GetProcesses
                If c.MainWindowTitle = "s.txt - Notepad" Then
                    Me.Hide()
                    Form1.Show()
                End If
            Next
        End If
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Select Case Selectd
            Case 1
                Pname.Text = "                                                                   Wait File Open"
                Dim path = Application.StartupPath + "\s.txt"
                If (System.IO.File.Exists(path)) Then
                    Process.Start(path)
                Else
                    Pname.Text = "File Not Found"
                End If

                Timer1.Enabled = False
        End Select
        Selectd = Selectd + 1

    End Sub
End Class

هذا رابط المشروع
ممكن تصحيح هذا الكود
كود :
If Process.Wait("s.txt") Then
            Me.Hide()
            Form1.Show()
        End If
إستبدل الأمر الموجود في Form1 بـ :
كود :
Imports System.Runtime.InteropServices
Public Class Form
    Dim Selectd As Integer, Big As Long
    Private Const AW_BLEND = &H1
    Private Declare Function AnimateWindow Lib "user32" (ByVal hwnd As Int32, ByVal dwTime As Int32, ByVal dwFlags As Int32) As Boolean
    Dim winHide As Integer = &H1
    Dim winBlend As Integer = &H1

    Private Sub Form_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
        Pname.Text = "Wait File Open"
        Dim path = Application.StartupPath + "\s.txt"
        If (System.IO.File.Exists(path)) Then
            Dim Process As Process = Process.Start(path)
            Pname.Text = "File Opened"
            Me.Hide()
            Form1.Show()
            Process.[color=#ff0000]WaitForExit[/color]()
            Pname.Text = "File Closed"
            Form1.Hide()
            Me.Show()
        Else
            Pname.Text = "File Not Found"
        End If
    End Sub
End Class
Osama_Ghareeb كتب :إستبدل الأمر الموجود في Form1 بـ :
كود :
Imports System.Runtime.InteropServices
Public Class Form
    Dim Selectd As Integer, Big As Long
    Private Const AW_BLEND = &H1
    Private Declare Function AnimateWindow Lib "user32" (ByVal hwnd As Int32, ByVal dwTime As Int32, ByVal dwFlags As Int32) As Boolean
    Dim winHide As Integer = &H1
    Dim winBlend As Integer = &H1

    Private Sub Form_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
        Pname.Text = "Wait File Open"
        Dim path = Application.StartupPath + "\s.txt"
        If (System.IO.File.Exists(path)) Then
            Dim Process As Process = Process.Start(path)
            Pname.Text = "File Opened"
            Me.Hide()
            Form1.Show()
            Process.[color=#ff0000]WaitForExit[/color]()
            Pname.Text = "File Closed"
            Form1.Hide()
            Me.Show()
        Else
            Pname.Text = "File Not Found"
        End If
    End Sub
End Class

جزاك الله كل خير اخى
هل من الممكن بدل استخدام
كود :
Dim path = Application.StartupPath + "\s.txt"
        If (System.IO.File.Exists(path)) Then
            Dim Process As Process = Process.Start(path)
فتح الملف من الخارج ؟
وى عندما يفتح الملف Form تظهر؟
كود :
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim Processes As Process() = Process.GetProcessesByName("notepad")
        If Processes.Count > 1 Then
            For Each Process In Processes
                 If Process.MainWindowTitle.StartsWith("s.txt") Then
                    Pname.Text = "File Opened"
                    Me.Hide()
                    Form1.Show()
                    Process.WaitForExit()
                    Pname.Text = "File Closed"
                    Form1.Hide()
                    Me.Show()
                    Exit For
                End If
            Next
        End If
    End Sub
Osama_Ghareeb كتب :
كود :
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim Processes As Process() = Process.GetProcessesByName("notepad")
        If Processes.Count > 1 Then
            For Each Process In Processes
                 If Process.MainWindowTitle.StartsWith("s.txt") Then
                    Pname.Text = "File Opened"
                    Me.Hide()
                    Form1.Show()
                    Process.WaitForExit()
                    Pname.Text = "File Closed"
                    Form1.Hide()
                    Me.Show()
                    Exit For
                End If
            Next
        End If
    End Sub

جزاك الله كل خير وى حماك الله من كل شر
لم ينفع هذا الكود أخى
Dim Processes As Process() = Process.GetProcessesByName("notepad")
If Processes.Count > 1 Then
For Each Process In Processes
If Process.MainWindowTitle.StartsWith("s.txt") Then
بفتح الملف لاكن لا شئ يحدوث
عفوا كان في خطأ بسيط في الأمر واللي هو رقم 1 المفروض يكون رقم 0 ...

كود :
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim Processes As Process() = Process.GetProcessesByName("notepad")' البحث عن عمليات برنامج المفكرة
        If [color=#ff0000]Processes.Count > 0[/color] Then ' إذا وجد البرنامج أي عملية
            For Each Process In Processes
                 If Process.MainWindowTitle.StartsWith("s.txt") Then  ' البحث في عناوين العمليات عن اسم الملف
                    Pname.Text = "File Opened"
                    Me.Hide()
                    Form1.Show()
                    Process.WaitForExit()
                    Pname.Text = "File Closed"
                    Form1.Hide()
                    Me.Show()
                    Exit For
                End If
            Next
        End If
    End Sub
Osama_Ghareeb كتب :عفوا كان في خطأ بسيط في الأمر واللي هو رقم 1 المفروض يكون رقم 0 ...

كود :
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim Processes As Process() = Process.GetProcessesByName("notepad")' البحث عن عمليات برنامج المفكرة
        If [color=#ff0000]Processes.Count > 0[/color] Then ' إذا وجد البرنامج أي عملية
            For Each Process In Processes
                 If Process.MainWindowTitle.StartsWith("s.txt") Then  ' البحث في عناوين العمليات عن اسم الملف
                    Pname.Text = "File Opened"
                    Me.Hide()
                    Form1.Show()
                    Process.WaitForExit()
                    Pname.Text = "File Closed"
                    Form1.Hide()
                    Me.Show()
                    Exit For
                End If
            Next
        End If
    End Sub
لم يعمل أيضآ أخى معلش هاتعبك معايه شويه ممكن تعملى مثال صغير؟
ارجو منك التقيد بكتابة عنوان واضح لمواضيعك
والابتعاد عن كتابة كلمات ارجوكم سااعدوني مهم جداً وللضرورة و ....الخ
تقيد بمضمون السؤال .

تحياتي لك
ابو سامي