CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    37

    UNICODE question



    Hi, I have the following few lines in my program, that get called in OnInitialUpdate() for a RichEditView doc/view app.

    CHARFORMAT cfm;

    cfm.cbSize = sizeof(cfm);

    cfm.dwMask = CFM_FACE | CFM_BOLD;

    cfm.dwEffects = CFE_BOLD;

    _tcscpy(cfm.szFaceName, _T("Arial&quot);

    theCtrl.SetDefaultCharFormat(cfm);

    When compiling with _UNICODE, that code fails on the _tcscpy line, with the following error:

    error C2664: 'wcscpy' : cannot convert parameter 1 from 'char [32]' to 'unsigned short *'

    Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

    How can I get this to work with _UNICODE?


    thanks,

    -Matt

  2. #2
    Join Date
    Mar 1999
    Posts
    3

    Re: UNICODE question



    In the header file AFXPRIV.H are numerous string conversion macros:

    A2BSTR OLE2A T2A W2A

    A2COLE OLE2BSTR T2BSTR W2BSTR

    A2CT OLE2CA T2CA W2CA

    A2CW OLE2CT T2COLE W2COLE

    A2OLE OLE2CW T2CW W2CT

    A2T OLE2T T2OLE W2OLE

    A2W OLE2W T2W W2T



    W2A will solve your problem and convert the UNICODE string to normal ASCII



  3. #3
    Join Date
    Mar 1999
    Posts
    6

    Re: UNICODE question





    Use _UNICODE and UNICODE (without underline)


    The following codefragment is from richedit.h:


    #if (_RICHEDIT_VER >= 0x0200)

    #ifdef UNICODE

    #define CHARFORMAT CHARFORMATW

    #else

    #define CHARFORMAT CHARFORMATA

    #endif /* UNICODE */

    #else

    #define CHARFORMAT CHARFORMATA

    #endif /* _RICHEDIT_VER >= 0x0200 */



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