gpt4 book ai didi

vb6 - 当用户尝试在vb6中打开新实例时,返回到已经打开的应用程序

转载 作者:行者123 更新时间:2023-12-02 05:25:55 24 4
gpt4 key购买 nike

假设用户将我的视觉基本应用程序最小化到任务栏通知图标。现在,我想当用户打开一个新实例时,应该还原旧实例。

最佳答案

通常,您可以使用简并的​​方式使用DDE相当简单地执行此操作:

Form1.frm

Option Explicit
'This is Form1. To use as DDE source at design time we set:
' Form1.LinkMode = 1 (Source, i.e. vbLinkSource).
' Form1.LinkTopic = "Form1" (default).
'
'Note we use (hidden) Label1 on this Form as a DDE destination.

Private PrevState As Integer

Private Sub Form_LinkExecute(CmdStr As String, Cancel As Integer)
'Got a "command" so restore Form1 and accept the command.
WindowState = PrevState
Caption = "I am awake!"
Cancel = False
End Sub

Private Sub Form_Load()
PrevState = WindowState
End Sub

Private Sub Form_Resize()
If WindowState <> vbMinimized Then PrevState = WindowState
End Sub

Module1.bas
Option Explicit

Private Sub Main()
Load Form1
'After Form1 is loaded (hidden), try DDE link to possible prior copy.
With Form1.Label1
.LinkTopic = App.EXEName & "|Form1"
On Error Resume Next
.LinkMode = vbLinkManual
If Err.Number = 0 Then
On Error GoTo 0
'Link succeeded. Wake up prior copy via pushback to
'the DDE source, then unload Form1 and terminate.
.LinkExecute "Wake up!"
Unload Form1
Else
On Error GoTo 0
'Link failed, so we're 1st. Show Form1.
Form1.Show vbModal
End If
End With
End Sub

关于vb6 - 当用户尝试在vb6中打开新实例时,返回到已经打开的应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11669401/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com