15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


When DoModal is not modal

Paulo Soares -- psoares@ip.pt
Tuesday, June 11, 1996

(vc++4.1,win95)

I've got an application created from the example 'hello' (no view/doc) =
with two threads: the main thread (GUI) and a worker thread. The worker =
thread interacts with the main thread through user messages. The worker =
thread must at some time create a modal dialog. To avoid the problems =
with objects across threads, the worker thread sends a WM_USER message =
to the main thread to create the dialog. The dialog itself is in an =
extension DLL. The route to create the dialog is:

  worker thread -> WM_USER message -> function in ext DLL -> DoModal =
also in ext DLL

So far so good. The dialog shows up and does what is supposed to do, so =
does the worker thread. Clicking the mouse in the main window doesn't =
move the focus. The problem arises when I do ALT-TAB. The focus moves to =
the main window and when I do ALT-TAB again the main window icon =
disappears from the icon list. The only way to return to the application =
is to click in the start bar. I know that in the MFC the modal dialogs =
are simulated but they should work as intended. The stranger thing (or =
maybe not) is that I have a context menu (mouse rigth click) and one of =
the options creates a modal dialog without any problems. The working is =
the same except that all happens in the same main thread and module.
Any help or hints would be appreciated.

Best Regards,
Paulo Soares
psoares@ip.pt





Dave Kolb -- sasdxk@unx.sas.com
Thursday, June 13, 1996

At 08:24 PM 6/11/96 +-100, Paulo Soares wrote:
>(vc++4.1,win95)
>
>I've got an application created from the example 'hello' (no view/doc) with
two threads: the main thread (GUI) and a worker thread. The worker thread
interacts with the main thread through user messages. The worker thread must
at some time create a modal dialog. To avoid the problems with objects
across threads, the worker thread sends a WM_USER message to the main thread
to create the dialog. The dialog itself is in an extension DLL. The route to
create the dialog is:
>
>  worker thread -> WM_USER message -> function in ext DLL -> DoModal also
in ext DLL
>
>So far so good. The dialog shows up and does what is supposed to do, so
does the worker thread. Clicking the mouse in the main window doesn't move
the focus. The problem arises when I do ALT-TAB. The focus moves to the main
window and when I do ALT-TAB again the main window icon disappears from the
icon list. The only way to return to the application is to click in the
start bar. I know that in the MFC the modal dialogs are simulated but they
should work as intended. The stranger thing (or maybe not) is that I have a
context menu (mouse rigth click) and one of the options creates a modal
dialog without any problems. The working is the same except that all happens
in the same main thread and module.
>Any help or hints would be appreciated.

Each thread has it's own message queue and modal dialogs are modal for that
thread only I believe. I think you can specify a DS_SYSMODAL style however
they are not really modal for the entire system in win32 just your process.
Perhaps that's what you need.

Dave Kolb                     Compuserve: 72410,407@compuserve.com
SAS Institute, Inc.           EMAIL:      sasdxk@unx.sas.com
SAS Campus Drive - R3282      Phone:      (919) 677-8000 x6827
Cary, NC  27513-2414 USA      FAX:        (919) 677-8123





| Вернуться в корень Архива |