From 3de8318e98ebc2be40154da33e326536723d980e Mon Sep 17 00:00:00 2001 From: Takamichi Horikawa Date: Fri, 17 Mar 2017 23:16:29 +0900 Subject: win32: fixed CRLF when copying to clipboard --- version.h | 2 +- win32/toneview.c | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/version.h b/version.h index 8337db6..04e5012 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #ifndef MYON_FMPLAYER_VERSION_H_INCLUDED #define MYON_FMPLAYER_VERSION_H_INCLUDED -#define FMPLAYER_VERSION_STR "0.1.0" +#define FMPLAYER_VERSION_STR "0.1.1" #endif // MYON_FMPLAYER_VERSION_H_INCLUDED diff --git a/win32/toneview.c b/win32/toneview.c index a0a920a..90ad24a 100644 --- a/win32/toneview.c +++ b/win32/toneview.c @@ -68,10 +68,19 @@ enum { static void on_command(HWND hwnd, int id, HWND hwnd_c, UINT code) { if (code == BN_CLICKED && ((ID_COPY0 <= id) && (id <= ID_COPY5))) { int i = id - ID_COPY0; - HGLOBAL gmem = GlobalAlloc(GMEM_MOVEABLE, FMPLAYER_TONEDATA_STR_SIZE*sizeof(wchar_t)); - if (!gmem) return; - wchar_t *buf = GlobalLock(gmem); + wchar_t buf[FMPLAYER_TONEDATA_STR_SIZE]; GetWindowText(g.tonelabel[i], buf, FMPLAYER_TONEDATA_STR_SIZE*sizeof(wchar_t)); + HGLOBAL gmem = GlobalAlloc(GMEM_MOVEABLE, (FMPLAYER_TONEDATA_STR_SIZE+10)*sizeof(wchar_t)); + if (!gmem) return; + wchar_t *gbuf = GlobalLock(gmem); + wchar_t *c = buf; + while (*c) { + if (*c == L'\n') { + *gbuf++ = L'\r'; + } + *gbuf++ = *c++; + } + *gbuf = 0; GlobalUnlock(gmem); if (!OpenClipboard(hwnd)) return; EmptyClipboard(); -- cgit v1.2.3