Visual C++ Edit Box, dopisywanie danych

0

Witam, otóż stworzyłem mini aplikację w Visual C++ 6.0 Standard Edition, w której klikniecie przycisku dodaj powoduje, iż zmienna a rośnie o 1, zaś wynik tego wyświetlany jest w Edit Boxie po lewej.

user image

Wszystko byłoby ok, tylko zależy mi, żeby kolejne kliknięcia nie zastępowały starej wiadomości, tylko po prostu dopisywały nową, aby wyglądało to tak:

Liczba kliknięć = 1
Liczba kliknięć = 2
Liczba kliknięć = 3

Używam komendy SetWindowText, ale właśnie to powoduje zastępowanie, czy jest jakiś sposób aby funkcja dopisywała, a nie zastępowała ?

Oto kod funkcji przyklejonej do przycisku:

void CEditBoxDlg::OnButton1() 
{
a=a+1;
CString b;
b.Format("Liczba kliknięć = %d\n", a);
GetDlgItem(IDC_EDIT)->SetWindowText(b);
UpdateData(FALSE);
}
0

to bracie prosto-PRZED SetWindowText wpierw użyj

MSDN napisał(a)

int GetWindowText(HWND hWnd,LPTSTR lpString,int nMaxCount);
hWnd
[in] Handle to the window or control containing the text.
lpString
[out] Pointer to the buffer that will receive the text. If the string is as long or longer than the buffer, the string is truncated and terminated with a NULL character.
nMaxCount
[in] Specifies the maximum number of characters to copy to the buffer, including the NULL character. If the text exceeds this limit, it is truncated.
Return Value

If the function succeeds, the return value is the length, in characters, of the copied string, not including the terminating NULL character. If the window has no title bar or text, if the title bar is empty, or if the window or control handle is invalid, the return value is zero.

//q: wez "bracie" nastepnym razem podaj linka na MSDN po prostu

jak masz już stary tekst skopiowany,to na końcu łańcucha w buforze dopisujesz nowe dane i to dajesz SetWindowTextowi do wyświetlenia.A i może przydatna być przy tym GetWindowTextLength()

0

Dzięki za pomoc :)

1 użytkowników online, w tym zalogowanych: 0, gości: 1