ID Number: Q74510
3.00
WINDOWS
buglist3.00 fixlist3.10
Summary:
PROBLEM ID: WIN9107005
SYMPTOMS
Under version 3.0 of the Microsoft Windows graphical environment,
when an application calls the SetDlgItemText function to change the
text of a group box, any text not overwritten by the new text
continues to be displayed.
CAUSE
A group box is implemented as a type of transparent window with a
border and title text. A group box cannot erase its background
because doing so would erase any controls inside the box. Versions
of Windows earlier than 3.1 do not erase the portion of the group
box under the title text.
RESOLUTION
Microsoft has confirmed this to be a problem in Windows version
3.0. Two methods to work around this problem are as follows:
- Be sure that the string passed to SetDlgItemText is as long as
or longer than the text displayed in the control. If necessary,
add blanks to the end of the string.
-or-
- Cause the application to repaint the group box text. The
following code fragment implements this method:
char temp_string[MAXLEN];
RECT rect;
HWND hDlg, hGroupBox;
SetDlgItemText(hDlg, ID_GROUPBOX, temp_string);
hGroupBox = GetDlgItem(hDlg, ID_GROUPBOX);
GetWindowRect(hGroupBox, &rect);
ScreenToClient(hDlg, (LPPOINT)&rect.left);
ScreenToClient(hDlg, (LPPOINT)&rect.right);
InvalidateRect(hDlg, &rect, TRUE); // erase background
UpdateWindow(hDlg); // repaint
This problem was corrected in Windows version 3.1. The methods
provided above to avoid the problem are compatible with Windows
3.1.
Additional reference words: 3.00