• Welcome to Valhalla Legends Archive.
 

Another Question

Started by ChR0NiC, October 06, 2003, 01:52 AM

Previous topic - Next topic

Skywing

Quote from: Adron on October 08, 2003, 10:32 AM
Ah. How interesting! I never checked that. Nothing wrong in making your own message boxes with dialogs then. It just uses some tight message loop that doesn't retrieve messages for other windows?
It uses the standard modal dialog message loop, like you see with DialogBox().  I was wondering just how it worked, yesterday, but I didn't have time to fully investigate.  I'm pretty sure that it does take a look at messages for other windows, though, and if those messages would cause the dialog to lose focus, it beeps at you and flashes the title bar (presumably instead of passing it on to the other window procedure).  Of course, there could be some special support for modal message loops in win32k.sys; like I said, I'm not entirely certain.  Try using Spy++ to see what the parent hwnd receives message-wise when a modal dialog owned by it is up.

Adron

Maybe this is different, but I have a feeling that in VB, showing a form modally still lets timer events occur on the parent form, but showing a message box does not. I'm not 100% certain though.

Skywing

Quote from: Adron on October 08, 2003, 12:30 PM
Maybe this is different, but I have a feeling that in VB, showing a form modally still lets timer events occur on the parent form, but showing a message box does not. I'm not 100% certain though.
Do VB timers actually use WM_TIMER, though, or something else?

Adron

Test application: Two forms, form1 having two command buttons, a timer and a label, the timer being set for 100 ms interval.

form1:

Option Explicit

Private Sub Command1_Click()
 Form2.Show 1
End Sub

Private Sub Command2_Click()
 MsgBox "test"
End Sub

Private Sub Timer1_Timer()
 Label1.Caption = Now
End Sub


Clicking Command2 pauses the clock, clicking Command1 doesn't.

Adron

Quote from: Skywing on October 08, 2003, 02:23 PM
Quote from: Adron on October 08, 2003, 12:30 PM
Maybe this is different, but I have a feeling that in VB, showing a form modally still lets timer events occur on the parent form, but showing a message box does not. I'm not 100% certain though.
Do VB timers actually use WM_TIMER, though, or something else?

They do use WM_TIMER.

Skywing

Quote from: Adron on October 08, 2003, 02:46 PM
Quote from: Skywing on October 08, 2003, 02:23 PM
Quote from: Adron on October 08, 2003, 12:30 PM
Maybe this is different, but I have a feeling that in VB, showing a form modally still lets timer events occur on the parent form, but showing a message box does not. I'm not 100% certain though.
Do VB timers actually use WM_TIMER, though, or something else?

They do use WM_TIMER.
I noticed something interesting.  You can run a modal dialog box in a different thread from the owner, and it still seems to have the same magic block-interaction-with-owner properties.  Thus, it's message loop really can't be just filtering messages from the owner window, because it's in the wrong thread, and the owner window is still running it's own, normal message loop.

Kp

Quote from: Skywing on October 08, 2003, 03:56 PM
I noticed something interesting.  You can run a modal dialog box in a different thread from the owner, and it still seems to have the same magic block-interaction-with-owner properties.  Thus, it's message loop really can't be just filtering messages from the owner window, because it's in the wrong thread, and the owner window is still running it's own, normal message loop.
I can't tell for sure from the documentation, but perhaps AttachThreadInput would allow the message box to bypass this limitation and receive the requisite input?
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

iago

#22
Quote from: Skywing on October 08, 2003, 03:56 PM
Quote from: Adron on October 08, 2003, 02:46 PM
Quote from: Skywing on October 08, 2003, 02:23 PM
Quote from: Adron on October 08, 2003, 12:30 PM
Maybe this is different, but I have a feeling that in VB, showing a form modally still lets timer events occur on the parent form, but showing a message box does not. I'm not 100% certain though.
Do VB timers actually use WM_TIMER, though, or something else?

They do use WM_TIMER.
I noticed something interesting.  You can run a modal dialog box in a different thread from the owner, and it still seems to have the same magic block-interaction-with-owner properties.  Thus, it's message loop really can't be just filtering messages from the owner window, because it's in the wrong thread, and the owner window is still running it's own, normal message loop.

In Richter's book (Programming applications in microsoft windows 3rd edition), there's a demo program that had a messagebox display a countdown message, and if the countdown reaches 0 it's automatically closed.  I know this is done from a different thread, but I'm not too sure beyond that.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Adron

#23
From the topic Modal Dialog Boxes:  (note that the forum breaks the link, you will have to fix it if you want to follow it)

Quote
When the owner window is not already disabled, the system 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, the system enables the owner window again, but only if the modal dialog box caused the owner to be disabled.

As the system 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 the system 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, the system starts its own message loop, taking temporary control of the message queue for the entire application. When the system 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.



Hitmen

I'm not sure what http://ms-help:// is but it doesn't look like a valid domain to me :P

Yoni

Yes,

Quote from: Adron on October 08, 2003, 05:24 PM
(note that the forum breaks the link, you will have to fix it if you want to follow it)

ms-help:// URLs are MSDN links, you need MSDN installed to follow them (in IE or in Document Explorer).

Zakath

In case anyone is wondering, this is what it should look like.
Quote from: iago on February 02, 2005, 03:07 PM
Yes, you can't have everybody...contributing to the main source repository.  That would be stupid and create chaos.

Opensource projects...would be dumb.