说三道四技术文摘-感悟人生的经典句子
说三道四 > 文档快照

通用对话框专辑(全) -VB资料

HTML文档下载 WORD文档下载 PDF文档下载
通用对话框专辑(全) -VB资料
使用API调用Winodws各种通用对话框(Common Diaglog)的方法(一)

1.文件属性对话框
Type SHELLEXECUTEINFO
cbSize As Long
fMask As Long
hwnd As Long
lpVerb As String
lpFile As String
lpParameters As String
lpDirectory As String
nShow As Long
hInstApp As Long
lpIDList As Long '可选参数
lpClass As String '可选参数
hkeyClass As Long '可选参数
dwHotKey As Long '可选参数
hIcon As Long '可选参数
hProcess As Long '可选参数
End Type

Const SEE_MASK_INVOKEIDLIST = &HC
Const SEE_MASK_NOCLOSEPROCESS = &H40
Const SEE_MASK_FLAG_NO_UI = &H400

Declare Function ShellExecuteEX Lib "shell32.dll" Alias "ShellExecuteEx" _
(SEI As SHELLEXECUTEINFO) As Long
Public Function ShowProperties(filename As String, OwnerhWnd As Long) As Long
'打开指定文件的属性对话框,如果返回值<=32则出错
Dim SEI As SHELLEXECUTEINFO
Dim r As Long
With SEI
.cbSize = Len(SEI)
.fMask = SEE_MASK_NOCLOSEPROCESS Or SEE_MASK_INVOKEIDLIST Or SEE_MASK_FLAG_NO_UI
.hwnd = OwnerhWnd
.lpVerb = "properties"
.lpFile = filename
.lpParameters = vbNullChar
.lpDirectory = vbNullChar
.nShow = 0
.hInstApp = 0
.lpIDList = 0
End With
r = ShellExecuteEX(SEI)
ShowProperties = SEI.hInstApp
End Function

新建一个工程,添加一个按钮和名为Text1的文本框
把以下代码置入CommandbButton_Click 中
Dim r As Long
Dim fname As String
'从Text1 中获取文件名及路径
fname = (Text1)
r = ShowProperties(fname, Me.hwnd)
If r <= 32 Then MsgBox "Error"

2.使用Win95的关于对话框
Private Declare Function ShellAbout Lib "shell32.dll" _
Alias "ShellAboutA" (ByVal hwnd As Long, ByVal szApp As String, _
ByVal szOtherStuff As String, ByVal hIcon As Long) As Long
示例:
Dim x As Long
x = shellabout (Form1.hwnd, "Visual Basic 6.0", _
"Alp Studio MouseTracker Ver 1.0", Form1.icon)

2.调用"捕获打印机端口"对话框
Private Declare Function WNetConnectionDialog Lib "mpr.dll" _
(ByVal hwnd As Long, ByVal dwType As Long) As Long
示例:
Dim x As Long
x = WNetConnectionDialog(Me.hwnd, 2)

3.调用颜色对话框
Private Type ChooseColor
lStructSize As Long
hwndOwner As Long
hInstance As Long
rgbResult As Long
lpCustColors As String
flags As Long
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Private Declare Function ChooseColor Lib "comdlg32.dll" Alias "ChooseColorA" (pChoosecolor As ChooseColor) As Long

将以下代码置入某一事件中:
Dim cc As ChooseColor
Dim CustColor(16) As Long
cc.lStructSize = Len(cc)
cc.hwndOwner = Form1.hWnd
cc.hInstance = App.hInstance
cc.flags = 0
cc.lpCustColors = String$(16 * 4, 0)
Dim a
Dim x
Dim c1
Dim c2
Dim c3
Dim c4
a = ChooseColor(cc)
Cls
If (a) Then
MsgBox "Color chosen:" & Str$(cc.rgbResult)

For x = 1 To Len(cc.lpCustColors) Step 4
c1 = Asc(Mid$(cc.lpCustColors, x, 1))
c2 = Asc(Mid$(cc.lpCustColors, x + 1, 1))
c3 = Asc(Mid$(cc.lpCustColors, x + 2, 1))
c4 = Asc(Mid$(cc.lpCustColors, x + 3, 1))
CustColor(x / 4) = (c1) + (c2 * 256) + (c3 * 65536) + (c4 * 16777216)
MsgBox "Custom Color " & Int(x / 4) & " = " & CustColor(x / 4)
Next x
Else
MsgBox "Cancel was pressed"
End If

4.调用复制磁盘对话框
Private Declare Function SHFormatDrive Lib "shell32" (ByVal hwnd As Long, ByVal Drive As Long, ByVal fmtID As Long, ByVal options As Long) As Long
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long

示例:
向窗体中添加一个名为Drive1的DriveListBox,将以下代码置入某一事件中
Dim DriveLetter$, DriveNumber&, DriveType&
Dim RetVal&, RetFromMsg&
DriveLetter = UCase(Drive1.Drive)
DriveNumber = (Asc(DriveLetter) - 65)
DriveType = GetDriveType(DriveLetter)
If DriveType = 2 Then 'Floppies, etc
RetVal = Shell("rundll32.exe diskcopy.dll,DiskCopyRunDll " _
& DriveNumber & "," & DriveNumber, 1) 'Notice space after
Else ' Just in case 'DiskCopyRunDll
RetFromMsg = MsgBox("Only floppies can" & vbCrLf & _
"be diskcopied!", 64, "DiskCopy Example")
End If

5.调用格式化软盘对话框
Private Declare Function SHFormatDrive Lib "shell32" (ByVal hwnd As Long, ByVal Drive As Long, ByVal fmtID As Long, ByVal options As Long) As Long
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
参数设置:
fmtID-
3.5" 5.25"
-------------------------
0 1.44M 1.2M
1 1.44M 1.2M
2 1.44M 1.2M
3 1.44M 360K
4 1.44M 1.2M
5 720K 1.2M
6 1.44M 1.2M
7 1.44M 1.2M
8 1.44M 1.2M
9 1.44M 1.2M

选项
0 快速
1 完全
2 只复制系统文件
3 只复制系统文件
4 快速
5 完全
6 只复制系统文件
7 只复制系统文件
8 快速
9 完全
示例:要求同上
Dim DriveLetter$, DriveNumber&, DriveType&
Dim RetVal&, RetFromMsg%
DriveLetter = UCase(Drive1.Drive)
DriveNumber = (Asc(DriveLetter) - 65) ' Change letter to Number: A=0
DriveType = GetDriveType(DriveLetter)
If DriveType = 2 Then 'Floppies, etc
RetVal = SHFormatDrive(Me.hwnd, DriveNumber, 0&, 0&)
Else
RetFromMsg = MsgBox("This drive is NOT a removeable" & vbCrLf & _
"drive! Format this drive?", 276, "SHFormatDrive Example")
Select Case RetFromMsg
Case 6 'Yes
' UnComment to do it...
'RetVal = SHFormatDrive(Me.hwnd, DriveNumber, 0&, 0&)
Case 7 'No
' Do nothing
End Select
End If
-----------------------------------------------------------------------------
使用API调用Winodws各种通用对话框(Common Diaglog)的方法(二)

1.选择目录/文件夹对话框
将以下代码置于一模块中
Option Explicit
' 调用方式:: string = BrowseForFolders(Hwnd,TitleOfDialog)
' 例如:String1 = BrowseForFolders(Hwnd, "Select target folder...")
Public Type BrowseInfo
hwndOwner As Long
pIDLRoot As Long
pszDisplayName As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type
Public Const BIF_RETURNONLYFSDIRS = 1
Public Const MAX_PATH = 260
Public Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
Public Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Public Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Public Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long

Public Function BrowseForFolder(hwndOwner As Long, sPrompt As String) As String
Dim iNull As Integer
Dim lpIDList As Long
Dim lResult As Long
Dim sPath As String
Dim udtBI As BrowseInfo
'初始化变量
With udtBI
.hwndOwner = hwndOwner
.lpszTitle = lstrcat(sPrompt, "")
.ulFlags = BIF_RETURNONLYFSDIRS
End With
'调用 API
lpIDList = SHBrowseForFolder(udtBI)
If lpIDList Then
sPath = String$(MAX_PATH, 0)
lResult = SHGetPathFromIDList(lpIDList, sPath)
Call CoTaskMemFree(lpIDList)
iNull = InStr(sPath, vbNullChar)
If iNull Then sPath = Left$(sPath, iNull - 1)
End If
'如果选择取消, sPath = ""
BrowseForFolder = sPath
End Function
2.调用"映射网络驱动器"对话框
Private/Public Declare Function WNetConnectionDialog Lib "mpr.dll" _
(ByVal hwnd As Long, ByVal dwType As Long) As Long
x% = WNetConnectionDialog(Me.hwnd, 1)
3.调用"打开文件"对话框
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 Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
将以下代码置于某一事件中
Dim ofn As OPENFILENAME
ofn.lStructSize = Len(ofn)
ofn.hwndOwner = Form1.hWnd
ofn.hInstance = App.hInstance
ofn.lpstrFilter = "Text Files (*.txt)" + Chr$(0) + "*.txt" + Chr$(0) + "Rich Text Files (*.rtf)" + Chr$(0) + "*.rtf" + Chr$(0)
ofn.lpstrFile = Space$(254)
ofn.nMaxFile = 255
ofn.lpstrFileTitle = Space$(254)
ofn.nMaxFileTitle = 255
ofn.lpstrInitialDir = curdir
ofn.lpstrTitle = "Our File Open Title"
ofn.flags = 0
Dim a
a = GetOpenFileName(ofn)
If (a) Then
MsgBox "File to Open: " + Trim$(ofn.lpstrFile)
Else
MsgBox "Cancel was pressed"
End If
4.调用"打印"对话框
Private Type PrintDlg
lStructSize As Long
hwndOwner As Long
hDevMode As Long
hDevNames As Long
hdc As Long
flags As Long
nFromPage As Integer
nToPage As Integer
nMinPage As Integer
nMaxPage As Integer
nCopies As Integer
hInstance As Long
lCustData As Long
lpfnPrintHook As Long
lpfnSetupHook As Long
lpPrintTemplateName As String
lpSetupTemplateName As String
hPrintTemplate As Long
hSetupTemplate As Long
End Type
Private Declare Function PrintDlg Lib "comdlg32.dll" Alias "PrintDlgA" (pPrintdlg As PrintDlg) As Long
'将以下代码置于某一事件中
Dim tPrintDlg As PrintDlg
tPrintDlg.lStructSize = Len(tPrintDlg)
tPrintDlg.hwndOwner = Me.hwnd
tPrintDlg.hdc = hdc
tPrintDlg.flags = 0
tPrintDlg.nFromPage = 0
tPrintDlg.nToPage = 0
tPrintDlg.nMinPage = 0
tPrintDlg.nMaxPage = 0
tPrintDlg.nCopies = 1
tPrintDlg.hInstance = App.hInstance
lpPrintTemplateName = "Print Page"
Dim a
a = PrintDlg(tPrintDlg)
If a Then
lFromPage = tPrintDlg.nFromPage
lToPage = tPrintDlg.nToPage
lMin = tPrintDlg.nMinPage
lMax = tPrintDlg.nMaxPage
lCopies = tPrintDlg.nCopies
PrintMyPage 'Custom printing Subroutine
End If
中国电信携手电商打造跨界O2O联盟 【MDCC 2014】移动开发技术与平台峰会(下):系统演进、应用数据泄露风险 惊喜太多 IntelliJ IDEA 14正式发布 欧派、南航、招行、哈根达斯等加盟 深圳微信大会第二批讲师议题公布 【MDCC】用友高级副总裁谢志华:企业移动化的变革与挑战 HTML5定稿了,为什么原生App世界将被颠覆 走苹果的路子!Jawbone推低端健身追踪设备 专访POWER 8编程挑战赛选手吴亮:集众家之长, 激发算法性能极限 微信沟通接口上线,开启移动应用与公众号的连接 【特惠最后1天】参加深圳微信开发者大会赠书及全套讲师讲义(附大会最新日程) 编码运行两不误!KZPlayground,Objective-C中的Playgrounds 专访PopCap:AR是数字与物质世界的调和剂 【多图】Github编程语言分布统计:JavaScript称霸 【最具价值CTO评选秀】途家美女CTO杨孟彤:不创业会后悔 2014腾讯WE大会:开启未来的五大科技发展趋势 TIOBE 2014年11月编程语言排行榜:R受大数据影响跃至12位 深圳微信开发者大会全部议程出炉 最后仅剩30个参会名额 智能硬件:一半海水,一半火焰 聚焦SDN、NFV、云安全基础架构等技术热点 2014云安全联盟高峰论坛即将召开 富Web应用开发的七大原则 应用原型设计毫无压力!开源Sketch插件管理器Sketch Toolbox 【MDCC专访】友盟副总裁焦岳:从36万款App,看今年的热门领域 一切只为经典 微信开发者大会前瞻(附议程) 从手势识别到增强现实,开发实感应用该了解的技术细节 福利来了,爱拍原创免费为iOS版手游制作宣传视频 【工具推荐】Zrender——轻量级Canvas类库,让绘图大不同! 基于Docker和CoreOS的开源PaaS平台——Deis v1.0正式发布! 微软宣布.NET开发环境开源 支持三大操作系统 爆发吧,诺基亚!前员工开发物联网新设备 详解Visual Studio Emulator for Android,微软的Mobile First! HPC China 2014完美落幕,AMD Firepro荣获好评! 为什么98下可以到2000下不行了.关于openfilename???????????????????????????? (困惑请教 )关于内存释放的一些问题! 数据库操作出错该如何避免???? 我是第一次来到CSDN,大家多关照! YYSUN关于大富翁论坛的解释(从水母看到的) vb 访问SYBASE的问题 支持北京伸奥的朋友,进来签个名吧! 怎样截获一个应用程序的消息? 数据结构得答案 大连的软件人员工作环境怎么样? 不好意思,小弟又来麻烦大家了! 上次的文章到那儿去了? enmity,进来,我给你结帐 enmity,进来,我给你结帐!! 各位侠客帮忙啊,重新装系统出了问题! 将10进制转换成16进制的函数是什么啊? VC高手,怎样以编程的方法实现磁带机的Backup 和 Restore. enmity,进来,我给你结帐.共200分 支援白菜300分,支持白菜个人网站建设:))) CMM 的缩写是什么? 想和大家讨论一下怎样系统的编制软件 如何实现和Word、CorelDRAW同样效果缩放位图 请问各位大哥大爷大妈大。。。。。。。。。。。。。哪里有支持 ASP 的服务器软件下载 我该如何控制IP地址??高手请进。。。 弱弱地问:关于SQL server中的中括号。 各位侠客帮忙啊,重新装系统出了问题!! 一点点小问题????? 请问在 WINDOWS98 下面,除了IIS,还有没有支持 PHP 的服务器软件呢? 在ADO中如何获取表名 关于ASN树的问题(snmp中的MIB的拓扑树) 你是高手你进来!!!!! 各位的顶级域名都在哪申请?价格/速度如何?大家都来说说! DirectX8的MultiFileReader过滤器怎么找不到? 关于用VB显示ado数据库中的图像字段问题 大家来谈谈Msdn如何有效利用 请各位帮忙查看我这段程序错在哪里 , 我是照书上做的 , 可就是无法保存. SQL plus 为何无法登录?? 谁要下载msdn? 紧急求救!寻找工作! 最新新消息~~~~~~~台灣地區中午地震最大震度花蓮市5級 有没有大连的公司要俺? 请教大家!!!java如何实现多重继承?接口该如何使用?份数可以再加,只要我明白了 怎样以编程的方法实现磁带机的Backup. 愿者请进,请各位留下自己的QQ或E-mail,以后大家可以多多交流!!! solaris unix8 的一个问题 asp是用什么软件的阿?我用了interdev,可是开始新建项目时就不行,叫你输入serve时,总是不对?应该输什么啊? 关于字符集 哪里有好的LAN管理软件??? 一个去美国的机会,保签(替朋友贴的,信誉没问题) 打印没有输出? 动态分配内存 用阴影在图中表示出5分之2公顷 有2公顷5个格子,怎么画? 1,1,2,3,5,8,13,21,31,55.第12个是?前一百个数中【含100个】偶数的个数有多少个、? 负三分之一加四分之一减六分之五加七分之三 怎么算 用初一的方法 图中的长方形面积表示2公顷,请用阴影部分表示出三分之二公顷 1.1+2.2+3.3+4.4+5.5+6.6分之11+22+33+44+55+66谢谢各位大哥大姐了! 六分之五减四分之一加三分之一怎么算 在图中用阴影表示出5分之2公顷 15°15′15″+55°14′35″-32°28′19″=? 7又六分之五加负五又三分之一加2又四分之一加负四又四分之三 在图中用阴影表示出7/12公顷.急 77度45分+34度45分=___度____分 求(1+1/2+1/2+1/4+1/5)*1-(1+1/2+1/3+1/4)的计算过程. 有一块3公顷的地,把它分成7份,用阴影表示出7分之9公顷,该画多少份, 34度42分=多少度 3/5-(1/2-1/4)计算, 七分之三表示吧【 】平均分成【 】份,取这样的【 】份,它的分数单位是【 】,再加上【 】个这样的分数单位就是3. 45*46等于多少? 2又4/5*[1/(3又1/3-2.4)] 计算 7分之4乘3表示什么?,还可以表示为什么? 45*2等于多少 计算:(1)3.5÷(-2分之7)×/-2分之1/ 3×7分之3表示(),3÷7分之3表示( ) 2+45等于几 (2.5+3/4)÷1/8列式计算, 7.5+4分之3= 2.45约等于几一直约下去,得几? 列式计算 9/10÷[1/2×(6/5-3/10)] 谷歌地球飞行模拟器出错每次一打开飞行模拟器,就出现这样的对话框,仔细看一下文件路径(划红线的部分)文件夹下边的子文件夹用“/”分隔,划红线的路径为什么用“\”分隔?谷歌地球抽 a分之4+a分之5=7分之3,那么a是( ). 5分之2*45等于多少 谷歌地球飞行模拟器怎么用操纵杆我的上面没办法打勾,怎么补救 七分之三可以表示,还可以表示什么 45-多少+13等于28 35*(3/35-2/53)*53简便计算过程 x+7分之6=2+14分之1怎么解? 180°-23°13′6〃*4等于几 将0.75,0.25,0.125,0.375,0.625,0.875化成最简分数 5分之7-X=14分之3 角1是36度,求角2 1+2+3+4.+99等于多少 x+7分之8=x-2分之2怎么解 计算3分之一加四分之一时 3分支4-(-7分之8)-2-(+3分支1)-7分支1 x:5分之7=8分之7解比例要求全过程. -3又3分之1-2又四分之一-(-2又三分之一)+(-4又四分之一) 怎么算 2002/1×3+2002/3×5+2002/5×7+2002/7×9+2002/9×11 简便计算 3.5:7分之8=x:5分之2(解比例只要答案) 计算:(-四分之一)^5*(四分之一)^3*(-四分之一)^2(a^2)^3*a*(a^4)^2 3(a^3)^4+a^9*a^3-2(a^2)^6 (-2a^2)^3-(-3a^3)^2 10^m-1*10^n-1*10^3 (x^2y^3)^3+(-2x^3y^2)^2*y^5 (四分之一)^2006*2^4010 (-3a)^3-(-a)*(-3a)^2 1—2—3+4+5—6—7+8+9—10—11…+2001—2002—2003 求简便运算过程1—2—3+4+5—6—7+8+9—10—11…+2001—2002—2003 求简便运算过程 求快速. 急!0.75-2又4分之3-0.125+12又7分之5-48分之1+|6又7分之5-10|要过程~~~~ 修一条路,前3天修了这条路的四分之一,平均每天修了这条路的几分之几?照这样计算,修往这条路,需要几天. 2002/1×3+2002/3×5+2002/5×7+2002/7×9+2002/9×11简便计算 下面的分数请化成最简分数;75分之12、65分之15、130分之80、30分之25、55分之33、48分之32、75分之125还有63分之117 (-3又四分之一)+(-1又十二分之一) 7分之四乘3分之2加7分之4 [2-(5.55×1又3分之1-2又10分之7)]÷0.9 负三又四分之一加负一又十二分之一= 负三又四分之一加负一又十二分之一=几 4分之3乘( )=( )乘8分之7=( )+7分之4=( )-2分之1=1 观察:1+2+3+4+5+6+7+8+9+10=(1+10)*(10÷2 )=11*5=55计算:1992/1993+1991/1993+1990/1993+...+3/1993+2/1993+1/1993=?/:分数线 分子/分母 四分之一里有几个十二分之一?一又四分之一里有几个二十四分之一?
备案号:鲁ICP备13029499号-2 说三道四 www.s3d4.cn