На главную

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

Modal Dialog Boxes



A modal dialog box should be a pop-up window having a System menu, a title bar, and a thick border; that is, the dialog box template should specify the WS_POPUP, WS_SYSMENU, WS_CAPTION, and DS_MODALFRAME styles. Although an application can designate the WS_VISIBLE style, Windows always displays a modal dialog box regardless of whether the dialog box template specifies the WS_VISIBLE style. An application must not create a modal dialog box having the WS_CHILD style. A modal dialog box with this style disables itself, preventing any subsequent input from reaching the application.

An application creates a modal dialog box by using either the DialogBox or DialogBoxIndirect function. DialogBox requires the name or identifier of a resource containing a dialog box template; DialogBoxIndirect requires the handle of a memory object containing a dialog box template. The DialogBoxParam and DialogBoxIndirectParam functions also create modal dialog boxes; they are identical to the previously mentioned functions but pass a specified parameter to the dialog box procedure when the dialog box is created.

When creating the modal dialog box, Windows makes it the active window. The dialog box remains active until the dialog box procedure calls the EndDialog function or Windows activates a window in another application. Neither the user nor the application can make the owner window active until the modal dialog box is destroyed.
When the owner window is not already disabled, Windows automatically disables the window and any child windows belonging to it when it creates the modal dialog box. The owner window remains disabled until the dialog box is destroyed. Although a dialog box procedure could potentially enable the owner window at any time, enabling the owner defeats the purpose of the modal dialog box and is not recommended. When the dialog box procedure is destroyed, Windows enables the owner window again, but only if the modal dialog box caused the owner to be disabled.

As Windows creates the modal dialog box, it sends the WM_CANCELMODE message to the window (if any) currently capturing mouse input. An application that receives this message should release the mouse capture so that the user can move the mouse in the modal dialog box. Because Windows disables the owner window, all mouse input is lost if the owner fails to release the mouse upon receiving this message.
To process messages for the modal dialog box, Windows starts its own message loop, taking temporary control of the message queue for the entire application. When Windows retrieves a message that is not explicitly for the dialog box, it dispatches the message to the appropriate window. If it retrieves a WM_QUIT message, it posts the message back to the application message queue so that the application's main message loop can eventually retrieve the message.

Windows sends the WM_ENTERIDLE message to the owner window whenever the application message queue is empty. The application can use this message to carry out a background task while the dialog box remains on the screen. When an application uses the message in this way, the application must frequently yield control (for example, by using the PeekMessage function) so that the modal dialog box can receive any user input. To prevent the modal dialog box from sending the WM_ENTERIDLE messages, the application can specify the DS_NOIDLEMSG style when creating the dialog box.

An application destroys a modal dialog box by using the EndDialog function. In most cases, the dialog box procedure calls EndDialog when the user chooses the Close command from the dialog box's System menu or chooses the OK or Cancel button in the dialog box. The dialog box can return a value through the DialogBox function (or other creation functions) by specifying a value when calling the EndDialog function. Windows returns this value after destroying the dialog box. Most applications use this return value to determine whether the dialog box completed its task successfully or was canceled by the user. Windows does not return control from the function that creates the dialog box until the dialog box procedure has called the EndDialog function.


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

Модальные Диалоговые Ящики



Модальный диалоговый блок должен быть управляющим окном, имеющим меню Системы, зона названия, и толстую границу; то есть, диалоговый шаблон блока должен определить WS_POPUP, WS_SYSMENU, WS_CAPTION, и стили DS_MODALFRAME. Хотя приложение может определить стиль WS_VISIBLE, Windows всегда отображает модального диалогового блока независимо от того, что диалоговый шаблон блока определяет стиль WS_VISIBLE. Приложение не должно создавать модального диалогового блока, имеющего стиль WS_CHILD. Модальный диалоговый блок с этим стилем выводит из строя себя, предохраняя любой последующий ввод чтобы достигать приложения.

Приложение создает модального диалогового блока используя или DialogBox или функция DialogBoxIndirect. DialogBox ТРЕБУЕТ имя или идентификатор ресурса, содержащие диалоговый шаблон блока; DialogBoxIndirect ТРЕБУЕТ ручку объекта памяти, содержащей диалоговый шаблон блока. DialogBoxParam И функции DialogBoxIndirectParam также создают модальных диалоговых блоков; они идентичны прежде упомянутым функциям но передают определенный параметр диалоговому блоку процедуры когда диалоговый блок создан.

При создании модального диалогового блока, Windows делает это активное окно. Диалоговый блок остается активным пока диалоговый блок процедуры не назовет функцию EndDialog или Windows активизирует окно в другом приложении. Ни пользователь ни приложение может сделать окном владельца активным пока модальный диалоговый блок не будет уничтожен.
Когда окно владельца уже не выведено из строя, Windows автоматически выводит из строя окно и любое окно ребенка, принадлежащие этому когда это создает модального диалогового блока. Остатки окна владельца выведенные из строя пока диалоговый блок не будет уничтожен. Хотя диалоговый блок процедуры мог бы потенциально приспособиться окно владельца в любое время, приспосабливающееся владельца побеждает цель модального диалогового блока и не рекомендован. Когда диалоговый блок процедуры уничтожен, Windows приспосабливается окно владельца снова, но только если модальный диалоговый блок вызывал бы владельца, который нужно выводиться из строя.

Как Windows создает модального диалогового блока, это посылает сообщение WM_CANCELMODE в окно (если имеется) к настоящему времени захватывая ввод мыши. Приложение, которое получает это сообщение должно выпускать сбор мыши чтобы пользователь может переместить мышь в модальный диалоговый блока. Поскольку Windows выводит из строя окно владельца, весь ввод мыши потерен если владелец не выпускает мышь на, получающий это сообщение.
Для того, чтобы обрабатывать сообщения для модального диалогового блока, Windows начинает свой собственный цикл сообщения, временного управления взятия очередью сообщения для целого приложения. Когда Windows извлекает сообщение, которое - не явно для диалогового блока, это посылает сообщение в подходящее окно. Если это извлекает сообщение WM_QUIT, это посылает сообщение в прикладную очередь сообщения чтобы прикладной основной цикл сообщения может в конечном счете извлечь сообщение.

Windows посылает сообщение WM_ENTERIDLE в окно владельца всякий раз, когда прикладная очередь сообщения пустая. Приложение может использовать это сообщение, чтобы выполнять задачу фона тогда как диалоговый блок остается на экране. Когда приложение использует сообщение таким образом, приложение должно часто дать управление (например, используя функцию PeekMessage) чтобы модальный диалоговый блок может получить любой ввод пользователя. Чтобы мешать модального диалогового блока чтобы посылать сообщения WM_ENTERIDLE, приложение может определить стиль DS_NOIDLEMSG при создании диалогового блока.

Приложение уничтожает модального диалогового блока используя функцию EndDialog. В большинстве случаев, диалоговый блок процедуры вызывает EndDialog когда пользователь выбирает Закрытую команду из меню Системы диалогового блока или выбирает OK или Отменяет кнопку в диалоговом блоке. Диалоговый блок может возвращать величину через функцию DialogBox (или другие функции создания) определяя величину при разговоре функции EndDialog. Windows возвращает эту величину после уничтожать диалогового блока. Большинство приложений используют эту обратную величину, чтобы определять завершал диалоговый блок задачу успешно или был отменен пользователем. Windows не возвращает управление из функции, которая создает диалогового блока пока диалоговый блок процедуры не был вызван функция EndDialog.


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