如何在vb6中用程序激活表单

  • 本文关键字:程序 激活 表单 vb6 vb6
  • 更新时间 :
  • 英文 :


我正在构建VB6.0应用程序,用户在其中刷卡,表单会弹出一条感谢消息。休息都很好,唯一的问题是表单最小化,而不是它应该弹出
我在谷歌上搜索了他们的表格。激活,但当我写的时候会出错。

编译错误:找不到方法或数据成员

我是VB的新手,所以如果有任何天真的错误,请原谅
代码:

  Me.Hide
  Form2.Show
  Form2.Activate

我需要Form2弹出。

感谢

我能够通过实现

Private Sub Form_Load()
Dim lR As Long
     lR = SetTopMostWindow(Form2.hwnd, True)
End Sub

并添加了一个模块

Option Explicit
 Public Const SWP_NOMOVE = 2
 Public Const SWP_NOSIZE = 1
 Public Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
 Public Const HWND_TOPMOST = -1
 Public Const HWND_NOTOPMOST = -2
 Declare Function SetWindowPos Lib "user32" _
       (ByVal hwnd As Long, _
       ByVal hWndInsertAfter As Long, _
       ByVal x As Long, _
       ByVal y As Long, _
       ByVal cx As Long, _
       ByVal cy As Long, _
       ByVal wFlags As Long) As Long
 Public Function SetTopMostWindow(hwnd As Long, Topmost As Boolean) _
    As Long
    If Topmost = True Then 'Make the window topmost
       SetTopMostWindow = SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, _
          0, FLAGS)
    Else
       SetTopMostWindow = SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, _
          0, 0, FLAGS)
       SetTopMostWindow = False
    End If
 End Function</pre>

可以参考https://support.microsoft.com/en-us/kb/184297

感谢