小弟我的程序应该如何改?怎么实现"打开对话框"那样,窗体以外部分不接受操作
我的程序应该怎么改?如何实现"打开对话框"那样,窗体以外部分不接受操作?
我的本意是想自己画一form,实现 "打开对话框 "那样的功能,在弹出form后只响应form内的操作,以外部分不响应,但是为什么我用ClipCursor在父窗体可以实现鼠标限制在窗体里面,但是当作为子窗体或被调用窗体时,且窗体属性设置StartUPposition=2窗体中心时,就没办法实现所要的功能呢了?
或者哪位高手知道 "打开对话框 "如何实现的方法,给小弟提供一个思路,谢谢!
Private Type RECT
left As Long
top As Long
right As Long
bottom As Long
End Type
Private Type POINT
x As Long
y As Long
End Type
Private Declare Sub ClipCursor Lib "user32 " (lpRect As Any)
Private Declare Sub GetClientRect Lib "user32 " (ByVal hWnd As Long, lpRect As RECT)
Private Declare Sub ClientToScreen Lib "user32 " (ByVal hWnd As Long, lpPoint As POINT)
Private Declare Sub OffsetRect Lib "user32 " (lpRect As RECT, ByVal x As Long, ByVal y As Long)
Private Sub Form_Load()
Command1.Caption = "Limit Cursor Movement "
Command2.Caption = "Release Limit "
End Sub
Private Sub Command1_Click()
'Limits the Cursor movement to within the form.
Dim client As RECT
Dim upperleft As POINT
'Get information about our wndow
GetClientRect Me.hWnd, client
upperleft.x = client.left
upperleft.y = client.top
ClientToScreen Me.hWnd, upperleft
'move our rectangle
OffsetRect client, upperleft.x, upperleft.y
'limit the cursor movement
ClipCursor client
End Sub
Private Sub Command2_Click()
'Releases the cursor limits
ClipCursor ByVal 0&
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Releases the cursor limits
ClipCursor ByVal 0&
End Sub
------解决方案--------------------
打开文件对话框不用自己画啊,用api就可以show出来了。
Private Declare Function GetOpenFileName Lib "comdlg32.dll " Alias "GetOpenFileNameA " (pOpenfilename As OPENFILENAME) As Long
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
我的本意是想自己画一form,实现 "打开对话框 "那样的功能,在弹出form后只响应form内的操作,以外部分不响应,但是为什么我用ClipCursor在父窗体可以实现鼠标限制在窗体里面,但是当作为子窗体或被调用窗体时,且窗体属性设置StartUPposition=2窗体中心时,就没办法实现所要的功能呢了?
或者哪位高手知道 "打开对话框 "如何实现的方法,给小弟提供一个思路,谢谢!
Private Type RECT
left As Long
top As Long
right As Long
bottom As Long
End Type
Private Type POINT
x As Long
y As Long
End Type
Private Declare Sub ClipCursor Lib "user32 " (lpRect As Any)
Private Declare Sub GetClientRect Lib "user32 " (ByVal hWnd As Long, lpRect As RECT)
Private Declare Sub ClientToScreen Lib "user32 " (ByVal hWnd As Long, lpPoint As POINT)
Private Declare Sub OffsetRect Lib "user32 " (lpRect As RECT, ByVal x As Long, ByVal y As Long)
Private Sub Form_Load()
Command1.Caption = "Limit Cursor Movement "
Command2.Caption = "Release Limit "
End Sub
Private Sub Command1_Click()
'Limits the Cursor movement to within the form.
Dim client As RECT
Dim upperleft As POINT
'Get information about our wndow
GetClientRect Me.hWnd, client
upperleft.x = client.left
upperleft.y = client.top
ClientToScreen Me.hWnd, upperleft
'move our rectangle
OffsetRect client, upperleft.x, upperleft.y
'limit the cursor movement
ClipCursor client
End Sub
Private Sub Command2_Click()
'Releases the cursor limits
ClipCursor ByVal 0&
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Releases the cursor limits
ClipCursor ByVal 0&
End Sub
------解决方案--------------------
打开文件对话框不用自己画啊,用api就可以show出来了。
Private Declare Function GetOpenFileName Lib "comdlg32.dll " Alias "GetOpenFileNameA " (pOpenfilename As OPENFILENAME) As Long
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long