VB怎么让Form2始终在Form1前面?
答案:2 悬赏:0 手机版
解决时间 2021-03-08 05:01
- 提问者网友:听门外雪花风
- 2021-03-07 15:58
点击Form1出现Form2,再点击Form1可以对Form1进行操作,但Form2始终在最前面。请问用VB怎么实现上述效果?
最佳答案
- 五星知识达人网友:拜訪者
- 2021-03-07 17:12
Form1中的代码(添加个按钮)
Private Sub Command1_Click()
Form2.Show
End Sub
***************************************************************
Form2中的代码
Private 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)
Private Sub Form_Load()
Me.Show
Call SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3)
'……其它代码
End Sub
Private Sub Command1_Click()
Form2.Show
End Sub
***************************************************************
Form2中的代码
Private 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)
Private Sub Form_Load()
Me.Show
Call SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3)
'……其它代码
End Sub
全部回答
- 1楼网友:话散在刀尖上
- 2021-03-07 17:31
建立一个类模块 在里边定一个公共的
type parm str as string end type public parm1 as parm '初始化
在form1 点继续的时候写
parm1.str = text1.value
form2.show
unload me
在form2里边放一个文本框或者标签 ,当窗体加载的时候写
text1.value = parm1.str
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯