Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
// ------------------------------------------------------------------- // Name: AppendText() // Desc: Appends text to the textbox. // ------------------------------------------------------------------- void Forms::TextBox::AppendText(LPCWSTR lpText) { const unsigned int size(wcslen(lpText) + wcslen(m_lpText) + 1); LPWSTR buffer = new wchar_t[size]; int strsize = swprintf(buffer, size, L"%s%s", m_lpText, lpText); SetWindowText(m_hwndTextBox, buffer); // return value ist 0 (bei dieser funktion ein fehler) int ret = GetWindowText(m_hwndTextBox, m_lpText, 2048); delete buffer; } // AppendText() |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
// ------------------------------------------------------------------- // Name: AppendText() // Desc: Appends text to the textbox. // ------------------------------------------------------------------- void Forms::TextBox::AppendText(LPCWSTR lpText) { const unsigned int size(wcslen(lpText) + wcslen(m_lpText) + 1); LPWSTR buffer = new wchar_t[size]; int strsize = swprintf(buffer, size, L"%s%s", m_lpText, lpText); SetWindowText(m_hwndTextBox, buffer); // alles ok.. funktion kopiert die chars in die var LPWSTR test= new wchar_t[size]; int ret = GetWindowText(m_hwndTextBox, test, 2048); delete buffer; } // AppendText() |
C-/C++-Quelltext |
|
1 |
m_lpText[0] = 'x'; |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
// irgendwo .. txtbox->Text(L"hallooo"); txtbox->AppendText(L"1"); // ------------------------------------------------------------------- // Name: Text() // Desc: Sets the text inside of the textbox. // ------------------------------------------------------------------- void Forms::TextBox::Text(LPCWSTR lpText) { SetWindowText(m_hwndTextBox, lpText); m_lpText = const_cast<LPWSTR>(lpText); } // Text() // ------------------------------------------------------------------- // Name: AppendText() // Desc: Appends text to the textbox. // ------------------------------------------------------------------- void Forms::TextBox::AppendText(LPCWSTR lpText) { const unsigned int size(wcslen(lpText) + wcslen(m_lpText) + 1); LPWSTR buffer = new wchar_t[size]; int strsize = swprintf(buffer, size, L"%s%s", m_lpText, lpText); SetWindowText(m_hwndTextBox, buffer); int ret = GetWindowText(m_hwndTextBox, m_lpText, 2048); delete buffer; } // AppendText() |
Zitat von »"$nooc"«
C-/C++-Quelltext
1 2 3 4 5 6 7 8 9 10 11 12 13 // irgendwo .. txtbox->Text(L"hallooo"); txtbox->AppendText(L"1"); // ------------------------------------------------------------------- // Name: Text() // Desc: Sets the text inside of the textbox. // ------------------------------------------------------------------- void Forms::TextBox::Text(LPCWSTR lpText) { SetWindowText(m_hwndTextBox, lpText); m_lpText = const_cast<LPWSTR>(lpText); } // Text()
die Text() wird noch ganz normal ausgeführt...
erst in AppendText() is ZV
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
// ------------------------------------------------------------------- // Name: SetText() // Desc: Sets the text inside of the textbox. // ------------------------------------------------------------------- void Forms::TextBox::SetText(std::wstring const& text) { ::SetWindowTextW(m_hWndTextBox, text.c_str()); } // ------------------------------------------------------------------- // Name: GetText() // Desc: Gets the text inside of the textbox. // ------------------------------------------------------------------- void Forms::TextBox::GetText(std::wstring& text) { const std::size_t size(::GetWindowTextLength(m_hWndTextBox) + 1); wchar_t* ptr_text(new wchar_t[size]()); ::GetWindowTextW(m_hWndTextBox, ptr_text, size); text = ptr_text; delete [] ptr_text; } // ------------------------------------------------------------------- // Name: AppendText() // Desc: Appends text to textbox content. // ------------------------------------------------------------------- void Forms::TextBox::AppendText(std::wstring const& text) { std::wstring text_current; GetText(text_current); const std::size_t size(text.length() + text_current.length() + 1); SetWindowText(m_hWndTextBox, (text + text_current).c_str()); } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 |
foo::~foo() { if (m_pointer != NULL) { delete m_pointer; m_pointer = NULL; } } |
C-/C++-Quelltext |
|
1 2 3 4 |
foo::~foo() { delete m_pointer; } |
C-/C++-Quelltext |
|
1 2 3 |
std::wstring text = L"text"; LPWSTR str = new WCHAR[text.size()]; wcscpy(str, text.c_str(),...); |
Werbeanzeige