CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2006
    Posts
    230

    c++ how can i in win32 static text control enable to copy text ?

    im writing simple win32 application that is window and static text , now i want to enable the user to copy the text with his right click (mark and copy ) how can i do that ?
    Code:
    LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
    IDD_DIALOG1 DIALOG 0, 0, 369, 318
    STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU
    CAPTION "Win32 demo"
    FONT 8, "Ms Shell Dlg"
    {
         LTEXT           "Questions to [email protected]", IDC_STATIC, 96, 87, 150, 8, SS_LEFT
    }

  2. #2
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: c++ how can i in win32 static text control enable to copy text ?

    If using a (read-only) Edit control is a very easy task: just have to select the Edit control contents then send a WM_COPY message:
    Code:
       HWND hWndEdit = ::GetDlgItem(hWndDlg, IDC_EDIT1);
       ::SendMessage(hWndEdit, EM_SETSEL, (WPARAM)0, (LPARAM)-1);
       ::SendMessage(hWndEdit, WM_COPY, 0, 0);
    Unfortunatelly, that is not possibile in case of Static control and have to deal yourself with clipboard functions.
    See Clipboard topics in MSDN.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  3. #3
    Join Date
    Aug 2006
    Posts
    230

    Re: c++ how can i in win32 static text control enable to copy text ?

    Thanks for the reply , im using ResEdit , so its selectble already .
    but when i select the text all the edit text background become painted in white how can i cancel that ?
    one more question , if i use Edit Text control , can i make some text inside it be clicked as a link?

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: c++ how can i in win32 static text control enable to copy text ?

    What is "ResEdit "?
    Did you consider using something like CHtmlCtrl?
    Victor Nijegorodov

  5. #5
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: c++ how can i in win32 static text control enable to copy text ?

    Quote Originally Posted by umen View Post
    if i use Edit Text control , can i make some text inside it be clicked as a link?
    Of course you can. Also you can get rid of default behavior of selecting text.

    Attached here is a little Win32 Application which has an Edit control behaving as a hyperlink and having copy to clipboard feature.
    Attached Files Attached Files
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  6. #6
    Join Date
    Aug 2006
    Posts
    230

    Re: c++ how can i in win32 static text control enable to copy text ?

    Thanks for the example and help

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