nbsp; 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 = "*.*|*.*" &n 上一页 [1] [2] [3] [4] 下一页 没有相关教程
|