Thread: Text being automatically selected: WM_SETTEXT

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    124

    Text being automatically selected: WM_SETTEXT

    Hi,

    This strikes me as pretty silly, but I can't figure out why this is happening.

    I've got the following code (in highly cut-down form):

    Code:
    LRESULT CALLBACK HelpAboutDlgBox(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
    {
    	static char outbuf[UV_MAXANALEN];
    	static HWND help_abt;
    
    	switch (message)
    	{
    		/* Use messages to update, etc */
    		case WM_INITDIALOG:
    			help_abt = GetDlgItem(hDlg, HELP_ABT); // Multiline edit area
    			strcpy(outbuf, "A lot of text");
    			SendMessage(help_abt, WM_SETTEXT, (WPARAM)NULL, (LPARAM)outbuf);
    			return TRUE;
    			break;
    		case WM_COMMAND:
    			...
    			break;
    		default:
    			break;
    	}
    	return FALSE;
    }
    For some reason, the text when displayed is being selected (as if with Control-A) and yet I'm doing nothing to achieve this. The effect is undesired.

    HELP_ABT is defined as follows:
    Code:
    EDITTEXT        HELP_ABT, 32, 23, 293, 102, ES_MULTILINE | ES_READONLY | WS_VSCROLL
    Is there anything wrong with the above code fragment that would give rise to this?

    TIA!
    I think you can put a signature here.

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Return FALSE from WM_INITDIALOG instead of TRUE.

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    124
    Thanks Bithub, that worked a treat :-)

    Funnily enough, I'd tried that (amongst lots of other things) before posting, all to no effect.
    I think you can put a signature here.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DirectX | Drawing text
    By gavra in forum Game Programming
    Replies: 4
    Last Post: 06-08-2009, 12:23 AM
  2. Automatically Open Text File
    By JackR in forum C++ Programming
    Replies: 4
    Last Post: 01-16-2008, 09:56 AM
  3. Display selected words from text file
    By picasso in forum C++ Programming
    Replies: 3
    Last Post: 10-10-2007, 09:06 AM
  4. struct question
    By caduardo21 in forum Windows Programming
    Replies: 5
    Last Post: 01-31-2005, 04:49 PM
  5. Replies: 1
    Last Post: 07-13-2002, 05:45 PM