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 --- win32/toneview.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'win32/toneview.c') 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