summaryrefslogtreecommitdiff
path: root/protocols/Discord/src/menus.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-12-06 15:35:29 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-12-06 15:35:29 +0300
commitfa3d7e46f262cdbfea89b2b9ddab75768024be10 (patch)
tree06a6fadca2f732bb15ae2eeab1bc69d834fb7aba /protocols/Discord/src/menus.cpp
parent0380841eece1c03a7a47da463c0f94d7945227d9 (diff)
minor code cleaning + warning fix
Diffstat (limited to 'protocols/Discord/src/menus.cpp')
-rw-r--r--protocols/Discord/src/menus.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/protocols/Discord/src/menus.cpp b/protocols/Discord/src/menus.cpp
index 3cc43fc6ab..59dcc683a5 100644
--- a/protocols/Discord/src/menus.cpp
+++ b/protocols/Discord/src/menus.cpp
@@ -19,16 +19,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
INT_PTR CDiscordProto::OnMenuCopyId(WPARAM hContact, LPARAM)
{
- CMStringW mynick(ptrW(getWStringA(hContact, DB_KEY_NICK)));
- mynick.AppendFormat(L"#%d", getDword(hContact, DB_KEY_DISCR));
-
if (OpenClipboard(nullptr)) {
EmptyClipboard();
+
+ CMStringW mynick(FORMAT, L"%s#%d", getMStringW(hContact, DB_KEY_NICK).c_str(), getDword(hContact, DB_KEY_DISCR));
int length = mynick.GetLength() + 1;
- HGLOBAL hMemory = GlobalAlloc(GMEM_FIXED, length * sizeof(wchar_t));
- mir_wstrncpy((wchar_t*)GlobalLock(hMemory), mynick, length);
- GlobalUnlock(hMemory);
- SetClipboardData(CF_UNICODETEXT, hMemory);
+ if (HGLOBAL hMemory = GlobalAlloc(GMEM_FIXED, length * sizeof(wchar_t))) {
+ mir_wstrncpy((wchar_t *)GlobalLock(hMemory), mynick, length);
+ GlobalUnlock(hMemory);
+ SetClipboardData(CF_UNICODETEXT, hMemory);
+ }
CloseClipboard();
}