Changeset 78142 in vbox
- Timestamp:
- Apr 16, 2019 10:36:08 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp
r76553 r78142 47 47 #endif 48 48 49 /** Sets announced clipboard formats from the host. */ 50 #define VBOX_WM_SHCLPB_SET_FORMATS WM_USER 51 /** Reads data from the clipboard and sends it to the host. */ 52 #define VBOX_WM_SHCLPB_READ_DATA WM_USER + 1 53 49 54 typedef struct _VBOXCLIPBOARDCONTEXT 50 55 { … … 105 110 106 111 107 static int vboxOpenClipboard(HWND h wnd)112 static int vboxOpenClipboard(HWND hWnd) 108 113 { 109 114 /* "OpenClipboard fails if another window has the clipboard open." … … 112 117 BOOL fOpened = FALSE; 113 118 119 LogFlowFunc(("hWnd=%p\n", hWnd)); 120 114 121 int i = 0; 115 122 for (;;) 116 123 { 117 if (OpenClipboard(h wnd))124 if (OpenClipboard(hWnd)) 118 125 { 119 126 fOpened = TRUE; … … 130 137 #ifdef LOG_ENABLED 131 138 if (i > 0) 132 LogFlowFunc(("%d times tried to open clipboard .\n", i + 1));139 LogFlowFunc(("%d times tried to open clipboard\n", i + 1)); 133 140 #endif 134 141 … … 138 145 else 139 146 { 140 const DWORD err = GetLastError();141 LogFlowFunc(("error %d\n", err));142 rc = RTErrConvertFromWin32(err);147 const DWORD dwLastErr = GetLastError(); 148 rc = RTErrConvertFromWin32(dwLastErr); 149 LogRel(("Clipboard: Failed to open clipboard! Error=%ld (%Rrc)\n", dwLastErr, rc)); 143 150 } 144 151 … … 195 202 CloseClipboard(); 196 203 rc = VbglR3ClipboardReportFormats(pCtx->u32ClientID, u32Formats); 197 }198 else199 {200 LogFlow(("vboxClipboardChanged: error in open clipboard. hwnd: %x. err: %Rrc\n", pCtx->hwnd, rc));201 204 } 202 205 return rc; … … 530 533 CloseClipboard(); 531 534 } 532 else533 {534 LogFlowFunc(("WM_RENDERALLFORMATS: Failed to open clipboard! rc: %Rrc\n", vboxrc));535 }536 535 } break; 537 536 538 case WM_USER:537 case VBOX_WM_SHCLPB_SET_FORMATS: 539 538 { 540 539 /* Announce available formats. Do not insert data, they will be inserted in WM_RENDER*. */ 541 540 uint32_t u32Formats = (uint32_t)lParam; 542 541 542 LogFlowFunc(("VBOX_WM_SHCLPB_SET_FORMATS: u32Formats=0x%x\n", u32Formats)); 543 543 544 int vboxrc = vboxOpenClipboard(hwnd); 544 545 if (RT_SUCCESS(vboxrc)) … … 549 550 550 551 if (u32Formats & VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT) 551 {552 LogFlowFunc(("WM_USER: VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT\n"));553 552 hClip = SetClipboardData(CF_UNICODETEXT, NULL); 553 554 if (u32Formats & VBOX_SHARED_CLIPBOARD_FMT_BITMAP) 555 hClip = SetClipboardData(CF_DIB, NULL); 556 557 if (u32Formats & VBOX_SHARED_CLIPBOARD_FMT_HTML) 558 { 559 UINT format = RegisterClipboardFormat ("HTML Format"); 560 if (format != 0) 561 hClip = SetClipboardData(format, NULL); 554 562 } 555 563 556 if (u32Formats & VBOX_SHARED_CLIPBOARD_FMT_BITMAP)557 {558 LogFlowFunc(("WM_USER: VBOX_SHARED_CLIPBOARD_FMT_BITMAP\n"));559 hClip = SetClipboardData(CF_DIB, NULL);560 }561 562 if (u32Formats & VBOX_SHARED_CLIPBOARD_FMT_HTML)563 {564 UINT format = RegisterClipboardFormat ("HTML Format");565 LogFlowFunc(("WM_USER: VBOX_SHARED_CLIPBOARD_FMT_HTML 0x%04X\n", format));566 if (format != 0)567 {568 hClip = SetClipboardData(format, NULL);569 }570 }571 572 564 CloseClipboard(); 573 LogFlowFunc(("WM_USER: hClip = %p, err = %ld\n", hClip, GetLastError ())); 574 } 575 else 576 { 577 LogFlowFunc(("WM_USER: Failed to open clipboard! error = %Rrc\n", vboxrc)); 565 566 LogFlowFunc(("VBOX_WM_SHCLPB_SET_FORMATS: hClip=%p, lastErr=%ld\n", hClip, GetLastError())); 578 567 } 579 568 } break; 580 569 581 case WM_USER + 1:570 case VBOX_WM_SHCLPB_READ_DATA: 582 571 { 583 572 /* Send data in the specified format to the host. */ 584 573 uint32_t u32Formats = (uint32_t)lParam; 585 574 HANDLE hClip = NULL; 575 576 LogFlowFunc(("VBOX_WM_SHCLPB_READ_DATA: u32Formats=0x%x\n", u32Formats)); 586 577 587 578 int vboxrc = vboxOpenClipboard(hwnd); … … 597 588 if (lp != NULL) 598 589 { 599 LogFlowFunc(("WM_USER + 1: CF_DIB\n"));600 590 vboxrc = VbglR3ClipboardWriteData(pCtx->u32ClientID, VBOX_SHARED_CLIPBOARD_FMT_BITMAP, 601 591 lp, GlobalSize(hClip)); … … 618 608 if (uniString != NULL) 619 609 { 620 LogFlowFunc(("WM_USER + 1: CF_UNICODETEXT\n"));621 610 vboxrc = VbglR3ClipboardWriteData(pCtx->u32ClientID, VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT, 622 611 uniString, (lstrlenW(uniString) + 1) * 2); … … 641 630 if (lp != NULL) 642 631 { 643 LogFlowFunc(("WM_USER + 1: CF_HTML\n"));644 632 vboxrc = VbglR3ClipboardWriteData(pCtx->u32ClientID, VBOX_SHARED_CLIPBOARD_FMT_HTML, 645 633 lp, GlobalSize(hClip)); … … 656 644 CloseClipboard(); 657 645 } 658 else659 {660 LogFlowFunc(("WM_USER: Failed to open clipboard! rc: %Rrc\n", vboxrc));661 }662 646 663 647 if (hClip == NULL) … … 857 841 switch (u32Msg) 858 842 { 859 /** @todo r=andy: Use a \#define for WM_USER (+1). */860 843 case VBOX_SHARED_CLIPBOARD_HOST_MSG_FORMATS: 861 844 { … … 863 846 * Forward the information to the window, so it can later 864 847 * respond to WM_RENDERFORMAT message. */ 865 ::PostMessage(pCtx->hwnd, WM_USER, 0, u32Formats);848 ::PostMessage(pCtx->hwnd, VBOX_WM_SHCLPB_SET_FORMATS, 0, u32Formats); 866 849 } break; 867 850 … … 869 852 { 870 853 /* The host needs data in the specified format. */ 871 ::PostMessage(pCtx->hwnd, WM_USER + 1, 0, u32Formats);854 ::PostMessage(pCtx->hwnd, VBOX_WM_SHCLPB_READ_DATA, 0, u32Formats); 872 855 } break; 873 856
Note:
See TracChangeset
for help on using the changeset viewer.