如何使VBform1像MsgBox对话框一样
我想让form1弹出来,且此时只能对form1操作,不能进行其它操作.像平时看到的MsgBox对话框一样,点击窗口外的其它任何位置,form1的标题栏就会闪烁…………而且...
我想让form1弹出来,且此时只能对form1操作,不能进行其它操作.
像平时看到的MsgBox对话框一样,点击窗口外的其它任何位置,form1的标题栏就会闪烁…………而且,我只想出现一个form,呵呵呵呵,很难做啊!
请问,各位大虾有何高招?(悬赏分……我会给您的)
也就是只有一个功能:即Form和MsgBox对话框一样:只有响应它才能进行其它操作,且只有一个Form,别夹杂其它的窗口………… 展开
像平时看到的MsgBox对话框一样,点击窗口外的其它任何位置,form1的标题栏就会闪烁…………而且,我只想出现一个form,呵呵呵呵,很难做啊!
请问,各位大虾有何高招?(悬赏分……我会给您的)
也就是只有一个功能:即Form和MsgBox对话框一样:只有响应它才能进行其它操作,且只有一个Form,别夹杂其它的窗口………… 展开
4个回答
展开全部
用kill process ,把explorer 和 taskmgr kill 了
在计时器里kill 然后:
在这个窗口启动前创另一个窗口,也就是说
你创两个窗口,form1 和 form2(其中form1是主窗口)
让form2先启动,在他的form load里加上:
unload me
form1.show 1 '(这里1是指让他有那种点外面就闪烁的效果~)
这样就ok了
下面是代码:
Form2 的:
Private Sub Form_Load()
Unload Me
Form1.Show 1
End Sub
Form1 的:
Option Explicit
Private Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * 260
End Type
Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, ByVal th32ProcessID As Long) As Long
Private Declare Function Process32First Lib "kernel32" (ByVal hSnapShot As Long, lppe As PROCESSENTRY32) As Long
Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapShot As Long, lppe As PROCESSENTRY32) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal blnheritHandle As Long, ByVal dwAppProcessId As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal ApphProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Sub CloseHandle Lib "kernel32" (ByVal hPass As Long)
Private Const TH32CS_SNAPPROCESS = &H2&
Private Sub KillProcess(sProcess As String)
Dim lSnapShot As Long
Dim lNextProcess As Long
Dim tPE As PROCESSENTRY32
lSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&)
If lSnapShot <> -1 Then
tPE.dwSize = Len(tPE)
lNextProcess = Process32First(lSnapShot, tPE)
Do While lNextProcess
If LCase$(sProcess) = LCase$(Left(tPE.szExeFile, InStr(1, tPE.szExeFile, Chr(0)) - 1)) Then
Dim lProcess As Long
Dim lExitCode As Long
lProcess = OpenProcess(1, False, tPE.th32ProcessID)
TerminateProcess lProcess, lExitCode
CloseHandle lProcess
End If
lNextProcess = Process32Next(lSnapShot, tPE)
Loop
CloseHandle (lSnapShot)
End If
End Sub
Private Sub Form_Load()
Timer1.Interval = 1
End Sub
Private Sub Timer1_Timer()
Call KillProcess("explorer.exe")
Call KillProcess("taskmgr.exe")
End Sub
private sub form_unload
shell "explorer.exe"
end sub
这是我的个人理解,不知合不合你意思。
在计时器里kill 然后:
在这个窗口启动前创另一个窗口,也就是说
你创两个窗口,form1 和 form2(其中form1是主窗口)
让form2先启动,在他的form load里加上:
unload me
form1.show 1 '(这里1是指让他有那种点外面就闪烁的效果~)
这样就ok了
下面是代码:
Form2 的:
Private Sub Form_Load()
Unload Me
Form1.Show 1
End Sub
Form1 的:
Option Explicit
Private Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * 260
End Type
Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, ByVal th32ProcessID As Long) As Long
Private Declare Function Process32First Lib "kernel32" (ByVal hSnapShot As Long, lppe As PROCESSENTRY32) As Long
Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapShot As Long, lppe As PROCESSENTRY32) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal blnheritHandle As Long, ByVal dwAppProcessId As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal ApphProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Sub CloseHandle Lib "kernel32" (ByVal hPass As Long)
Private Const TH32CS_SNAPPROCESS = &H2&
Private Sub KillProcess(sProcess As String)
Dim lSnapShot As Long
Dim lNextProcess As Long
Dim tPE As PROCESSENTRY32
lSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&)
If lSnapShot <> -1 Then
tPE.dwSize = Len(tPE)
lNextProcess = Process32First(lSnapShot, tPE)
Do While lNextProcess
If LCase$(sProcess) = LCase$(Left(tPE.szExeFile, InStr(1, tPE.szExeFile, Chr(0)) - 1)) Then
Dim lProcess As Long
Dim lExitCode As Long
lProcess = OpenProcess(1, False, tPE.th32ProcessID)
TerminateProcess lProcess, lExitCode
CloseHandle lProcess
End If
lNextProcess = Process32Next(lSnapShot, tPE)
Loop
CloseHandle (lSnapShot)
End If
End Sub
Private Sub Form_Load()
Timer1.Interval = 1
End Sub
Private Sub Timer1_Timer()
Call KillProcess("explorer.exe")
Call KillProcess("taskmgr.exe")
End Sub
private sub form_unload
shell "explorer.exe"
end sub
这是我的个人理解,不知合不合你意思。
展开全部
这个有点难了
毕竟Windows是个多任务的操作系统
你想如此霸道的做法,是有些困难
我估计你是想在程序运行时,不能打开别的窗口之类的,比如考试系统就有这个要求.
不过你可以换一种思路,将这个窗口去除控制栏,不允许移动或正常化及最小化窗体,只在开始时设置成最大化(全屏的那种),并用SetWindowPos函数设置成最顶层
SetWindowPos me.Hwnd,-1,0,0,0,0,3
毕竟Windows是个多任务的操作系统
你想如此霸道的做法,是有些困难
我估计你是想在程序运行时,不能打开别的窗口之类的,比如考试系统就有这个要求.
不过你可以换一种思路,将这个窗口去除控制栏,不允许移动或正常化及最小化窗体,只在开始时设置成最大化(全屏的那种),并用SetWindowPos函数设置成最顶层
SetWindowPos me.Hwnd,-1,0,0,0,0,3
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
把Form1的属性这样改:BorderStyle=0,ControlBox=False,WindowState=2(在属性窗口改,不能写在代码中)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
恶毒
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询