![]() |
AW: IntToStr zu WCHAR
Zitat:
Code:
WCHAR * StreamLenght = std::to_wstring(Second / 60) + L"Min " + std::to_wstring(Second %= 60) + L"Sec";
Zitat:
Zitat:
gruss |
AW: IntToStr zu WCHAR
Probier mal:
Delphi-Quellcode:
Der Assignment Operator ist scheinbar nicht überladen.
std::wstring streamLength = std::to_wstring(Second / 60) + L"Min " + std::to_wstring(Second %= 60) + L"Sec";
const WCHAR* ptr = streamLength.c_str(); |
AW: IntToStr zu WCHAR
Zitat:
Das Problem dabei ist das dann die Berechnung von (Second / 60) fehlschlägt. Seltsamer weise stimmen aber die Sekunden (Second %= 60). (Second mod 60). Zudem kommt noch das ich einen "const WCHAR*" nicht an SetWindowText übergeben kann. So! stimmen die
Code:
gruss
std::wstring Min_tmp = std::to_wstring(Second / 60);
WCHAR * Min = &Min_tmp[0]; |
AW: IntToStr zu WCHAR
Also
Delphi-Quellcode:
ist zumindest auch falsch, es muss nur
%=
Delphi-Quellcode:
sein.
%
Delphi-Quellcode:
und Konsorten sind Kurzformen von
var += value
Delphi-Quellcode:
.
var = var + value
So funktioniert es bei mir ohne Probleme:
Delphi-Quellcode:
uint32_t seconds = 350;
std::wstring title = std::to_wstring(seconds / 60) + L"Min " + std::to_wstring(seconds % 60) + L"Sec"; AllocConsole; SetWindowTextW(GetConsoleWindow(), title .c_str()); |
AW: IntToStr zu WCHAR
Zitat:
So funktioniert es 100%. Kann also die 100 Zeilen wieder löschen. Wenn du möchtest kannst mir dabei auch noch helfen. ? :duck:
Delphi-Quellcode:
Danach wären die String Probleme beseitigt.
//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); gruss |
AW: IntToStr zu WCHAR
Float Conversions mit bestimmter Präzision und Formatierung sind etwas umständlich bei C++. Es gibt mehrere Möglichkeiten:
![]() Also entweder über
Delphi-Quellcode:
und
std::stringstream
Delphi-Quellcode:
und
set::setw()
Delphi-Quellcode:
. Oder über die C-Style Format Funktionen wie
set::setprecision()
Delphi-Quellcode:
.
std::snprintf
Da müsstest du schauen, was dir lieber ist. |
AW: IntToStr zu WCHAR
Zitat:
Werde mich mal umsehen. gruss |
AW: IntToStr zu WCHAR
So geht's aber auch wieder so viele Zeilen ;)
Inklusive kleinen Helfern.
Code:
#define long_proc_c typedef long (__cdecl *Proc)
Code:
HMODULE MSVCRT() {
static HMODULE hModule; if (hModule == 0) { hModule = LoadLibrary(L"MSVCRT"); } return hModule; }
Code:
long Add_Str(OUT WCHAR* dest, IN WCHAR* srce) {
long nRet = -1; // Error HMODULE hModule = MSVCRT(); if (hModule) { long_proc_c(WCHAR*, WCHAR*, size_t); Proc hProc = (Proc)GetProcAddress(hModule, "wcsncat"); if (hProc) { nRet = hProc(dest, srce, _TRUNCATE); } } return nRet; }
Code:
grussAdd_Str(VideoInfo, STRL(aMediaProperty.Video_Width)); Add_Str(VideoInfo, L" x "); Add_Str(VideoInfo, STRL(aMediaProperty.Video_Height)); Add_Str(VideoInfo, L", "); Add_Str(VideoInfo, STRD(aMediaProperty.Video_FPS)); Add_Str(VideoInfo, L" FPS"); SetWindowText(hLblVideoInfo, VideoInfo); |
AW: IntToStr zu WCHAR
Zu Deiner Lösung sag ich jetzt nix.........
Code:
#include <stdio.h>
wchar_t Buffer[100]; int err = _snwprintf_s(Buffer, 100, 99, L"%.3f x %.3f y , %6.2f FPS", aMediaProperty.Video_Width, aMediaProperty.Video_Height, aMediaProperty.Video_FPS); if (err <0){ // Buffer to small fix it } else SetWindowText(hLblVideoInfo, Buffer); |
AW: IntToStr zu WCHAR
Zitat:
Gut dann ich.. selbst erarbeitet. (Stolz) Warum soll ich die MSVC.. hehehhe (VCL) verwenden wenn es nicht nötig ist? Warum künstlich den Code um 250 KB und hoch vergrößern wenn es auch statisch zu lösen ist. Ok ist nicht schön aber NONVCL oops meine natürlich NONMSVC. Aber Danke für deinen Lösungsansatz. Würde gerne wissen wie sich deine Lösung zusammen setzt. Also die Formatierung. :) Auch in C++ kann man eine EXE von 3 MB und mehr erstellen es geht aber auch in 64 KB das ist kein Witz, Zitat:
Code:
}
WCHAR* STRD(IN double N) {
static WCHAR ws[128] = { 0 }; swprintf(ws, strSize(ws), L"%f", N); return (WCHAR*)ws; oder
Code:
ok glaube habe es verstanden.. Danke
WCHAR VideoInfo[MAX_PATH] = { 0 };
_snwprintf_s(VideoInfo, MAX_PATH, 259, L"%d x %d, %6.3f FPS", aMediaProperty.Video_Width, aMediaProperty.Video_Height, aMediaProperty.Video_FPS); SetWindowText(hLblVideoInfo, VideoInfo);
Code:
gruss
WCHAR AudioProperty[MAX_PATH] = { 0 };
_snwprintf_s(AudioProperty, MAX_PATH, 259, L"%d Channel, %d SPS, %d BPS", aMediaProperty.Audio_Channels, aMediaProperty.Audio_Samplerate, aMediaProperty.Audio_BitsPerSample); SetWindowText(hLblAudioProperty, AudioProperty); |
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:27 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