发新话题
打印

冰点版主有个超级大难题,已经问了好多人

工程名为DDE,窗口名是FRM
创建一个PICTURE,名字是P,用来启动DDELINK
如果是多窗体,就在MDIFORM的LOAD中写,如果是单窗体,就在FORM的LOAD中写:
If App.PrevInstance = True Then
    Me.LinkMode = 0
    Me.LinkTopic = ""
    P.LinkMode = 0
    P.LinkTopic = "DDE|Frm"
    P.LinkMode = 2
    P.LinkExecute Command
    End
Else
    OpenFile(Command)'OpenFile是你的程序中用来打开文件的函数。
End If
然后,在LinkExecute中写:
OpenFile(CmdStr)
Cancel = False

这样就可以得到第二次打开的文件的名字啦。

TOP

做了一个完整的,不过不是多窗体的。
工程名:DDETRY,窗体名:FRMTRY,PICTURE名:P,RTFBOX名:TEXT1

Option Explicit

Private Sub Form_LinkExecute(CmdStr As String, Cancel As Integer)
Dim Tmp As String
If CmdStr <> "" Then
    Tmp = CmdStr
    If Left(Tmp, 1) = Chr(34) Then Tmp = Right(Tmp, Len(Tmp) - 1)
    If Right(Tmp, 1) = Chr(34) Then Tmp = Left(Tmp, Len(Tmp) - 1)
    Text1.Text = ""
    Text1.FileName = Tmp
    Me.Caption = Tmp
End If
Cancel = False
End Sub

Private Sub Form_Load()
Dim Tmp As String
If App.PrevInstance = True Then
    Me.LinkMode = 0
    Me.LinkTopic = ""
    P.LinkMode = 0
    P.LinkTopic = "DDETry|FrmTry"
    P.LinkMode = 2
    P.LinkExecute Command
    End
Else
    If Command <> "" Then
        Tmp = Command$
        If Left(Tmp, 1) = Chr(34) Then Tmp = Right(Tmp, Len(Tmp) - 1)
        If Right(Tmp, 1) = Chr(34) Then Tmp = Left(Tmp, Len(Tmp) - 1)
        Text1.FileName = Tmp
        Me.Caption = Tmp
    End If
End If
Text1.Top = 0
Text1.Left = 0
End Sub

Private Sub Form_Resize()
Text1.Height = Me.ScaleHeight
Text1.Width = Me.ScaleWidth
End Sub

TOP

发新话题