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

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


AfxMessageBox timeout

Jim Krahn -- Jim_Krahn@globalvillag.com
Monday, July 29, 1996

Environment: VC++ 4.x, Win 95

How can I get a standard AfxMessageBox to timeout after a specified
period of time instead of waiting for the user to hit the ok or cancel
buttons?

I have created my own dialog box with a timer but I don't get the nice
window sizing and information/warning icons of the standard
AfxMessageBox.

Thanks, Jim



Kit Kauffmann -- kitk@mudshark.sunquest.com
Friday, August 02, 1996

[Mini-digest: 3 responses]

>Environment: VC++ 4.x, Win 95
>
>How can I get a standard AfxMessageBox to timeout after a specified
>period of time instead of waiting for the user to hit the ok or cancel
>buttons?
>
>I have created my own dialog box with a timer but I don't get the nice
>window sizing and information/warning icons of the standard
>AfxMessageBox.
>
>Thanks, Jim

You'll have to do the timout thing yourself, Jim, but to close a MessageBox, 
I use code like:

        CDialog* pMsgBox;
        if( pMsgBox = (CDialog*) CWnd::FindWindow( "#32770",
                                                   AfxGetAppName() ) )
                pMsgBox->EndDialog( IDCANCEL );

HTH!
I don't suffer from insanity.  I enjoy every minute of it.

-----From: Qing Zhao 

Hi, Jim

You can setup the timer inside your app. When you call MessageBox, reset
the timer. After time out, use FindWindow (NULL, lpstrCaption) to find
MessageBox. If Window is still there, then destroy it.
Good Luck!

QING ZHAO "Syncro Development Corp"
qzhao@syncro.com

-----From: Gonzalo Isaza 

Create the timer before the message box is created.   Then call
AfxMessageBox.  Your timer routine keeps track of the active window.
Once the active window changes it can check the caption to make sure it
is the message box.  The timer callback routine keeps track of the time
now.  Once the timeout takes place, it calls
DestroyWindow(hwndMessageBox).

If the message box is destroyed by the user, you just kill the timer
immediately after.

Good luck.

Gonzalo

I speak for myself.  I do not speak for Microsoft.





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