ASE Home Page Products Download Purchase Support About ASE
ChartDirector General
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  StringArray add data with vc++ CString class
Posted by gdkevin on Jul-10-2009 08:34
how can i do ?
use vc++ CString class add to StringArray data ?

  Re: StringArray add data with vc++ CString class
Posted by Peter Kwan on Jul-10-2009 23:40
Hi gdkevin,

The StringArray is just an array of standard C text strings (char *). So you just need to use standard C text strings in the array.

For "CString", I assume you are referring to MFC CString. It is a Microsoft proprietary data structure, and the underlying text string is a TCHAR *.

You may use one of the following methods to convert "TCHAR *" to standard C text string "char *".

(a) You can use Microsoft's method to convert "TCHAR *" to standard C text string "char *". If your MFC is set to MBCS mode, you can just cast the "TCHAR *" to "char *". If your MFC is set to UNICODE mode, you may use WideCharToMultiByte to convert the "TCHAR *" to "char *".

(b) ChartDirector also has a utility to convert TCHAR to UTF8 (a UTF8 text string is a "char *" text string). If you use the ChartDirector utility, the code would be like:

for (int i=0;i<numw;i++)
{
    str=app->m_well.MyWell[i]->name; //AfxMessageBox(str);
    labels.data[i]=strdup(TCHARtoUTF8((TCHAR *)str));
}

As strdup is used, please remember to free to data afterwards to avoid memory leak.

Hope this can help.

Regards
Peter Kwan

  Re: StringArray add data with vc++ CString class
Posted by gdkevin on Jul-11-2009 13:59
thank you very mach !

solving