Click here to Skip to main content
16,007,687 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Please see why it happened Pin
Ryan Binns8-Jul-03 20:51
Ryan Binns8-Jul-03 20:51 
GeneralRe: Please see why it happened Pin
Toni788-Jul-03 21:03
Toni788-Jul-03 21:03 
GeneralRe: Please see why it happened Pin
Ryan Binns8-Jul-03 21:07
Ryan Binns8-Jul-03 21:07 
GeneralRe: Please see why it happened Pin
Toni788-Jul-03 21:16
Toni788-Jul-03 21:16 
GeneralRe: Please see why it happened Pin
Ryan Binns8-Jul-03 21:21
Ryan Binns8-Jul-03 21:21 
GeneralRe: Please see why it happened Pin
Toni788-Jul-03 21:40
Toni788-Jul-03 21:40 
GeneralRe: Please see why it happened Pin
Ryan Binns8-Jul-03 21:46
Ryan Binns8-Jul-03 21:46 
GeneralRe: Please see why it happened Pin
Iain Clarke, Warrior Programmer8-Jul-03 22:58
Iain Clarke, Warrior Programmer8-Jul-03 22:58 
While it takes a little abstract thought, this isn't all that wierd when you think about the guts of
the DialogBox function.

In your OnClick1 function, you post a message in to the threads message queue.

You then call the MessageBox function.
This then calls the ::DialogBox function after having set up the parameters for you.
The ::DialogBox function displays a Modal dialog. It can also work from console apps.
So it has to have its own message pump.

After having created the MessageBox window (which is all a dlg is), it gets these messages:
MSG(hWnd1, WM_USER1, 0, 0)
MSG(hDlg, WM_NCCREATE, ...)
MSG(hDlg, WM_CREATE, ...)
MSG(hDlg, WM_PAINT, ...)
etc.

It dispatches (DispatchMessage) with them in the order it gets them.

"Aha!" you say, it should filter out the messages not for the dialog. But it can't. For multiple
reasons, some of which mentioned in other responses.
e.g. If you move the dialog about, the window "behind" it needs to get WM_ERASEBKGND, WM_PAINT, WM_NC*
etc.
You may have background activity needing WM_TIMER messages etc.

The point being windows can't *know* not to pass on all but a few messages, so it does.

This is why your beep happens before you see the dialog. If you *really* want it after, post the message
after.

This has been a little wordy, but behind MFC and its On...s, there is SDK code, with messages, pumps,
the whole shebang.


Iain.

GeneralRe: Please see why it happened Pin
Ryan Binns8-Jul-03 23:04
Ryan Binns8-Jul-03 23:04 
GeneralRe: Please see why it happened Pin
Iain Clarke, Warrior Programmer9-Jul-03 1:02
Iain Clarke, Warrior Programmer9-Jul-03 1:02 
GeneralRe: Please see why it happened Pin
Ryan Binns9-Jul-03 1:26
Ryan Binns9-Jul-03 1:26 
GeneralRe: Please see why it happened Pin
Anonymous9-Jul-03 0:14
Anonymous9-Jul-03 0:14 
GeneralRe: Please see why it happened Pin
Iain Clarke, Warrior Programmer9-Jul-03 0:56
Iain Clarke, Warrior Programmer9-Jul-03 0:56 
GeneralRe: Please see why it happened Pin
Toni789-Jul-03 13:44
Toni789-Jul-03 13:44 
GeneralCrystal report Pin
modular8-Jul-03 19:35
modular8-Jul-03 19:35 
GeneralDisplaying the line of the source code in case of an error Pin
Jerome Conus8-Jul-03 19:18
Jerome Conus8-Jul-03 19:18 
GeneralRe: Displaying the line of the source code in case of an error Pin
Ryan Binns8-Jul-03 19:22
Ryan Binns8-Jul-03 19:22 
GeneralAbout MessageBoxEX Pin
FlyingDancer8-Jul-03 19:17
FlyingDancer8-Jul-03 19:17 
GeneralRe: About MessageBoxEX Pin
Ryan Binns8-Jul-03 19:21
Ryan Binns8-Jul-03 19:21 
GeneralRe: About MessageBoxEX Pin
Ryan Binns8-Jul-03 19:24
Ryan Binns8-Jul-03 19:24 
GeneralRe: About MessageBoxEX Pin
FlyingDancer8-Jul-03 19:35
FlyingDancer8-Jul-03 19:35 
GeneralRe: About MessageBoxEX Pin
Ryan Binns8-Jul-03 19:42
Ryan Binns8-Jul-03 19:42 
GeneralRe: About MessageBoxEX Pin
FlyingDancer8-Jul-03 20:05
FlyingDancer8-Jul-03 20:05 
GeneralRe: About MessageBoxEX Pin
Ryan Binns8-Jul-03 20:10
Ryan Binns8-Jul-03 20:10 
GeneralRe: About MessageBoxEX Pin
FlyingDancer8-Jul-03 20:27
FlyingDancer8-Jul-03 20:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.