CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12

Threaded View

  1. #1
    Join Date
    Dec 2021
    Posts
    10

    CStatic - disable double click copy to clipboard.

    Hi all,

    by default double-clicking on the label (CStatic) control, you copy the text of the label to the clipboard. To disable this functionality I followed this site. The problem is, that I want to preserve the previous value of the clipboard. Based on MSDN documentation the WM_GETTEXT should return the text length without null character. I do so, but my code still not working, which means that the clipboard is empty.

    Code:
            LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam) override
            {
                if (message == WM_LBUTTONDBLCLK)
                {
                    double_click_flag_ = true;
                }
                if (message == WM_GETTEXT && double_click_flag_ && !double_click_copy_)
                {
                    double_click_flag_ = false;
    
                    HANDLE clip = nullptr;
                    if (OpenClipboard()) {
                        clip = GetClipboardData(CF_TEXT);
                        CloseClipboard();
                    }
                    string text;
                    text = (char*)clip;
                    std::wstring wsTmp(text.begin(), text.end());
                    return wsTmp.length();
                }
                return CStatic::WindowProc(message, wParam, lParam);
            }
    Any idea?

    Thx
    Last edited by Tony.star21; March 25th, 2022 at 10:25 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured