На главную

On-line справка по Win32 API

Написать письмо
БЕСПЛАТНАЯ ежедневная online лотерея! Выигрывай каждый день БЕСПЛАТНО!
Список всех статей A-B-C-D-E-F-G-H-I-J-K-L-M-N-O-P-Q-R-S-T-U-V-W-X-Y-Z | Скачать Вниз

Filters



The information in this section applies to both Explorer-style and old style Open and Save As dialog boxes.

You can provide filename filters to assist the user in limiting the filenames that the dialog box displays. A filename filter consists of a pair of null-terminated strings, a description and a pattern, one concatenated to the other. The dialog box displays the description to let the user pick which filter to use; and it uses the pattern to select the files to display.
To specify the filters, set the lpstrFilter member of the OPENFILENAME structure to point to a buffer that contains an array of filter string pairs. The last string in the array must be followed by an extra null character.

A pattern string can be a combination of valid filename characters and the asterisk (*). The asterisk is a wildcard that represents any combination of valid filename characters. The dialog box displays only those files that match the pattern. To specify multiple patterns for the same description, you must use a semicolon (;) to separate the patterns. Note that space characters in the pattern string can produce unexpected results.
The following code fragment specifies two filters. The filter with the "Source" description has two patterns. If the user selects this filter, the dialog box displays only files that have the .C and .CXX extensions.

OPENFILENAME ofn; // common dialog box structure

ofn.lpstrFilter = "Source\0*.C;*.CXX\0All\0*.*\0"
ofn.nFilterIndex = 1;


The nFilterIndex member of the OPENFILENAME structure specifies an index that indicates which filter the dialog box initially uses. The first filter in the buffer has index 1, the second 2, and so on. If the user changes the filter while using the dialog box, the nFilterIndex member is set to the index of the selected filter on return.
You can create a custom filter by setting the lpstrCustomFilter member to the address of a buffer that contains a single filter, and by setting the nMaxCustFilter member to the size of the buffer, in characters or bytes. The dialog box always places the custom filter at the beginning of the list of filters and, on return, always updates the pattern part of the filter with the pattern from the filter selected by the user.

For Explorer-style dialog boxes, the default extension may change if the user selects a different filter. If the user selects a filter whose first pattern is of the form *.
xxx (that is, the extension does not include a wildcard character), the dialog box uses xxx as the default extension. This occurs only if you specified a default extension in the lpstrDefExt member of the OPENFILENAME structure. For example, if the user selects the "Source\0*.C;*.CXX\0" filter, the default extension changes to "C". However, if you had defined the filter as "Source\0*.C*\0", the default extension would not change because the extension includes a wildcard.


Пригласи друзей и счет твоего мобильника всегда будет положительным!
Предыдущая статья
 
Сайт Народ.Ру Интернет
Следующая статья
Пригласи друзей и счет твоего мобильника всегда будет положительным!

Фильтры



Информация в этой секции относится как к стилю Explorer-так и старый стиль Открытому и Сохраняемому Как диалоговые блоки.

Вы можете обеспечить filename фильтры, чтобы помогать пользователю в ограничивающем filenames, что диалоговый блок отображает. Фильтр filename состоит из пары недействительный расторгнутых строк, описание и образец, один конкатенированное другому. Диалоговый блок отображает описание, чтобы позволять указке пользователя какой фильтр, чтобы использовать; и это использует образец, чтобы выбираться файлы, чтобы отображаться.
Для того, чтобы определять фильтры, установите элемент lpstrFilter структуры OPENFILENAME, чтобы указывать на буфер, который содержит массив пар строки фильтра. Последняя строка в массиве должна последовать за дополнительным недействительным символом.

Строка образца может быть комбинацией правильных filename символов и звездочка (*). Звездочка является шаблоном, который представляет любую комбинацию правильных filename символов. Диалоговый блок отображает только те файлы, что соответствовать образцу. Чтобы определять многочисленные образцы для того же описания, Вы должны использовать точку с запятой (;), чтобы разделять образцы. Отметьте, что космические символы в строке образца могут произвести неожиданные результаты.
Кодовый фрагмент следующего определяет два фильтра. Фильтр с описанием "Источника" имеет два образца. Если пользователь выбирается этот фильтр, только файлы дисплеев диалогового блока, которые имеют .C и расширения .CXX.

ofn OPENFILENAME; // общая диалоговая структура блока

ofn.lpstrFilter = "Source\0*.C;*.CXX\0All\0*.*\0" ofn.nFilterIndex = 1;


Элемент nFilterIndex структуры OPENFILENAME определяет индекс, который указывает какой фильтр, что диалоговый блок первоначально использует. Первый фильтр в буфере имеет индекс 1, вторые 2, и так далее. Если пользователь изменяет фильтр при использовании диалогового блока, элемент nFilterIndex установлен в индекс выбранного фильтра в возврате.
Вы можете создать заказной фильтр устанавливая элемент lpstrCustomFilter по адресу буфера, который содержит единственный фильтр, и устанавливая элемент nMaxCustFilter по величине с буфером, в символах или байтах. Диалоговый блок всегда устанавливает заказной фильтр в начале списка фильтров и, в возврате, всегда корректирует часть образца фильтра с образцом из фильтра выбранного пользователем.

Для диалоговых блоков стиля Explorer-, по умолчанию расширение может измениться если пользователь выбирается другой фильтр. Если пользователь выбирается фильтр, чей первый образец - формы *.
xxx (то есть, расширение не включает символ шаблона), диалоговый блок использует xxx как по умолчанию расширение. Это происходит только если Вы определили бы по умолчанию расширение в элементе lpstrDefExt структуры OPENFILENAME. Например, если пользователь выбирается "Source\0*.C;*.CXX\0" фильтр, по умолчанию расширение изменяется на "C". Тем не менее, если Вы определили бы фильтр как "Source\0*.C*\0", по умолчанию расширение не захочет изменяться поскольку расширение включает шаблон.


Вверх Version 1.3, Oct 26 2010 © 2007, 2010, mrhx Вверх
 mrhx software  Русский перевод OpenGL  Русский перевод Win32 API
 
Используются технологии uCoz