如何在vb6中将表单从后台带到前面 [英] How to bring form from background to front in vb6

查看:71
本文介绍了如何在vb6中将表单从后台带到前面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在VB6中有一个form1在后台运行,因为Me.Visible = False。它在HID模式下获得键盘输入,当在Text_change I上时,它显示另一个具有Thank You消息的form2。

一切正常,但Form2最小化我想让它弹出来。

我用谷歌搜索它有助于使用Me.SetFocus我在两种形式上都使用它但没有去。我再次尝试了Form1.visible = True它仍然是最小化的。



请让我知道我还能尝试什么。



感谢

Hi,
I have one form1 in VB6 running in background as Me.Visible=False. It gets keyboard entry in HID mode and when in does on Text_change I and showing another form2 which has Thank You message.
All works fine but Form2 is minimized I want it to be popped out.
I googled it aid to use Me.SetFocus I have used it on both forms but No go . I tried Form1.visible= True again it remains minimized.

Please let me know what else I can try.

Thank

推荐答案

我能够实现

I am able to achieve by
Private Sub Form_Load()

Dim lR As Long
         lR = SetTopMostWindow(Form2.hwnd, True)

End Sub







并添加了一个模块






and added a module

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







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



谢谢




One can refer to https://support.microsoft.com/en-us/kb/184297

Thanks


这篇关于如何在vb6中将表单从后台带到前面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆