GSMessageBox - Auto-Kill
The code
GSMSGBOX msg = { 0 };
msg.cbSize = sizeof( msg );
msg.uFlags = GS_MSGBOX_KILLTIMER;
msg.uKillTimer = 3;
int n = GSMessageBox( NULL
, _T("This window will close in <T> second(s)")
, _T("Caption")
, MB_OKCANCEL | MB_DEFBUTTON2
, &msg );
Notes
All we do is declare an appropriate structure, set some values and then call the API.
uKillTimer
is in seconds.- If the user does nothing and lets the timer expire then the default action is taken. You can change this to do whatever you want using the standard MessageBox behaviour to alter the default buttons
<T>
gives you the ability to place the timer value in the text. You can add this anywhere and as many times as you like.