Editbox problems

This is a discussion on Editbox problems within the Windows Programming forums, part of the Platform Specific Boards category; I have an Editbox in a dialog, when the dialog is created I send a text to the editbox, but ...

  1. #1
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768

    Editbox problems

    I have an Editbox in a dialog, when the dialog is created I send a text to the editbox, but this makes the text in the editbox to be marked (chosen).

    How can I avoid it?


    thanks.
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227

  3. #3
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    According the off-line MSDN:
    Code:
    SendMessage(GetDlgItem(hDlg, IDD_PREVIEW_PORT), EM_SETSEL, -1, 0);
    According the link you gave me:
    Code:
    SendMessage(GetDlgItem(hDlg, IDD_PREVIEW_PORT), EM_SETSEL, 1, 0);
    They both don't work, why?
    Last edited by Devil Panther; 07-26-2003 at 02:17 PM.
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  4. #4
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  5. #5
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    I agree with Devil Panther. Something is up here. MSDN says:

    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.
    That is entirely untrue. Every "1" should be replaced with "-1" for it to be true. What's with the emoticon adrian? Care to explain yourself?

    Devil Panther, the following line works for me:

    Code:
    SendMessage(hEdit,EM_SETSEL,-1,0);
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  6. #6
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    The MSDN library says...

    >>>
    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.
    <<<

    ... however, the cd's say...

    >>>
    If the nStart parameter is 0 and the nEnd parameter is 1, all the text in the edit control is selected. If nStart is 1, any current selection is removed.
    <<<

    ... which is a little odd since I had always assumed one was created from the other.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  7. #7
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    So the online MSDN is incorrect? It appears that way to me.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  8. #8
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    Would seem so. The -1 is what I've always used and never had any trouble with.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  9. #9
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    I think it just checks for a non-zero value, so 1 and -1 are the same.
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  10. #10
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Actually DevilPanther, that's untrue. Doing what MSDN says will NOT give you the desired results. specifying 0,1 will select the first character. Specifying 1,0 will select the first character also. I advise that you use -1.

    EDIT: Typo
    Last edited by bennyandthejets; 07-27-2003 at 04:15 PM.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No clue how to make a code to solve problems!
    By ctnzn in forum C Programming
    Replies: 8
    Last Post: 10-16-2008, 02:59 AM
  2. Replies: 2
    Last Post: 08-25-2005, 03:09 PM
  3. Create two buttons that interact with an editbox
    By Arkanos in forum Windows Programming
    Replies: 8
    Last Post: 07-13-2005, 12:56 AM
  4. editbox problem
    By tyouk in forum Windows Programming
    Replies: 7
    Last Post: 10-05-2004, 09:14 PM
  5. Cant Get Data From EditBox
    By GodLike in forum Windows Programming
    Replies: 2
    Last Post: 05-12-2003, 04:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21