精华内容
下载资源
问答
  • VB6.0 多种使用通用对话框的方法演示含源代码,为对话框增加常见的“打开”、“另存为”、“字体”、“打颖、“帮助”。演示了当“颜色”、“字体”等对话框按钮被按下时,程序如何执行,将TextBox的字体属性根据...
  • 3.在VB中可以建立 菜单和 菜单...为了把通用对话框控件加到工具箱中应在工程菜单中选择部件命令弹出部件对话框在部件对话框的控件选项卡中选择 2.建立打开文件保存文件颜色字体和打印对话框所使用的方法分别为 Showopen
  • VB.Net - 对话框

    2018-03-01 09:53:52
    VB.Net - 对话框有许多内置的对话框,用于Windows窗体中的各种任务,例如打开和保存文件,打印页面,向应用程序的用户提供颜色,字体,页面设置等选择。 这些内置的对话框减少了开发人员的时间和工作量。所有这些...

    VB.Net - 对话框


    有许多内置的对话框,用于Windows窗体中的各种任务,例如打开和保存文件,打印页面,向应用程序的用户提供颜色,字体,页面设置等选择。 这些内置的对话框减少了开发人员的时间和工作量。

    所有这些对话框控件类继承自CommonDialog类,并覆盖基类的RunDialog()函数以创建特定对话框。

    当对话框的用户调用其ShowDialog()函数时,将自动调用RunDialog()函数。

    ShowDialog方法用于在运行时显示所有对话框控件。 它返回一个DialogResult枚举类型的值。 DialogResult枚举的值为:

    • Abort 中止 - returns DialogResult.Abort value, when user clicks an Abort button.  当用户单击“中止”按钮时,返回DialogResult.Abort值。

    • Cancel 取消 -returns DialogResult.Cancel, when user clicks a Cancel button.  当用户单击Ignore按钮时,返回DialogResult.Ignore。

    • Ignore 忽略 -returns DialogResult.Ignore, when user clicks an Ignore button.  返回DialogResult.No,当用户单击否按钮。

    • No  -returns DialogResult.No, when user clicks a No button.  不返回任何内容,对话框继续运行。

    • None  -returns nothing and the dialog box continues running.  返回DialogResult.OK,当用户单击确定按钮

    • OK -returns DialogResult.OK, when user clicks an OK button.  返回DialogResult.  OK,当用户点击OK键

    • Retry 重试 -returns DialogResult.Retry , when user clicks an Retry button.  当用户单击重试按钮时,返回DialogResult.Retry

    • Yes  -returns DialogResult.Yes, when user clicks an Yes button.  返回DialogResult.Yes,当用户单击是按钮


    下图显示了通用对话框类继承:


    VB.Net对话框

    上述 所有 相应 控件,可以在设计期间从工具箱中添加。 您可以通过以编程方式实例化类或通过使用相关控件,将这些类的相关功能包括到应用程序中。

    当双击工具箱中的任何对话框控件或将控件拖动到窗体上时,它将显示在Windows窗体设计器底部的组件托盘中,但不会直接显示在窗体上。

    下表列出了常用的对话框控件。 点击以下链接查看其详细信息:

     
    S.N.控制& 说明
    1

    ColorDialog

    It represents a common dialog box that displays available colors along with controls that enable the user to define custom colors.

    它表示一个公共对话框,显示可用颜色以及允许用户定义自定义颜色的控件。

    2

    FontDialog

    It prompts the user to choose a font from among those installed on the local computer and lets the user select the font, font size, and color.

    它提示用户从安装在本地计算机上的字体中选择字体,并让用户选择字体,字体大小和颜色。

    3

    OpenFileDialog

    It prompts the user to open a file and allows the user to select a file to open.

    它提示用户打开文件,并允许用户选择要打开的文件。

    4

    SaveFileDialog

    It prompts the user to select a location for saving a file and allows the user to specify the name of the file to save data.

    它提示用户选择保存文件的位置,并允许用户指定保存数据的文件的名称。

    5

    PrintDialog

    It lets the user to print documents by selecting a printer and choosing which sections of the document to print from a Windows Forms application.

    它允许用户通过选择打印机并从Windows窗体应用程序中选择要打印的文档的哪些部分来打印文档。

    展开全文
  • 二级VB培训笔记07:通用对话框 通用对话框(CommonDialog)控件提供了一组标准对话框界面,包括打开文件、保存文件、选择颜色、选择字体、设置打印机和帮助等六个对话框。这些对话框只能返回用户输入、选择或确认的...

    二级VB培训笔记07:通用对话框

    通用对话框(CommonDialog)控件提供了一组标准对话框界面,包括打开文件、保存文件、选择颜色、选择字体、设置打印机和帮助等六个对话框。这些对话框只能返回用户输入、选择或确认的信息,要实现诸如文件打开、保存文件、设置颜色等操作,还必须编写相应的代码才能实现。

    在设计状态下,通用对话框控件显示为一个在运行时不可见的图标。在程序运行状态下,可以通过设置其Action属性或使用其Show方法来打开需要的某种对话框。通用对话框控件的Action属性值及相应的Show方法如下表所示。

    1、演示添加通用对话框,利用Action属性的设置来显示打开对话框

    展开全文
  • VB中关于CommonDialog通用对话框的使用

    千次阅读 2019-02-25 16:10:22
    3.initDir:表示指定通用对话框的初始目录 4.FileName:表示文件对话框默认的保存文件名 5.ShowSave:表示表示打开另存为对话框,执行保存文件的操作。 注意:CD1.showopen的程序位置很重要,如果放在程序开头,...

    Private Sub Command1_Click()
      CD1.Filter="All File| * . * |Text File| * .txt|PPT| * .ppt"
      CD1.FilterIndex=2
      CD1.InitDir="C:"
      CD1.FileName="default"
      CD1.ShowSave
    End Sub

    1.Filter:为文件过滤器,列举出需要打开的文件类型,此程序包含的类型有TXT和ppt两种
    2.Filterindex=1,表示另存为的类型为All File ,若
    Filterindex=2,表示另存为的类型为txt,若
    Filterindex=3,表示另存为的类型为PPt
    3.initDir:表示指定通用对话框的初始目录
    4.FileName:表示文件对话框默认的保存文件名
    5.ShowSave:表示表示打开另存为对话框,执行保存文件的操作。
    注意:CD1.showopen的程序位置很重要,如果放在程序开头,程序首先执行打开文件操作,而后面的程序则未执行到,需要第二次打开才执行后面的程序。

    展开全文
  • VB中“打开对话框同时选择多个文件,各位经常用到的
  • VB用API实现各种对话框(总结)   各种对话框(总结)标准对话框(SmDialog) Option Explicit''定义一个全局变量,用于保存字体的各种属性Public Type SmFontAttrFontName As String '字体名FontSize ...

    VB用API实现各种对话框(总结)


     
     

    各种对话框(总结)
    标准对话框(SmDialog)


    Option Explicit
    ''定义一个全局变量,用于保存字体的各种属性
    Public Type SmFontAttr
    FontName As String '字体名
    FontSize As Integer '字体大小
    FontBod As Boolean '是否黑体
    FontItalic As Boolean '是否斜体
    FontUnderLine As Boolean '是否下划线
    FontStrikeou As Boolean
    FontColor As Long
    WinHwnd As Long
    End Type
    Dim M_GetFont As SmFontAttr
    ''**系统常量------------------------------------------
    Private Const SWP_NOOWNERZORDER = &H200
    Private Const SWP_HIDEWINDOW = &H80
    Private Const SWP_NOACTIVATE = &H10
    Private Const SWP_NOMOVE = &H2
    Private Const SWP_NOREDRAW = &H8
    Private Const SWP_NOREPOSITION = SWP_NOOWNERZORDER
    Private Const SWP_NOSIZE = &H1
    Private Const SWP_NOZORDER = &H4
    Private Const SWP_SHOWWINDOW = &H40
    Private Const RESOURCETYPE_DISK = &H1 '网络驱动器
    Private Const RESOURCETYPE_PRINT = &H2 '网络打印机
    '/------------------------------------------------------------
    Private Const NoError = 0
    Private Const CSIDL_DESKTOP = &H0
    Private Const CSIDL_PROGRAMS = &H2
    Private Const CSIDL_CONTROLS = &H3
    Private Const CSIDL_PRINTERS = &H4
    Private Const CSIDL_PERSONAL = &H5
    Private Const CSIDL_FAVORITES = &H6
    Private Const CSIDL_STARTUP = &H7
    Private Const CSIDL_RECENT = &H8
    Private Const CSIDL_SENDTO = &H9
    Private Const CSIDL_BITBUCKET = &HA
    Private Const CSIDL_STARTMENU = &HB
    Private Const CSIDL_DESKTOPDIRECTORY = &H10
    Private Const CSIDL_DRIVES = &H11
    Private Const CSIDL_NETWORK = &H12
    Private Const CSIDL_NETHOOD = &H13
    Private Const CSIDL_FONTS = &H14
    Private Const CSIDL_TEMPLATES = &H15
    Private Const LF_FACESIZE = 32
    Private Const MAX_PATH = 260
    Private Const CF_INITTOLOGFONTSTRUCT = &H40&
    Private Const CF_FIXEDPITCHONLY = &H4000&
    Private Const CF_EFFECTS = &H100&
    Private Const ITALIC_FONTTYPE = &H200
    Private Const BOLD_FONTTYPE = &H100
    Private Const CF_NOFACESEL = &H80000
    Private Const CF_NOSCRIPTSEL = &H800000
    Private Const CF_PRINTERFONTS = &H2
    Private Const CF_SCALABLEONLY = &H20000
    Private Const CF_SCREENFONTS = &H1
    Private Const CF_SHOWHELP = &H4&
    Private Const CF_BOTH = (CF_SCREENFONTS Or CF_PRINTERFONTS)
    '/------------------------------------------
    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 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 Type LOGFONT
    lfHeight As Long
    lfWidth As Long
    lfEscapement As Long
    lfOrientation As Long
    lfWeight As Long
    lfItalic As Byte
    lfUnderline As Byte
    lfStrikeOut As Byte
    lfCharSet As Byte
    lfOutPrecision As Byte
    lfClipPrecision As Byte
    lfQuality As Byte
    lfPitchAndFamily As Byte
    lfFaceName As String * LF_FACESIZE
    End Type
    Private Type CHOOSEFONT
    lStructSize As Long
    hwndOwner As Long
    hdc As Long
    lpLogFont As Long
    iPointSize As Long
    flags As Long
    rgbColors As Long
    lCustData As Long
    lpfnHook As Long
    lpTemplateName As String
    hInstance As Long
    lpszStyle As String
    nFontType As Integer
    MISSING_ALIGNMENT As Integer
    nSizeMin As Long
    nSizeMax As Long
    End Type
    '/--------------
    Private Type SHITEMID
    cb As Long
    abID() As Byte
    End Type
    Private Type ITEMIDLIST
    mkid As SHITEMID
    End Type
    '/------------------------------------------
    Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias

    "SHGetPathFromIDListA" _
    (ByVal Pidl As Long, ByVal pszPath As String) As Long
    Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" _
    (ByVal hwndOwner As Long, ByVal nFolder As Long, _
    Pidl As ITEMIDLIST) As Long
    '/------------------------------------------
    Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA"

    (pOpenfilename As OPENFILENAME) As Long
    Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA"

    (pOpenfilename As OPENFILENAME) As Long
    Private Declare Function CHOOSECOLOR Lib "comdlg32.dll" Alias "ChooseColorA"

    (pChoosecolor As CHOOSECOLOR) As Long
    Private Declare Function WNetConnectionDialog Lib "mpr.dll" (ByVal hWnd As Long,

    ByVal dwType As Long) As Long
    Private Declare Function CHOOSEFONT Lib "comdlg32.dll" Alias "ChooseFontA"

    (pChooseFont As CHOOSEFONT) As Long
    '/=======显示断开网络资源对话框============
    Private Declare Function WNetDisconnectDialog Lib "mpr.dll" _
    (ByVal hWnd As Long, ByVal dwType As Long) As Long
    '/================================================================================
    Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal pv As Long)
    Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias

    "SHBrowseForFolderA" _
    (lpBrowseInfo As BROWSEINFO) As Long
    Private Type BROWSEINFO
    hOwner As Long
    pidlRoot As Long
    pszDisplayName As String
    lpszTitle As String
    ulFlags As Long
    lpfn As Long
    lParam As Long
    iImage As Long
    End Type
    '/结构说明: _
    hOwner 调用这个对话框的窗口的句柄 _
    pidlRoot 指向你希望浏览的最上面的文件夹的符列表 _
    pszDisplayName 用于保存用户所选择的文件夹的显示名的缓冲区 _
    lpszTitle 浏览对话框的标题 _
    ulFlags 决定浏览什么的标志(见下) _
    lpfn 当事件发生时对话框调用的回调函数的地址.可将它设定为NULL _
    lparam 若定义了回调函数,则为传递给回调函数的值 _
    iImage As Long 保存所选文件夹映像索引的缓冲区 _
    ulFlags参数(见下:)
    Private Const BIF_RETURNONLYFSDIRS = &H1 '仅允许浏览文件系统文件夹
    Private Const BIF_DONTGOBELOWDOMAIN = &H2 '利用这个值强制用户仪在网上邻居的域级别


    Private Const BIF_STATUSTEXT = &H4 '在选择对话中显示状态栏
    Private Const BIF_RETURNFSANCESTORS = &H8 '返回文件系统祖先
    Private Const BIF_BROWSEFORCOMPUTER = &H1000 '允许浏览计算机
    Private Const BIF_BROWSEFORPRINTER = &H2000 '允许游览打印机文件夹
    '/--------------------------------------------------------------------------------
    Dim FontInfo As SmFontAttr '字体
    '/--------------------------------------------------------------------------------

    Private Function GetFolderValue(wIdx As Integer) As Long
    If wIdx < 2 Then
    GetFolderValue = 0
    ElseIf wIdx < 12 Then
    GetFolderValue = wIdx
    Else
    GetFolderValue = wIdx + 4
    End If
    End Function
    '
    Private Function GetReturnType() As Long
    Dim dwRtn As Long
    dwRtn = dwRtn Or BIF_RETURNONLYFSDIRS
    GetReturnType = dwRtn
    End Function
    '
    '文件夹选择对话框
    '函数:SaveFile
    '参数:Title 设置对话框的标签.
    ' hWnd 调用此函数的HWND
    ' FolderID SmBrowFolder枚举(默认:我的电脑).
    '返回值:String 文件夹路径.
    '例子:
    Public Function GetFolder(Optional Title As String, _
    Optional hWnd As Long, _
    Optional FolderID As SmBrowFolder = MyComputer) As String
    Dim Bi As BROWSEINFO
    Dim Pidl As Long
    Dim Folder As String
    Dim IDL As ITEMIDLIST
    Dim nFolder As Long
    Dim ReturnFol As String
    Dim Fid As Integer

    Fid = FolderID
    Folder = String$(255, Chr$(0))
    With Bi
    .hOwner = hWnd
    nFolder = GetFolderValue(Fid)
    If SHGetSpecialFolderLocation(ByVal hWnd, ByVal nFolder, IDL) = NoError Then
    .pidlRoot = IDL.mkid.cb
    End If
    .pszDisplayName = String$(MAX_PATH, Fid)

    If Len(Title) > 0 Then
    .lpszTitle = Title & Chr$(0)
    Else
    .lpszTitle = "请选择文件夹:" & Chr$(0)
    End If

    .ulFlags = GetReturnType()
    End With

    Pidl = SHBrowseForFolder(Bi)
    '/返回所选的文件夹路径
    If SHGetPathFromIDList(ByVal Pidl, ByVal Folder) Then
    ReturnFol = Left$(Folder, InStr(Folder, Chr$(0)) - 1)
    If Right$(Trim$(ReturnFol), 1) <> "" Then ReturnFol = ReturnFol & ""
    GetFolder = ReturnFol
    Else
    GetFolder = ""
    End If
    End Function
    '
    '文件保存对话框
    '函数:SaveFile
    '参数:WinHwnd 调用此函数的HWND
    ' BoxLabel 设置对话框的标签.
    ' StartPath 设置初始化路径.
    ' FilterStr 文件过滤.
    ' Flag 标志.(参考MSDN)
    '返回值:String 文件名.
    '例子:
    Public Function SaveFile(WinHwnd As Long, _
    Optional BoxLabel As String = "", _
    Optional StartPath As String = "", _
    Optional FilterStr = "*.*|*.*", _
    Optional Flag As Variant = &H4 Or &H200000) As String
    Dim Rc As Long
    Dim pOpenfilename As OPENFILENAME
    Dim Fstr1() As String
    Dim Fstr As String
    Dim I As Long
    Const MAX_Buffer_LENGTH = 256

    On Error Resume Next

    If Len(Trim$(StartPath)) > 0 Then
    If Right$(StartPath, 1) <> "" Then StartPath = StartPath & ""
    If Dir$(StartPath, vbDirectory + vbHidden) = "" Then
    StartPath = App.Path
    End If
    Else
    StartPath = App.Path
    End If
    If Len(Trim$(FilterStr)) = 0 Then
    Fstr = "*.*|*.*"
    End If
    Fstr1 = Split(FilterStr, "|")
    For I = 0 To UBound(Fstr1)
    Fstr = Fstr & Fstr1(I) & vbNullChar
    Next
    '/--------------------------------------------------
    With pOpenfilename
    .hwndOwner = WinHwnd
    .hInstance = App.hInstance
    .lpstrTitle = BoxLabel
    .lpstrInitialDir = StartPath
    .lpstrFilter = Fstr
    .nFilterIndex = 1
    .lpstrDefExt = vbNullChar & vbNullChar
    .lpstrFile = String(MAX_Buffer_LENGTH, 0)
    .nMaxFile = MAX_Buffer_LENGTH - 1
    .lpstrFileTitle = .lpstrFile
    .nMaxFileTitle = MAX_Buffer_LENGTH
    .lStructSize = Len(pOpenfilename)
    .flags = Flag
    End With
    Rc = GetSaveFileName(pOpenfilename)
    If Rc Then
    SaveFile = Left$(pOpenfilename.lpstrFile, pOpenfilename.nMaxFile)
    Else
    SaveFile = ""
    End If
    End Function

    '
    '文件打开对话框
    '函数:OpenFile
    '参数:WinHwnd 调用此函数的HWND
    ' BoxLabel 设置对话框的标签.
    ' StartPath 设置初始化路径.
    ' FilterStr 文件过滤.
    ' Flag 标志.(参考MSDN)
    '返回值:String 文件名.
    '例子:
    Public Function OpenFile(WinHwnd As Long, _
    Optional BoxLabel As String = "", _
    Optional StartPath As String = "", _
    Optional FilterStr = "*.*|*.*", _
    Optional Flag As Variant = &H8 Or &H200000) As String
    Dim Rc As Long
    Dim pOpenfilename As OPENFILENAME
    Dim Fstr1() As String
    Dim Fstr As String
    Dim I As Long
    Const MAX_Buffer_LENGTH = 256

    On Error Resume Next

    If Len(Trim$(StartPath)) > 0 Then
    If Right$(StartPath, 1) <> "" Then StartPath = StartPath & ""
    If Dir$(StartPath, vbDirectory + vbHidden) = "" Then
    StartPath = App.Path
    End If
    Else
    StartPath = App.Path
    End If
    If Len(Trim$(FilterStr)) = 0 Then
    Fstr = "*.*|*.*"
    End If
    Fstr = ""
    Fstr1 = Split(FilterStr, "|")
    For I = 0 To UBound(Fstr1)
    Fstr = Fstr & Fstr1(I) & vbNullChar
    Next
    With pOpenfilename
    .hwndOwner = WinHwnd
    .hInstance = App.hInstance
    .lpstrTitle = BoxLabel
    .lpstrInitialDir = StartPath
    .lpstrFilter = Fstr
    .nFilterIndex = 1
    .lpstrDefExt = vbNullChar & vbNullChar
    .lpstrFile = String(MAX_Buffer_LENGTH, 0)
    .nMaxFile = MAX_Buffer_LENGTH - 1
    .lpstrFileTitle = .lpstrFile
    .nMaxFileTitle = MAX_Buffer_LENGTH
    .lStructSize = Len(pOpenfilename)
    .flags = Flag
    End With
    Rc = GetOpenFileName(pOpenfilename)
    If Rc Then
    OpenFile = Left$(pOpenfilename.lpstrFile, pOpenfilename.nMaxFile)
    Else
    OpenFile = ""
    End If
    End Function
    '
    '颜色对话框
    '函数:GetColor
    '参数:
    '返回值:Long,用户所选择的颜色.
    '例子:
    Public Function GetColor() As Long
    Dim Rc As Long
    Dim pChoosecolor As CHOOSECOLOR
    Dim CustomColor() As Byte
    With pChoosecolor
    .hwndOwner = 0
    .hInstance = App.hInstance
    .lpCustColors = StrConv(CustomColor, vbUnicode)
    .flags = 0
    .lStructSize = Len(pChoosecolor)
    End With
    Rc = CHOOSECOLOR(pChoosecolor)
    If Rc Then
    GetColor = pChoosecolor.rgbResult
    Else
    GetColor = -1
    End If
    End Function
    '
    '显示映射网络驱动器对话框
    '函数:ConnectDisk
    '参数:hWnd 调用此函数的窗口HWND.(ME.HWN)
    '返回值:=0,成功,<>0,失败.
    '例子:
    Public Function ConnectDisk(Optional hWnd As Long) As Long
    Dim Rc As Long
    If IsNumeric(hWnd) Then
    Rc = WNetConnectionDialog(hWnd, RESOURCETYPE_DISK)
    Else
    Rc = WNetConnectionDialog(0, RESOURCETYPE_DISK)
    End If
    ConnectDisk = Rc
    End Function
    '
    '显示映射网络打印机对话框
    '函数:ConnectPrint
    '参数:hWnd 调用此函数的窗口HWND.(ME.HWN)
    '返回值:=0,成功,<>0,失败.
    '例子:
    Public Function ConnectPrint(Optional hWnd As Long) As Long
    Dim Rc As Long
    If IsNumeric(hWnd) Then
    Rc = WNetConnectionDialog(hWnd, RESOURCETYPE_PRINT)
    Else
    Rc = WNetConnectionDialog(0, RESOURCETYPE_PRINT)
    End If
    End Function
    '
    '断开映射网络驱动器对话框
    '函数:DisconnectDisk
    '参数:hWnd 调用此函数的窗口HWND.(ME.HWN)
    '返回值:=0,成功,<>0,失败.
    '例子:
    Public Function DisconnectDisk(Optional hWnd As Long) As Long
    Dim Rc As Long
    If IsNumeric(hWnd) Then
    Rc = WNetDisconnectDialog(hWnd, RESOURCETYPE_DISK)
    Else
    Rc = WNetDisconnectDialog(0, RESOURCETYPE_DISK)
    End If
    End Function
    '
    '断开映射网络打印机关话框
    '函数:DisconnectPrint
    '参数:hWnd 调用此函数的窗口HWND.(ME.HWN)
    '返回值:=0,成功,<>0,失败.
    '例子:
    Public Function DisconnectPrint(Optional hWnd As Long) As Long
    Dim Rc As Long
    If IsNumeric(hWnd) Then
    Rc = WNetDisconnectDialog(hWnd, RESOURCETYPE_PRINT)
    Else
    Rc = WNetDisconnectDialog(0, RESOURCETYPE_PRINT)
    End If
    End Function
    '
    '字体选择对话框
    '函数:GetFont
    '参数:WinHwnd 调用此函数的窗口HWND.(ME.HWN)
    '返回值:SmFontAttr 结构变量.
    '例子:
    ' Dim mDialog As New SmDialog
    ' Dim mFontInfo As SmFontAttr
    ' mFontInfo = mDialog.GetFont(Me.hWnd)
    ' Set mDialog = Nothing
    Public Function GetFont(WinHwnd As Long) As SmFontAttr
    Dim Rc As Long
    Dim pChooseFont As CHOOSEFONT
    Dim pLogFont As LOGFONT

    With pLogFont
    .lfFaceName = StrConv(FontInfo.FontName, vbFromUnicode)
    .lfItalic = FontInfo.FontItalic
    .lfUnderline = FontInfo.FontUnderLine
    .lfStrikeOut = FontInfo.FontStrikeou
    End With
    With pChooseFont
    .hInstance = App.hInstance
    If IsNumeric(WinHwnd) Then .hwndOwner = WinHwnd
    .flags = CF_BOTH + CF_INITTOLOGFONTSTRUCT + CF_EFFECTS + CF_NOSCRIPTSEL
    If IsNumeric(FontInfo.FontSize) Then .iPointSize = FontInfo.FontSize *

    10
    If FontInfo.FontBod Then .nFontType = .nFontType + BOLD_FONTTYPE
    If IsNumeric(FontInfo.FontColor) Then .rgbColors = FontInfo.FontColor
    .lStructSize = Len(pChooseFont)
    .lpLogFont = VarPtr(pLogFont)
    End With
    Rc = CHOOSEFONT(pChooseFont)
    If Rc Then
    FontInfo.FontName = StrConv(pLogFont.lfFaceName, vbUnicode)
    FontInfo.FontName = Left$(FontInfo.FontName, InStr(FontInfo.FontName,

    vbNullChar) - 1)
    With pChooseFont
    FontInfo.FontSize = .iPointSize / 10 '返回字体大


    FontInfo.FontBod = (.nFontType And BOLD_FONTTYPE) '返回是/否黑


    FontInfo.FontItalic = (.nFontType And ITALIC_FONTTYPE) '是/否斜体
    FontInfo.FontUnderLine = (pLogFont.lfUnderline) '是/否下划线
    FontInfo.FontStrikeou = (pLogFont.lfStrikeOut)
    FontInfo.FontColor = .rgbColors
    End With
    End If
    GetFont = FontInfo
    End Function
    '
    '文件打开.(带预览文件功能)
    '函数:BrowFile
    '参数:Pattern 文件类型字符串,StarPath 开始路径,IsBrow 是否生成预览
    '返回值:[确定] 文件路径.[取消] 空字符串
    '例:Me.Caption =

    FileBrow.BrowFile("图片文件|*.JPG;*.GIF;*.BMP|媒体文件|*.DAT;*.MPG;*.SWF;*.MP3;*.MP2

    ")
    Public Function BrowFile(Optional Pattern As String = "*,*|*.*", _
    Optional StarPath As String = "C:", _
    Optional IsBrow As Boolean = True) As String

    On Error Resume Next

    If Len(Trim$(Pattern)) = 0 Then Pattern = "*.*|*.*"
    P_FilePart = Pattern
    P_StarPath = StarPath
    P_IsBrow = IsBrow
    FrmBrowFile.Show 1
    BrowFile = P_FullFileName
    End Function
    '
    '显示网上邻居
    '函数:ShowNetWork
    '参数:FrmCap 窗口标题,Labction 提示标签名.
    '返回值:[确定] 所选计算机名称.[取消] 空字符串.
    '例:
    Public Function ShowNetWork(Optional FrmCap As String = "网上邻居", _
    Optional Labction As String = "选择计算机名称.") As

    String
    ShowLan.Hide
    ShowLan.Caption = FrmCap
    ShowLan.LabNNCaption = Labction
    ShowLan.Show 1
    ShowNetWork = P_NetReturnVal
    End Function

    转载于:https://www.cnblogs.com/MMLoveMeMM/articles/3317212.html

    展开全文
  • filterindex是“打开”或“另存为”对话框(CommonDialog控件)中的一个缺省的过滤器,来打开或者保存文件的文件扩展名 要使用这个属性值,就必须先给filter属性赋值,比如 CommonDialog1.filter=“word文档|.doc|...
  • VB讲课笔记10:菜单与对话框

    千次阅读 2018-03-14 06:46:11
    VB讲课笔记10:菜单与对话框一、用户界面设计基础用户界面是应用程序最基本的组成部分,其内容包括界面基本元素的外观设计和实现相应功能的代码编制。 1、用户界面元素(User Interface Element) 窗体是用户界面...
  • VB中可以使用commondialog控件得到“打开”、“另存为”等标准对话框以及文件路径和文件名,在vfp中同样可以使用这个控件。该控件运行时不可见,是一个ActiveX控件。该控件常用的事件有showopen和showsave,其中show...
  • vb.net对话框用法

    2010-10-30 14:32:28
    vb.net对话框的使用方法:使用消息对话框按钮启动程序、启动帮助文件、对话框中设置图片等等。源码!
  • VB备忘录(12) 通用对话框

    千次阅读 2013-04-10 21:35:27
    对话框有: 1、inputbox 2、msgbox 3、通用通话框 通用通话框 部件:microsoft common dialog control 6.0 分为五种: 打开showopen 另存为 showsave 颜色 showcolor 字体 showfont 打印 ...
  • 通用对话框使用方法全解,“打开”对话框,“另存为”对话框,“字体”对话框,“打印”对话框, “帮助”对话框VB6.0源代码
  • 没有OCX的通用对话框 描述 大家好, 该程序的目的是使用Windows通用对话框控件而不使用COMDLG32.OCX文件。 即使文件不存在也可以使用 这仅适用于打开和保存功能。 但是您也可以附加它以获取颜色和其他对话框, 只...
  • '选择文件夹(http://blog.sina.com.cn/s/blog_55fc7c2f0101mb4t.html): Option Explicit 'http://www.mvps.org/access/api/api0002.htm 'Code courtesy of Terry Kreft Private Type BROWSEINFO hOw...
  • 通用打开文件对话框,可以多选文件。一个模块搞定!
  • 8.8通用对话框控件  Windows应用程序里的Open对话框,Save As对话框在各个应用程序里看起来都是一样的,通用对话框控件就可以提供这些对话框的标准功能。  1.Open对话框及Save As对话框  打开Open对话框...
  • VB 通用对话框 为什么需要 CancelError

    千次阅读 2014-12-17 20:48:30
     .Action = 1 '相当于 CommonDialog1.ShowOpen "打开文件"对话框  End With  songName = CommonDialog1.FileName errHandler:  If Err > 0 Then '选择了取消  songName = "" '好像这样:如果此前...
  • ' 功 能:不使用控件,对Windows通用对话框进行自定义,核心包括一个封装的类和两个模块。 [更新历史] ◆ Ver 1.0.2 开发时间:2008-09-24 09:27 ~ 2008-09-24 12:04 ' 1、修正了没有设置预览或程序标志图片框时,...
  • ' 功能: 浏览及选择文件夹通用对话框 ' 使用方法:(1)将mdlBrowseFolder.bas模块添加到当前工程中; ' (2)在当前工程中使用 ' dim strMyPath as String ' strMyPath=BrowseFolder("请选择目录") ' 代码段进行调用,...
  • VB API通用对话框类

    2009-02-26 20:36:34
    包括打开、保存、字体、颜色等的对话框的调用
  • VB: 用通用对话框同时选择多个文件

    千次阅读 2005-05-23 23:13:00
    --------------------------------------用通用对话框同时选择多个文件-------------------------------------- 洪恩在线 求知无限--------------------------------------------名称-------------作用-----------...
  • Java局域网通信——飞鸽传书源代码 28个目标文件 内容索引:JAVA源码,媒体网络,飞鸽传书 Java局域网通信——飞鸽传书源代码,大家都知道VB版、VC版还有Delphi版的飞鸽传书软件,但是Java版的确实不多,因此这个Java...
  • vb 实验8答案

    2012-05-25 10:57:27
    更好更正确,清华大学出版的vb那本书的答案
  • 使用API调用Winodws各种通用对话框(Common Diaglog)的方法(一)1.文件属性对话框Type SHELLEXECUTEINFOcbSize As LongfMask As Longhwnd As LonglpVerb As StringlpFile As StringlpParameters As ...
  • VBA中使用Win API打开文件对话框

    千次阅读 2007-07-03 11:04:00
    使用网上比较普遍的vb中使用WindowsAPI实现打开文件对话框代码,Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _ "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long Type OPENFILENAME ...
  • Web端打开文件选择和保存对话框

    万次阅读 2013-03-20 15:32:38
    文件的选择、保存对话框,使用Java 很容易达成。 如果想在Web端使用的话,可以用Applet 达成。 但如果想使用HTML, js 达成的话,也是可以的。不过 web程序对客户机的文件进行读写是不安全的。ActiveXObject是IE...
  • 支持C++、VB.NET和Razor等附加语言,为客户提供了解决方案视图和源控件差异共享。 打开你最近处理过的代码,或者通过新的启动窗口,比如克隆、打开或新建项目等最常用的流程之一开始。 按受欢迎程度排序...
  • 第五步:再接下来我们需要进入系统设置--通用---描述文件,找到刚才下载的企业级描述文件,相信这点不用小编多解释,当然我们需要点击进入进行信任才可以正常打开这个CC12应用图标,如下图所示。 修改iPhone运营商...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 3,784
精华内容 1,513
关键字:

vb打开通用对话框