Click here to Skip to main content
15,899,018 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Get Windows Standard Dialog Color Pin
Nish Nishant9-Jan-06 4:58
sitebuilderNish Nishant9-Jan-06 4:58 
GeneralRe: Get Windows Standard Dialog Color Pin
master879-Jan-06 7:05
master879-Jan-06 7:05 
GeneralRe: Get Windows Standard Dialog Color Pin
master879-Jan-06 7:16
master879-Jan-06 7:16 
GeneralRe: Get Windows Standard Dialog Color Pin
Nish Nishant9-Jan-06 7:19
sitebuilderNish Nishant9-Jan-06 7:19 
GeneralRe: Get Windows Standard Dialog Color Pin
Nish Nishant9-Jan-06 7:20
sitebuilderNish Nishant9-Jan-06 7:20 
QuestionMapping Network drives Pin
Priya..k9-Jan-06 4:07
Priya..k9-Jan-06 4:07 
AnswerRe: Mapping Network drives Pin
David Crow9-Jan-06 4:20
David Crow9-Jan-06 4:20 
QuestionWhich Callback? Pin
Maciej Lisiewski9-Jan-06 3:48
Maciej Lisiewski9-Jan-06 3:48 
I'm using callback functions to get rtf strings in and out of CRichEditCtrl and I'm not happy with any I tried.

1. Works great until I try to get unicode string (SF_UNICODE) - if I do i only get the first letter of the string.
<br />
DWORD __stdcall MEditStreamInCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)<br />
{<br />
	CString *psBuffer = (CString *)dwCookie;<br />
	if (cb < psBuffer->GetLength()) cb = psBuffer->GetLength();<br />
	for (int i=0;i<cb;i++)	{<br />
		*(pbBuff+i) = psBuffer->GetAt(i);<br />
	}<br />
	*pcb = cb;<br />
	*psBuffer = psBuffer->Mid(cb);<br />
	return 0;<br />
}<br />
<br />
DWORD __stdcall MEditStreamOutCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)<br />
{<br />
	CString sThisWrite;<br />
	sThisWrite.GetBufferSetLength(cb);<br />
	CString *psBuffer = (CString *)dwCookie;	<br />
	for (int i=0;i<cb;i++) {<br />
		sThisWrite.SetAt(i,*(pbBuff+i));<br />
	}<br />
	*psBuffer += sThisWrite;<br />
	*pcb = sThisWrite.GetLength();<br />
	sThisWrite.ReleaseBuffer();<br />
	return 0;<br />
}<br />


2. Tricky. No problems with UNICODE (at least not with unicode as such - it basicaly works from time to time)
<br />
static DWORD CALLBACK StreamOut( DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb )<br />
{<br />
<br />
	// Setting up temp buffer<br />
	char*	buff;<br />
	buff = new char[ cb + 1 ];<br />
	buff[ cb ] = ( char ) 0;<br />
	strncpy( buff, ( LPCSTR ) pbBuff, cb );<br />
	int max = strlen( buff );<br />
<br />
	CString* str = ( CString* ) dwCookie;<br />
<br />
#ifdef _UNICODE<br />
<br />
	// We want to convert the buff to wide chars<br />
	int length = ::MultiByteToWideChar( CP_UTF8, 0, buff, max, NULL, 0 );<br />
	if( length )<br />
	{<br />
		TCHAR* wBuff = new TCHAR[ length ];<br />
		::MultiByteToWideChar( CP_UTF8, 0, buff, max, wBuff, length );<br />
		*str += wBuff;<br />
		delete[] wBuff;<br />
	}<br />
#else<br />
	*str += buff;<br />
#endif<br />
	delete[] buff;<br />
	*pcb = max;	<br />
	return 0;<br />
}<br />


and 'bout 2-3 found over net - none of them works as I'd like it to.

If you have a WORKING, TESTED callback functions for CRichEditCtrl and with unicode support let mi know. If you know what's wrong with these 2 sert and/or how to correct it just tell me

I apologise for any mistakes made in this post - it's my third day of non-stop coding and sleep depravation starts to kick in..


Maciej Lisiewski
The sad thing is that due to bad luck with code and deadlines my uptime makes me a good server.

-- modified at 9:49 Monday 9th January, 2006
AnswerRe: Which Callback? Pin
Rage9-Jan-06 6:10
professionalRage9-Jan-06 6:10 
GeneralRe: Which Callback? Pin
Maciej Lisiewski9-Jan-06 6:34
Maciej Lisiewski9-Jan-06 6:34 
GeneralRe: Which Callback? Pin
Rage9-Jan-06 8:12
professionalRage9-Jan-06 8:12 
Questionthread and standard Input (stdin) Pin
hellomoin9-Jan-06 3:33
hellomoin9-Jan-06 3:33 
QuestionError Message Tables - who to implement them Pin
Sebastian Schneider9-Jan-06 2:47
Sebastian Schneider9-Jan-06 2:47 
QuestionRe: Error Message Tables - who to implement them Pin
David Crow9-Jan-06 3:03
David Crow9-Jan-06 3:03 
AnswerRe: Error Message Tables - who to implement them Pin
Rage9-Jan-06 6:18
professionalRage9-Jan-06 6:18 
AnswerRe: Error Message Tables - who to implement them Pin
Blake Miller9-Jan-06 7:09
Blake Miller9-Jan-06 7:09 
AnswerRe: Error Message Tables - who to implement them Pin
Sebastian Schneider9-Jan-06 20:11
Sebastian Schneider9-Jan-06 20:11 
QuestionHow to read from a text file? Pin
Amarelia9-Jan-06 2:14
Amarelia9-Jan-06 2:14 
AnswerRe: How to read from a text file? Pin
Chris Losinger9-Jan-06 2:18
professionalChris Losinger9-Jan-06 2:18 
AnswerRe: How to read from a text file? Pin
toxcct9-Jan-06 2:21
toxcct9-Jan-06 2:21 
QuestionRe: How to read from a text file? Pin
David Crow9-Jan-06 3:06
David Crow9-Jan-06 3:06 
QuestionPrinter Monitoring Pin
micutzu9-Jan-06 1:44
micutzu9-Jan-06 1:44 
AnswerRe: Printer Monitoring Pin
David Crow9-Jan-06 3:09
David Crow9-Jan-06 3:09 
GeneralRe: Printer Monitoring Pin
Dudi Avramov9-Jan-06 4:07
Dudi Avramov9-Jan-06 4:07 
GeneralRe: Printer Monitoring Pin
David Crow9-Jan-06 4:18
David Crow9-Jan-06 4:18 

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.