Click here to Skip to main content
15,927,212 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: How to enable unicode? Pin
David Crow9-Jan-06 3:19
David Crow9-Jan-06 3:19 
AnswerRe: How to enable unicode? Pin
<color>Aljechin 9-Jan-06 20:22
<color>Aljechin 9-Jan-06 20:22 
GeneralRe: How to enable unicode? Pin
David Crow10-Jan-06 1:53
David Crow10-Jan-06 1:53 
QuestionRTF to plain text problem Pin
Maciej Lisiewski8-Jan-06 20:46
Maciej Lisiewski8-Jan-06 20:46 
AnswerRe: RTF to plain text problem Pin
Neville Franks8-Jan-06 21:35
Neville Franks8-Jan-06 21:35 
QuestionRe: RTF to plain text problem Pin
Maciej Lisiewski9-Jan-06 0:05
Maciej Lisiewski9-Jan-06 0:05 
AnswerRe: RTF to plain text problem Pin
S Douglas8-Jan-06 21:55
professionalS Douglas8-Jan-06 21:55 
QuestionRe: RTF to plain text problem Pin
Maciej Lisiewski9-Jan-06 0:15
Maciej Lisiewski9-Jan-06 0:15 
For some reason it doesn't work.
I'm using this StreamIn/StreamOut:
<code>
static DWORD CALLBACK StreamOut( DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb )
{

// Setting up temp buffer
char* buff;
buff = new char[ cb + 1 ];
buff[ cb ] = ( char ) 0;
strncpy( buff, ( LPCSTR ) pbBuff, cb );
int max = strlen( buff );

CString* str = ( CString* ) dwCookie;

#ifdef _UNICODE

// We want to convert the buff to wide chars
int length = ::MultiByteToWideChar( CP_UTF8, 0, buff, max, NULL, 0 );
if( length )
{
TCHAR* wBuff = new TCHAR[ length ];
::MultiByteToWideChar( CP_UTF8, 0, buff, max, wBuff, length );

*str += wBuff;
delete[] wBuff;
}

#else

*str += buff;

#endif

delete[] buff;
*pcb = max;

return 0;

}

static DWORD CALLBACK StreamIn( DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb )
{

CString* str = ( ( CString* ) dwCookie );

#ifdef _UNICODE

// Unicode is only supported for SF_TEXT, so we need
// to convert
LPCTSTR ptr = str->GetBuffer( (*str).GetLength() );
int length = ::WideCharToMultiByte( CP_UTF8, 0, ptr, -1, NULL, 0, NULL, NULL );
int max = min( cb, length );
if( length )
{
char* buff = new char[ length ];
::WideCharToMultiByte( CP_UTF8, 0, ptr, -1, buff, length + 1, NULL, NULL );
strncpy( (LPSTR) pbBuff, buff, max );
delete[] buff;
}
str->ReleaseBuffer();

#else

int max = min( cb, (*str).GetLength() );
strncpy( ( LPSTR ) pbBuff, (*str) , max );

#endif

(*str) = (*str).Right( (*str).GetLength() - max );

*pcb = max;

return 0;

}
</code>

If I StreamIn with SF_RTF and StreamOut with SF_TEXT I end up with an empty string or one far too long, but containing the desired data.

-- modified at 8:25 Monday 9th January, 2006
Question[Message Deleted] Pin
sanjukta1238-Jan-06 19:45
sanjukta1238-Jan-06 19:45 
AnswerRe: Windows Media Player Pin
<color>Aljechin 8-Jan-06 23:26
<color>Aljechin 8-Jan-06 23:26 
QuestionSubclassing CView twice with MFC Pin
flip8-Jan-06 19:43
flip8-Jan-06 19:43 
AnswerRe: Subclassing CView twice with MFC Pin
Cedric Moonen8-Jan-06 20:54
Cedric Moonen8-Jan-06 20:54 
AnswerRe: Subclassing CView twice with MFC Pin
Prakash Nadar8-Jan-06 22:20
Prakash Nadar8-Jan-06 22:20 
Questionconvert WAV file to VOX Pin
Member 22716558-Jan-06 18:50
Member 22716558-Jan-06 18:50 
AnswerRe: convert WAV file to VOX Pin
Prakash Nadar8-Jan-06 19:48
Prakash Nadar8-Jan-06 19:48 
GeneralRe: convert WAV file to VOX Pin
Aamir Butt8-Jan-06 23:40
Aamir Butt8-Jan-06 23:40 
GeneralRe: convert WAV file to VOX Pin
Prakash Nadar8-Jan-06 23:42
Prakash Nadar8-Jan-06 23:42 
QuestionHow to colour the scroll Bars of a MDI application Pin
rohinimtech8-Jan-06 18:42
rohinimtech8-Jan-06 18:42 
QuestionMouseOver effect for ToolBar Pin
Anilkumar K V8-Jan-06 18:24
Anilkumar K V8-Jan-06 18:24 
AnswerRe: MouseOver effect for ToolBar Pin
Owner drawn8-Jan-06 19:39
Owner drawn8-Jan-06 19:39 
QuestionVery urgent, problem with class wizard Pin
Vineethg8-Jan-06 18:23
Vineethg8-Jan-06 18:23 
AnswerRe: Very urgent, problem with class wizard Pin
Anilkumar K V8-Jan-06 18:26
Anilkumar K V8-Jan-06 18:26 
GeneralRe: Very urgent, problem with class wizard Pin
Vineethg8-Jan-06 18:47
Vineethg8-Jan-06 18:47 
GeneralRe: Very urgent, problem with class wizard Pin
BadKarma8-Jan-06 20:40
BadKarma8-Jan-06 20:40 
GeneralRe: Very urgent, problem with class wizard Pin
Vineethg8-Jan-06 20:49
Vineethg8-Jan-06 20:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.