TEXT_Handle hTxt = WM_GetDialogItem(hWinMain, TEXT_TITLE);
char s[64];
GUI_RECT rect;
printf("\n\n\n");
TEXT_GetText(hTxt, s, sizeof(s));
printf("TEXT_GetText(%ld)=%s\n", hTxt, s);
if (WM_GetInvalidRect(hTxt, &rect) == 0) {
printf("WM_GetInvalidRect(%ld)=0\n", hTxt);
} else {
printf("WM_GetInvalidRect(%ld)=1\n", hTxt);
}
TEXT_printf(hTxt, "Registro %d..%d/%d", first_entry + 1, first_entry + num_entries, log_size);
TEXT_GetText(hTxt, s, sizeof(s));
printf("TEXT_GetText(%ld)=%s\n", hTxt, s);
if (WM_GetInvalidRect(hTxt, &rect) == 0) {
printf("WM_GetInvalidRect(%ld)=0\n", hTxt);
} else {
printf("WM_GetInvalidRect(%ld)=1\n", hTxt);
}
printf("\n\n\n");
Display More
Output is
TEXT_GetText(92)=Registro eventi
WM_GetInvalidRect(92)=0
TEXT_GetText(92)=Registro 1..2/9
WM_GetInvalidRect(92)=0
How is possible that TEXT widget area is not invalidated after setting a new text? Indeed I don't see any visible changes.
If I call WM_InvalidateWindow() on the widget, the behaviour is correct and I see the new text in the TEXT widget.
It's an oddy behaviour, because it may depend on the first text set during TEXT_CreateEx(). I create the TEXT widget with the following code:
TEXT_Handle hTxt;
hTxt = TEXT_CreateEx(TOPBAR_LEFT_WIDTH, 0, xSize - 2 * TOPBAR_LEFT_WIDTH, TOPBAR_HEIGHT, hWin, WM_CF_SHOW, TEXT_CF_HCENTER | TEXT_CF_VCENTER, TEXT_TITLE, "Registro eventi");
TEXT_SetBkColor(hTxt, GUI_RED);
TEXT_SetTextColor(hTxt, GUI_WHITE);
TEXT_SetFont(hTxt, TOPBAR_FONT);
If I change the text in TEXT_CreateEx() it is possible that afterwards TEXT_SetText() will invalidate the widget and the new text is drawn.
It seems to me it depends of the length of the old and new string: if they are the same, TEXT_SetText() sometimes decides to not invalidate the text area.