![]() |
IntToStr zu WCHAR
Kann mir jemand helfen weis nicht wie ich das in C++ rüber bringen soll.
Delphi-Quellcode:
intToStr(Second div 60) + 'Min ' + intToStr(Second mod 60) + 'Sec';
Der Wert soll an WCHAR (Unicode) übergeben werden. Danach will ich den Text mit SetWindowText an meinen Label schicken. Das ist soweit klar
Code:
(Second / 60) + L"Min " + (Second %= 60) + L"Sec";
gruss |
AW: IntToStr zu WCHAR
Hallo Emil
tue Dir selbst einen gefallen und beschäftige Dich etwas mit std::wstring und Co Wenn es um Stringhandling geht ist C++ etwas ganz anderes als Delphi. Es lohnt sich die Std Lib zumindest etwas zu kennen. Gruss |
AW: IntToStr zu WCHAR
sorry doppelt kann gelöscht werden.
gruss |
AW: IntToStr zu WCHAR
Zitat:
Das ist ein Projekt in C++ das ich nur einmal erstelle dann wende ich mich wieder Delphi zu. C++ ist komplett anders als Delphi :) Warum muss ich jetzt das Komplette MSVC in 3 stunden erlernen wegen 1 Funktion (Frage) wenn mir dabei jemand helfen könnte. gruss |
AW: IntToStr zu WCHAR
Sofern du keinen älteren Standard als C++11 unterstützen willst, kannst du dafür
Delphi-Quellcode:
verwenden. Die
std::string s = std::to_string(42);
Delphi-Quellcode:
Klasse kann auch appenden und sollte den + Operator überladen haben, sodass du die Stringkonkatenation genau wie in Delphi hierrüber handhaben kannst.
std::string
|
AW: IntToStr zu WCHAR
Zitat:
Der Ausgangsstring ist WCHAR nicht string. :) gibt es das?
Code:
gruss
std::to_string(42).wchar_t;
|
AW: IntToStr zu WCHAR
Ja analog zu
Delphi-Quellcode:
gibt es auch
std::string
Delphi-Quellcode:
:P
std::wstring
Edit: Und
Delphi-Quellcode:
std::to_wstring
|
AW: IntToStr zu WCHAR
Zitat:
Code:
WCHAR StreamLenght = std::to_wstring(Second / 60) + L"Min " + std::to_wstring(Second %= 60) + L"Sec";
Zitat:
Zitat:
|
AW: IntToStr zu WCHAR
So macht man aus einer Zeile 11
Delphi-Quellcode:
Was für ein Schmarrn. Eine andere Lösung fällt mir nicht ein.
INT64 Second = (aMediaProperty.PlaybackLength / 10000) / 1000;
WCHAR Minutes[MAX_PATH]; WCHAR Seconds[MAX_PATH]; WCHAR StreamLenght[MAX_PATH]; // Minuten std::wstring Min_tmp = std::to_wstring(Second / 60); WCHAR * Min = &Min_tmp[0]; Str_Combine(Minutes, Min, L" Min "); // Sekunden std::wstring Sec_tmp = std::to_wstring(Second %= 60); WCHAR * Sec = &Sec_tmp[0]; Str_Combine(Seconds, Sec, L" Sec"); // Kombinieren Str_Combine(StreamLenght, Minutes, Seconds); // Ausgabe SetWindowText(hLblStreamLenght, StreamLenght); Wenn ich das jetzt hiermit auch noch machen muss dann habe ich 50 Zeilen anstelle von 3
Delphi-Quellcode:
gruss
//lbl_VideoInfo.Caption : = FormatFloat('#,##0', aMediaProperty.Video_Width) + ' x ' +
// FormatFloat('#,##0', aMediaProperty.Video_Height) + ', ' + // FormatFloat('##0.00', aMediaProperty.Video_FPS) + ' FPS'; //SetWindowText(hlblVideoInfo, VideoInfo); //lbl_AudioProperty.Caption : = intToStr(aMediaProperty.Audio_Channels) + ' Channel, ' + // FormatFloat('#,##0', aMediaProperty.Audio_Samplerate) + ' SPS, ' + // intToStr(aMediaProperty.Audio_BitsPerSample) + ' BPS'; //SetWindowText(hlblAudioProperty, AudioProperty); |
AW: IntToStr zu WCHAR
Dein Fehler kommt daher, dass du deine Variable als
Delphi-Quellcode:
(einzelnes Zeichen = WideChar) deklarierst und nicht als
WCHAR
Delphi-Quellcode:
(PWideChar).
WCHAR*
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 18:40 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz