﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Релиб / Программирование / Visual Basic  / Как создать нормальный ComDlg? / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>Релиб</description><link>http://www.relib.com/forums/</link><webMaster>robot@relib.com</webMaster><lastBuildDate>Sat, 10 Jan 2009 07:04:09 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Как создать нормальный ComDlg?</title><link>http://www.relib.com/forums/Topic486-1-1.aspx</link><description>Огромное спасибо за помощь!!!</description><pubDate>Fri, 09 Jun 2000 12:24:00 GMT</pubDate><dc:creator>member</dc:creator></item><item><title>RE: Как создать нормальный ComDlg?</title><link>http://www.relib.com/forums/Topic486-1-1.aspx</link><description>Пример:' Код модуль класса   CFileDialog*cls' Class       : CFileDialog' Description : Class for displaying the File Open/Save Common Dialog.' Source      : Total VB SourceBook 6Private 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 StringEnd TypePrivate Declare Function GetOpenFileName _  Lib "comdlg32.dll" _  Alias "GetOpenFileNameA" _  (pOpenfilename As OPENFILENAME) _  As LongPrivate Declare Function GetSaveFileName _  Lib "comdlg32.dll" _  Alias "GetSaveFileNameA" _  (pOpenfilename As OPENFILENAME) _  As LongPrivate m_strDefaultExt As StringPrivate m_strDialogTitle As StringPrivate m_strFileName As StringPrivate m_strFileTitle As StringPrivate m_strInitialDir As StringPrivate m_strFilter As StringPrivate m_intFilterIndex As IntegerPrivate m_eFlags As EnumFilFlagsPrivate m_intMaxFileSize As IntegerPrivate m_lnghWndParent As LongPrivate Const cintMaxFileLength As Integer = 260Public Enum EnumFilFlags  FleReadOnly = &amp;H1  FleOverWritePrompt = &amp;H2  FleHideReadOnly = &amp;H4  FleNoChangeDir = &amp;H8  FleShowHelp = &amp;H10  FleEnableHook = &amp;H20  FleEnableTemplate = &amp;H40  FleEnableTemplateHandle = &amp;H80  FleNoValidate = &amp;H100  FleAllowMultiSelect = &amp;H200  FleExtensionDifferent = &amp;H400  FlePathMustExist = &amp;H800  FleFileMustExist = &amp;H1000  FleCreatePrompt = &amp;H2000  FleShareAware = &amp;H4000  FleNoReadOnlyReturn = &amp;H8000  FleNoTestFileCreate = &amp;H10000  FleNoNetworkButton = &amp;H20000  FleExplorer = &amp;H80000  FleLongnames = &amp;H200000End EnumPublic Property Get DefaultExt() As String  ' Returns: The default extension  ' Source: Total VB SourceBook 6  DefaultExt = m_strDefaultExtEnd PropertyPublic Property Let DefaultExt(ByVal strValue As String)  ' strValue: Set the default extension used for a filename  ' Source: Total VB SourceBook 6  m_strDefaultExt = strValueEnd PropertyPublic Property Get DialogTitle() As String  ' Returns: The title displayed in the dialog  ' Source: Total VB SourceBook 6  DialogTitle = m_strDialogTitleEnd PropertyPublic Property Let DialogTitle(ByVal strValue As String)  ' strValue: Set the title displayed in the dialog  ' Source: Total VB SourceBook 6  m_strDialogTitle = strValueEnd PropertyPublic Property Get FileName() As String  ' Returns: The path and filename  ' Source: Total VB SourceBook 6  FileName = m_strFileNameEnd PropertyPublic Property Let FileName(ByVal strValue As String)  ' strValue: Set the filename  ' Source: Total VB SourceBook 6  m_strFileName = strValueEnd PropertyPublic Property Get FileTitle() As String  ' Returns: The filename without the path  ' Source: Total VB SourceBook 6  FileTitle = m_strFileTitleEnd PropertyPublic Property Let FileTitle(ByVal strValue As String)  ' strValue: Set the file title  ' Source: Total VB SourceBook 6  m_strFileTitle = strValueEnd PropertyPublic Property Get Filter() As String  ' Returns: The filter string  ' Source: Total VB SourceBook 6  Filter = m_strFilterEnd PropertyPublic Property Let Filter(ByVal strValue As String)  ' strValue: Set the filter string  ' Source: Total VB SourceBook 6  m_strFilter = strValueEnd PropertyPublic Property Get FilterIndex() As Integer  ' Returns: The index of the filter to display  ' Source: Total VB SourceBook 6  FilterIndex = m_intFilterIndexEnd PropertyPublic Property Let FilterIndex(ByVal intValue As Integer)  ' Set the index of the filter to display  ' Source: Total VB SourceBook 6  m_intFilterIndex = intValueEnd PropertyPublic Property Get Flags() As EnumFilFlags  ' Returns: The flags  ' Source: Total VB SourceBook 6  Flags = m_eFlagsEnd PropertyPublic Property Let Flags(ByVal eValue As EnumFilFlags)  ' eValue: Set the flags  ' Source: Total VB SourceBook 6  m_eFlags = eValueEnd PropertyPublic Property Get hWndParent() As Long  ' Returns: The parent hwnd  ' Source: Total VB SourceBook 6  hWndParent = m_lnghWndParentEnd PropertyPublic Property Let hWndParent(ByVal lngValue As Long)  ' lngValue: Set the parent hwnd  ' Source: Total VB SourceBook 6  m_lnghWndParent = lngValueEnd PropertyPublic Property Get InitialDir() As String  ' Returns: The current value of InitialDir  ' Source : Total VB SourceBook 6  InitialDir = m_strInitialDirEnd PropertyPublic Property Let InitialDir(ByVal strValue As String)  ' strValue: Set to the path where the dialog should open  ' Source  : Total VB SourceBook 6  m_strInitialDir = strValueEnd PropertyPublic Property Get MaxFileSize() As Integer  ' Returns: The maximum length of the filename  ' Source: Total VB SourceBook 6  MaxFileSize = m_intMaxFileSizeEnd PropertyPublic Property Let MaxFileSize(ByVal intValue As Integer)  ' intValue: Set the maximum length of the filename  ' Source: Total VB SourceBook 6  m_intMaxFileSize = intValueEnd PropertyPublic Function Show(fOpen As Boolean) As Boolean  ' Comments  : This procedure displays the file Open/Save common dialog  ' Parameters: fOpen - Determines if the Open or Save dialog is displayed.  ' Returns   : False if cancel selected, true otherwise.  ' Source    : Total VB SourceBook 6  '  Dim of As OPENFILENAME  Dim strChar As String * 1  Dim intCounter As Integer  Dim strTemp As String    On Error GoTo PROC_ERR    ' Initialize the OPENFILENAME type  of.lpstrTitle = m_strDialogTitle &amp; ""  of.Flags = m_eFlags  of.lpstrDefExt = m_strDefaultExt &amp; ""  of.lStructSize = LenB(of)  of.lpstrFilter = m_strFilter &amp; "||"  of.nFilterIndex = m_intFilterIndex    ' To make Windows-style filter, replace pipes with nulls  For intCounter = 1 To Len(m_strFilter)    strChar = Mid$(m_strFilter, intCounter, 1)    If strChar = "|" Then      strTemp = strTemp &amp; vbNullChar    Else      strTemp = strTemp &amp; strChar    End If  Next    ' Put double null at end  strTemp = strTemp &amp; vbNullChar &amp; vbNullChar  of.lpstrFilter = strTemp    ' Pad file and file title buffers to maximum path length  strTemp = m_strFileName &amp; String$(cintMaxFileLength - Len(m_strFileName), 0)  of.lpstrFile = strTemp  of.nMaxFile = cintMaxFileLength    strTemp = m_strFileTitle &amp; String$(cintMaxFileLength - Len(m_strFileTitle), 0)  of.lpstrFileTitle = strTemp  of.lpstrInitialDir = m_strInitialDir  of.nMaxFileTitle = cintMaxFileLength  of.hwndOwner = m_lnghWndParent    ' If fOpen is true, show the Open file dialog, otherwise show the Save dialog  If fOpen Then    If GetOpenFileName(of) Then      Show = True      ' Assign property variables to appropriate values      m_strFileName = TrimNulls(of.lpstrFile)      m_strFileTitle = TrimNulls(of.lpstrFileTitle)    Else      Show = False    End If  Else    If GetSaveFileName(of) Then      Show = True      ' Assign property variables to appropriate values      m_strFileName = TrimNulls(of.lpstrFile)      m_strFileTitle = TrimNulls(of.lpstrFileTitle)    Else      Show = False    End If  End If  PROC_EXIT:  Exit Function  PROC_ERR:  MsgBox "Error: " &amp; Err.Number &amp; ". " &amp; Err.Description, , _  "Show"  Resume PROC_EXITEnd FunctionPrivate Function TrimNulls(ByVal strIn As String) As String  ' Comments  : Returns the passed string terminated at the first null  ' Parameters: strIn - Value to parse  ' Returns   : Parsed string  ' Source    : Total VB SourceBook 6  '  Dim intPos As Integer    On Error GoTo PROC_ERR      intPos = InStr(strIn, vbNullChar)    If intPos = 0 Then    ' No nulls in the string, just return it as is    TrimNulls = strIn  Else    If intPos = 1 Then      ' If the null character is at the first position, the      ' entire string is a null string, so return a zero-length string      TrimNulls = ""    Else      ' Not at the first position, so return the contents up      ' to the occurrence of the null character      TrimNulls = Left$(strIn, intPos - 1)    End If  End If    PROC_EXIT:  Exit Function  PROC_ERR:  MsgBox "Error: " &amp; Err.Number &amp; ". " &amp; Err.Description, , _    "TrimNulls"  Resume PROC_EXIT    End Function------------Использование:1. Добавьте кнопку  ' cmdTest '2. Вставьте весь код примера в форму.3. Выполните форму.Private Sub cmdTest_Click()  ' Create a simple File|Open dialog and return the  ' file name selected    Dim FileDialog As CFileDialog  Set FileDialog = New CFileDialog    With FileDialog    .DefaultExt = "txt"    .DialogTitle = "VB SourceBook Example File Open"    .Filter = "Text files (*.txt)|*.txt|All Files (*.*)|*.*"    .FilterIndex = 0    .Flags = FleFileMustExist + FleHideReadOnly + FleCreatePrompt    .hWndParent = Me.hWnd    .MaxFileSize = 255    If .Show(True) Then      MsgBox "File selected: " &amp; .FileName &amp; vbCrLf &amp; "File name only: " &amp; _        .FileTitle    Else      MsgBox "User cancelled"    End If      End With  End SubPs: А насчет своей кнопочки я где то видел на наших сайтах пример....</description><pubDate>Fri, 09 Jun 2000 11:35:00 GMT</pubDate><dc:creator>Alex72</dc:creator></item><item><title>Как создать нормальный ComDlg?</title><link>http://www.relib.com/forums/Topic486-1-1.aspx</link><description>Не могу создать нормальное окно CommonDialog'а. Насчет UserControl'a "Microsoft common dialog control" мне известно. Но создать такое окно, добавив свои кнопки и еще что-нибудь я не могу. Например, при компилировании в VB 6 в окне есть кроме кнопки "открыть" кнопка "Options...". Знаю, что есть control ComDlg (именно не CommonDialog, а ComDlg). Но там невообразимое количество свойств и ссылок на другие объекты, и там я не разобрался. Если кто знает - помогите. Буду благодарен.</description><pubDate>Thu, 08 Jun 2000 09:46:00 GMT</pubDate><dc:creator>member</dc:creator></item></channel></rss>