CHARFORMAT and EM_SETCHARFORMAT

This is a discussion on CHARFORMAT and EM_SETCHARFORMAT within the Windows Programming forums, part of the Platform Specific Boards category; Hi. I am trying to underline a certain word in a rich edit control, located in a Dialog Box. I ...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    30

    CHARFORMAT and EM_SETCHARFORMAT

    Hi. I am trying to underline a certain word in a rich edit control, located in a Dialog Box. I understand that I should select the word by sending the EM_SETSEL message, and then format it with the EM_SETCHARFORMAT message using a CHARFORMAT structure. Whenever I call the SendMessage function for the EM_SETCHARFORMAT message, it fails and returns 0. I have searched the board and msdn and have failed to discern the problem. Any help is appreciated. Thank you in advance.

    Code:
    	//format
    	CHARFORMAT cf;
    	ZeroMemory(&cf,sizeof(cf));
        cf.cbSize=sizeof(cf);
    	lstrcpy(cf.szFaceName,"Arial");
    /*	cf.bCharSet=ANSI_CHARSET;
    	cf.bPitchAndFamily=FF_ROMAN;*/
    	cf.dwMask=CFM_UNDERLINE;
        cf.dwEffects=CFE_UNDERLINE;
       
    	SetFocus(GetDlgItem(hdlg,IDC_BIBLIO2));
    	SendMessage(GetDlgItem(hdlg,IDC_BIBLIO2),EM_SETSEL,(WPARAM)pos1,(LPARAM)pos2);
    	if(SendMessage(GetDlgItem(hdlg,IDC_BIBLIO2),EM_SETCHARFORMAT,(WPARAM)SCF_WORD|SCF_SELECTION,(LPARAM)(CHARFORMAT FAR *)&cf)==0)
    		MessageBox(NULL,"ERROR","ERROR",MB_OK);

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    30
    Never mind. . . probelm solved. Stupid error.

Popular pages Recent additions subscribe to a feed

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