sibi
May 11th, 1999, 01:03 AM
How do you blink a particular BUTTON(RED COLOUR) in a DIALOG-BASED form (ex: if some ERROR occcurs)?
|
Click to See Complete Forum and Search --> : HELP!!!__BUTTONS sibi May 11th, 1999, 01:03 AM How do you blink a particular BUTTON(RED COLOUR) in a DIALOG-BASED form (ex: if some ERROR occcurs)? Jason Teagle May 11th, 1999, 03:53 AM 1) Have two BOOL members to indicate whether it should blink or not, and its current state; say m_bBlinkButton and m_bButtonIsLit. 2) Have a CBrush member for the new button's back colour (red, for example). In your parent window's override of OnCreate() (from WM_CREATE message), call CBrush::CreateSolidBrush(). In the window's DestroyWindow() override, call CBrush::DeleteObject(). 3) Set a timer going for the window, and in its OnTimer() method toggle the state of m_bIsButtonLit if m_bBlinkButton is set (it would be set or cleared when the error condition was detected as active or inactive). 4) Override the window's OnCtlColor() and check for CTLCOLOR_BTN, then call GetDlgCtrlID() on the supplied CWnd pointer to get the ID to make sure it is the required button, then either call the base class if the button is normal, or return the CBrush member's GetSafeHandle() result if it is lit. Note that you should NOT let the base class be called if you want the button lit - it will override your brush setting. The OnCtlColor() method gets called once for each control, so for any other control you MUST let the base class be called. You should also call SetBkMode(TRANSPARENT) (or SetBkColor() ) on the supplied DC if this is the right button, so that the caption will not get the default colour behind the text. If this has made it confusing, e-mail me at jteagle@solartron.com and I'll provide a demo. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |