In Visual C++ is there a way to update a singal control without updating them all? If so how?
(for example, I want to have a clock in my program that doesn't interfer with my trying to type other things).

11 Years
Discussion Span
Last Post by Ancient Dragon

I believe you are asking for a way of updating a Caption of a Static Text Label Control ( IDC_STATIC ) which displays the Clock output without using the UpdateData method. You can do this by the use of Control Variables. It is possible to declare a control variable for any control that has a resource ID not equal to IDC_STATIC.
Therefore in the assumed case of a Static label follow the steps below.

1. Rename the Resouce ID of the Label to something other than IDC_STATIC ( say IDC_TIMEDISPLAY )

2. Right click the IDC_TIMEDISPLAY Control and select Add Variable.

3. Add a variable of anyname you prefer ( say m_TimeDisplay ) and of Category equal to Control.

4. At the event you want to update the Labels text, Just call
m_TimeDisplay.SetWindowText( m_DisplayString );

where m_DisplayString is the CString variable you want to be displayed in the caption.


If you want the clock in the display to tick off the time while you are typing in another control (such as an edit control), then use SetTime() to set an event to happen once a second. Then in that timer event update the clock display with current time. See MSDN for SetTimer() function.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.