GetOpenFileName API用的帮忙看看,急
GetOpenFileName
打开文件时,能否显示摸态窗口,不然他点一次就弹出个窗口,很不友好!
在此感谢
[解决办法]
这是OpenFileName结构:
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
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
第二个成员hwndOwner的值,指定为你的窗口句柄,就行了
MSDN里说得很清楚:
hwndOwner
Identifies the window that owns the dialog box. This member can be any valid window handle, or it can be NULL if the dialog box has no owner.
[解决办法]
很简单了:
你已经定义了一个OpenFileName类型的变量是吧?肯定是有的
然后:
变量.hwndOwner=[你的主窗口句柄]
就行了
这样做以后再把结构传给API.
[解决办法]
具体例子,可以看看这个类,它封装了通用对话框的功能,可以省个控件了:)
http://www.m5home.com/bbs/dispbbs.asp?boardID=10&ID=1100&page=1