CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2003
    Location
    Ottawa, Canada
    Posts
    40

    char * -> LPWSTR

    I'm currently trying to add listview groups to my listview control and for some reason the parameter asked is LPWSTR and not the regular LPSTR.

    Any way to convert so I can add my regular text to the item.

    LVGROUP lvg;
    char gtext[256];
    ....

    lvg.pszHeader = gtext;

    ERROR: c:\VCPP_Projects NET\DCX\ListView.cpp(58): error C2440: '=' : cannot convert from 'char [256]' to 'LPWSTR'

    Using regular WIN32 API and C/C++ to build the code.

    Thanx
    David

  2. #2
    Join Date
    Apr 2004
    Posts
    76
    Hi ClickHeRe,

    Try below. See http://msdn.microsoft.com/library/de...otes_tn059.asp.

    Jeff

    Code:
    USES_CONVERSION
    WCHAR* psz = A2W( "Test" );

  3. #3
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815
    Quote Originally Posted by ClickHeRe
    I'm currently trying to add listview groups to my listview control and for some reason the parameter asked is LPWSTR and not the regular LPSTR.

    Any way to convert so I can add my regular text to the item.
    That reason is most likely that you are building a UNICODE project (with UNICODE and _UNICODE #defined in your preprocessor settings). So either switch to non-UNICODE (if you don't need it), or supply a wide string instead:
    Code:
    WCHAR gtext[256];
    Better yet, use TCHAR instead of WCHAR, and your code will compile for both UNICODE and non-UNICODE builds.

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