| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1510 人关注过本帖
标题:[源码]使用API函数创建”打开文件“对话框
只看楼主 加入收藏
griefforyou
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:3336
专家分:0
注 册:2004-4-15
收藏
 问题点数:0 回复次数:2 
[源码]使用API函数创建”打开文件“对话框

以后可以不用CommonDialog控件了

Option Explicit

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 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

Private Sub Cancel_Click() Unload Me End Sub

Private Sub FileOpen_Click() Dim ofn As OPENFILENAME Dim rtn As String

ofn.lStructSize = Len(ofn) ofn.hwndOwner = Me.hWnd ofn.hInstance = App.hInstance ofn.lpstrFilter = "所有文件" ofn.lpstrFile = Space(254) ofn.nMaxFile = 255 ofn.lpstrFileTitle = Space(254) ofn.nMaxFileTitle = 255 ofn.lpstrInitialDir = App.Path ofn.lpstrTitle = "打开文件" ofn.flags = 6148

rtn = GetOpenFileName(ofn)

If rtn >= 1 Then Filename.Text = ofn.lpstrFile Else Filename.Text = "Cancel Was Pressed" End If End Sub

Private Sub Form_Load() Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2 End Sub

搜索更多相关主题的帖子: API 对话框 Long 源码 函数 
2004-05-10 12:01
tvrc200379
Rank: 1
等 级:新手上路
帖 子:351
专家分:0
注 册:2004-3-30
收藏
得分:0 

好文章啊!有用啊

我顶,顶,顶


我是灌水天堂的新版主,请新老用户来报道啊 (欢迎来灌水。。。) 哈哈哈。。。。 http://websx.home./bbs/list.asp?boardid=35
2004-05-10 15:06
rzw龙行天下
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2021-9-12
收藏
得分:0 
太厉害了,找了好长时间,终于解决了,
2021-10-04 21:50
快速回复:[源码]使用API函数创建”打开文件“对话框
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016384 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved