На главную

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 | Скачать Вниз

The WM_INITDIALOG Message



Windows does not send a WM_CREATE message to the dialog box procedure. Instead, it sends a WM_INITDIALOG message when it creates the dialog box and all its controls but before it displays the dialog box. The procedure should carry out any initialization required to ensure that the dialog box displays the current settings associated with the command or task. For example, when a dialog box contains a control to show the current drive and directory, the procedure must determine the current drive and directory and set the control to that value.

The procedure can initialize controls by using functions such as SetDlgItemText and CheckDlgButton. Because controls are windows, the procedure can also manipulate them by using window-management functions such as EnableWindow and SetFocus. The procedure can retrieve the window handle for a control by using the GetDlgItem function.
The dialog box procedure can change the contents, state, and position of any control as needed. For example, in a dialog box that contains a list box of filenames and an Open button, the procedure can disable the Open button until the user selects a file from the list. In this example, the dialog box template specifies the WS_DISABLED style for the Open button and Windows automatically disables the button when creating it. When the dialog box procedure receives a notification message from the list box indicating that the user has selected a file, the procedure calls the EnableWindow function to enable the Open button.

If the application creates the dialog box by using one of the functions DialogBoxParam, DialogBoxIndirectParam, CreateDialogParam, or CreateDialogIndirectParam, the lParam parameter for the WM_INITDIALOG message contains the extra parameter passed to the function. Applications typically use this extra parameter to pass the address of additional initialization information to the dialog box procedure, but the dialog box procedure must determine the meaning of the parameter. If the application uses another function to create the dialog box, Windows sets the lParam parameter to NULL.

Before returning from the WM_INITDIALOG message, the procedure should determine whether it should set the input focus to a given control. If the dialog box procedure returns TRUE, Windows automatically sets the input focus to the control whose window handle is in the wParam parameter. If the control receiving the default focus is not appropriate, it can set the focus to the appropriate control by using the SetFocus function. If the procedure sets the input focus, it must return FALSE to prevent Windows from setting the default focus. The control receiving the default input focus is always the first control given in the template that is visible, not disabled, and has the WS_TABSTOP style. If no such control exists, Windows sets the default input focus to the first control in the template.


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

Сообщение WM_INITDIALOG



Окно не посылает сообщение WM_CREATE в диалоговую процедуру ящика. Взамен, это посылает сообщение WM_INITDIALOG когда это создает диалоговый ящик и все элементы управления но прежде, чем это отобразит диалоговый ящик. Процедура должна выполнить любую инициализацию требовавшуюся, чтобы проверять, что диалоговый ящик отображает текущую обстановку связывался командой или задачей. Например, когда диалоговый ящик содержит управление, чтобы показывать текущий проезд и директорий, процедура должна определить текущий проезд и директорий и устанавливать управление в эту величину.

Процедура может инициализировать элементы управления используя функции как например, SetDlgItemText и CheckDlgButton. Поскольку элементы управления являются окном, процедура может также манипулировать ею используя окно-управление функций как например, EnableWindow и SetFocus. Процедура может извлечь ручку окна для управления используя функцию GetDlgItem.
Диалоговая процедура ящика может изменить содержание, состояние, и позицию любого управления как и требуется. Например, в диалоговом ящике, что содержит ящик списка filenames и Открытой кнопки, процедура может вывести из строя Открытую кнопку пока потребитель не выберется файл из списка. В этом примере, диалоговый шаблон ящика определяет стиль WS_DISABLED для Открытой кнопки и Окно автоматически выводит из строя кнопка при создании это. Когда диалоговая процедура ящика получает сообщение уведомления из ящика списка, указывающего, что потребитель выбрался файл, процедура вызовов функция EnableWindow, чтобы приспосабливаться Открытую кнопку.

Если приложение создает диалоговый ящик используя одну из функций DialogBoxParam, DialogBoxIndirectParam, CreateDialogParam, или CreateDialogIndirectParam, параметр lParam для сообщения WM_INITDIALOG содержит дополнительный параметр пройденный в функцию. Приложения обычно используют этот дополнительный параметр, чтобы передавать адрес дополнительной информации инициализации диалоговому блоку процедуры, но диалоговый блок процедуры должен определить значение параметра. Если приложение использует другую функцию, чтобы создавать диалогового блока, Windows устанавливает параметр lParam на НЕДЕЙСТВИТЕЛЬНЫЙ.

Перед возвратом из сообщения WM_INITDIALOG, процедура должна определить должна она устанавливать входной фокус на данное управление. Если диалоговый блок процедуры возвращает ИСТИНА, Windows автоматически устанавливает входной фокус на управление чья ручка окна - в параметре wParam. Если управление, получающее по умолчанию фокус не подходящее, это может установить фокус на подходящее управление используя функцию SetFocus. Если процедура устанавливает входной фокус, она должна возвращать ЛОЖЬ, чтобы предохранять Windows чтобы устанавливать по умолчанию фокус. Управление, получающее по умолчанию входной фокус является всегда первым управлением данным в шаблоне, который видимый, не выведенный из строя, и имеет стиль WS_TABSTOP. Если никакое такое управление не существует, Windows устанавливает по умолчанию входной фокус на первое управление в шаблоне.


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