in Search
     
Latest post 03-28-2007 10:08 PM by modchip. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 03-27-2007 1:43 AM

    • modchip
    • Top 10 Contributor
    • Joined on 02-09-2006
    • Ivalice
    • Posts 710
    • Points 10,110

    It Does Not Select! Cannot Copy to Clipbboard!

    Hi, I've been having problems with how to copy text items to the clipboard, so I turned to MSDN to find a solution... I found this piece of info about the EM_SETSEL.
    MSDN - If the start is 0 and the end is –1, all the text in the edit control is selected. If the start is –1, any current selection is deselected.
    ;SNIP-----------------------------------------------------------------------------------
    invoke
    SendMessage, IDC_EDIT_OUTPUT, EM_SETSEL, 0, -1     ; select yung laman textbox
    invoke SendDlgMessage, IDC_EDIT_OUTPUT, WM_COPY, 0, 0     ; copyahin yung selection
    invoke SendMessage, IDC_EDIT_OUTPUT, EM_SETSEL, -1, 0     ; alisin selection
    ;SNIP-----------------------------------------------------------------------------------

    All the controls are valid, as far as I know. I also search for sources about this, but some of them are so complicated.. with things like globalalloc stuff that I still doesn't want to delve into.

    Please, can anybody give a little hint? Geeked

    Thanks in advance for your time.

    Regards,
    m0ds


    Filed under:
    • Post Points: 20
  • 03-27-2007 8:00 PM In reply to

    • cvega
    • Top 10 Contributor
    • Joined on 11-25-2005
    • Posts 497
    • Points 8,455

    Re: It Does Not Select! Cannot Copy to Clipbboard!

    Hi,

    First of all, you need to be careful on what function you're using.

    SendMessage will send window message to a window handle.
    SendDlgMessage will send window message to a window handle (acting as dialog).

    That's why you can't use EM_SETSEL is because neither of the window you're trying to "copy" data from is/are an EditBox.

    To solve this, you need to "send" the message to the item itself, hence I recomment you to use the function that will send the message directly to the dialog item, which is the SendDlgItemMessage function. This should work:

    invoke SendDlgItemMessage, hDialog, IDC_EDIT_OUTPUT, EM_SETSEL, 0, -1
    invoke
    SendDlgItemMessage, hDialog, IDC_EDIT_OUTPUT, WM_COPY, 0, 0
    invoke
    SendDlgItemMessage, hDialog, IDC_EDIT_OUTPUT, EM_SETSEL, -1, 0

    where hDialog is the window handle of your DialogBox containing the EditBox having the id
    IDC_EDIT_OUTPUT.


    Cheers,

    -chris
    Chris Vega This posting is provided "AS IS" with no warranties, and confers no rights My Weblog|Visit MSDN Community
    • Post Points: 20
  • 03-27-2007 11:42 PM In reply to

    • modchip
    • Top 10 Contributor
    • Joined on 02-09-2006
    • Ivalice
    • Posts 710
    • Points 10,110

    Re: It Does Not Select! Cannot Copy to Clipbboard!

    I think there's something wrong with my code. I followed your advise... but it still does not copy... nor select... hmmmm... Are there codes that could mess up the operation of the "copy code"?

    Thanks!

    Regards,
    m0ds

    Filed under:
    • Post Points: 20
  • 03-28-2007 8:04 PM In reply to

    • cvega
    • Top 10 Contributor
    • Joined on 11-25-2005
    • Posts 497
    • Points 8,455

    Re: It Does Not Select! Cannot Copy to Clipbboard!

    Answer
    I fixed the source code you've sent me. I am posting it here for everyones' reference.

    Cheers,

    -chris
    Chris Vega This posting is provided "AS IS" with no warranties, and confers no rights My Weblog|Visit MSDN Community
    • Post Points: 20
  • 03-28-2007 10:08 PM In reply to

    • modchip
    • Top 10 Contributor
    • Joined on 02-09-2006
    • Ivalice
    • Posts 710
    • Points 10,110

    Re: It Does Not Select! Cannot Copy to Clipboard!

    Thank you, I have learned more than I asked for.

    Til next time! Chao!

    Filed under:
    • Post Points: 5
Page 1 of 1 (5 items)