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

    deselect text in combo box

    I have created a combo box like this :

    Code:
    combo_hwnd = CreateWindowEx(WS_EX_WINDOWEDGE, "COMBOBOX" , NULL, WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWN , left, top, width , height , parent_hwnd, NULL, NULL, NULL);
    When I select an item from a drop down list, its text appears normally in the edit part, but it always appears as selected text. I want to deselect this text, and I tried to achieve that by sending CB_SETEDITSEL message, right after item selection:


    Code:
    case WM_COMMAND:
    		     
              switch(HIWORD(wParam))
                  {
    			     case CBN_SELCHANGE:
    					 SendMessage(combo_hwnd , CB_SETEDITSEL ,  0, MAKELPARAM(-1,0));
    					 break;
    	      }
    This doesn't change anything to my combo box, so does anybody know how to deselect the text from a combo box?
    Last edited by user125; August 18th, 2015 at 09:23 AM.

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

    Re: deselect text in combo box

    Try PostMessage rather than SendMessage.
    Victor Nijegorodov

  3. #3
    Join Date
    Aug 2015
    Posts
    8

    Re: deselect text in combo box

    That seems to work. Thanks.

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

    Re: deselect text in combo box

    Welcome!
    Victor Nijegorodov

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