Click here to Skip to main content
16,004,974 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralfImagelist from files Pin
santu9-Oct-03 8:56
santu9-Oct-03 8:56 
General"Transparent" Control Pin
User-3779369-Oct-03 8:32
User-3779369-Oct-03 8:32 
GeneralRe: "Transparent" Control Pin
YaronNir9-Oct-03 11:06
YaronNir9-Oct-03 11:06 
GeneralRe: "Transparent" Control Pin
YaronNir9-Oct-03 11:08
YaronNir9-Oct-03 11:08 
GeneralRe: "Transparent" Control Pin
User-3779369-Oct-03 22:46
User-3779369-Oct-03 22:46 
QuestionDisassembly to Source Code??? Pin
MrGee9-Oct-03 8:08
MrGee9-Oct-03 8:08 
AnswerRe: Disassembly to Source Code??? Pin
Michael Dunn9-Oct-03 8:17
sitebuilderMichael Dunn9-Oct-03 8:17 
QuestionSaving multiple RTFs to string for storage? Pin
Kayembi9-Oct-03 7:27
Kayembi9-Oct-03 7:27 
Hi,

I'm writing a program that incorporates a Rich Edit control text editor containing consisting of an arbitrary number of "documents". On the left of the screen is a tree view, and on the right of the screen is a rich edit control for text editing. The user uses the tree view to create new "documents". By clicking on a tree view item, the document that that represents should appear in the rich text control on the right. All of this has to be saved to a single file (possibly using structs), and exported to an RTF. Saving to RTF is sorted (thanks to help from users here), but my problem is this:

How can I save an entire "document" to a string? I have tried saving to a char*, but I haven't got it working.

Note that I am using _no_ MFC, and I am not a very experienced programmer - I am still on a steep learning curve, so please forgive any idiocy in my code.

This is what I tried:

<br />
char* szTextTest;<br />
long nTest;<br />
<br />
static DWORD CALLBACK <br />
MyStreamInStringCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)<br />
{<br />
	memcpy(pbBuff,szTextTest,nTest);<br />
<br />
	*pcb = cb;<br />
<br />
	return 0;<br />
}<br />
<br />
void LoadRTFFromString(HWND hWnd, int nIDDlgItem)<br />
{<br />
	EDITSTREAM es;<br />
<br />
	es.pfnCallback = MyStreamInStringCallback; <br />
<br />
	SendDlgItemMessage(hWnd,nIDDlgItem,EM_STREAMIN,SF_RTF,(LPARAM)&es);<br />
}<br />
<br />
<br />
static DWORD CALLBACK <br />
MyStreamOutStringCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)<br />
{<br />
	nTest = cb;<br />
	szTextTest = new char[cb];<br />
	memcpy(szTextTest,pbBuff,cb);<br />
<br />
	*pcb = cb;<br />
<br />
	return 0;<br />
}<br />
<br />
void SaveRTFToString(HWND hWnd, int nIDDlgItem)<br />
{<br />
	EDITSTREAM es;<br />
<br />
	es.pfnCallback = MyStreamOutStringCallback; <br />
<br />
	SendDlgItemMessage(hWnd,nIDDlgItem,EM_STREAMOUT,SF_RTF,(LPARAM)&es);<br />
}<br />


Even if I could get the above working, would I be able to save the character pointer, szTextText, to file using WriteFile() and have it save all the text it has been allocated? I have only ever saved structures containing chars that aren't pointers to file so far...

If I can copy the whole of a formatted RTF file to a string, this is what I am thinking of doing to save the structure:

For each folder, copy text into the string such as "{{folder:name_of_folder;}}" or some such, and then add to the end of that the rich text that is associated with that folder. When reloading from file, I just need to search the string for occurrences such as "{{folder::...}}" etc in order to rebuild my treeview and associate text appropriately.

Thus the string created to hold the rich text needs to be infinitely long - or rather, it needs to be capable of holding formatted text that could run into the 100,000s of *words*.

To clarify, in case that was a bit long winded: I need to find a non-MFC way of saving and loading all of the text from a rich edit box into a string. And I need to be able to append to that string the text from _other_ rich edit boxes.

If anybody could give me any hints on how I could go about this, I'd be really grateful, as always.

Many thanks,
KB
AnswerRe: Saving multiple RTFs to string for storage? Pin
John M. Drescher9-Oct-03 7:51
John M. Drescher9-Oct-03 7:51 
Questionmfc42u.lib ? Pin
spiritualfields9-Oct-03 5:39
spiritualfields9-Oct-03 5:39 
AnswerRe: mfc42u.lib ? Pin
W. Hammer -sledge-9-Oct-03 6:04
W. Hammer -sledge-9-Oct-03 6:04 
AnswerRe: mfc42u.lib ? Pin
Garth J Lancaster9-Oct-03 17:49
professionalGarth J Lancaster9-Oct-03 17:49 
AnswerRe: mfc42u.lib ? Pin
speedo21shree14-Oct-10 23:11
speedo21shree14-Oct-10 23:11 
GeneralC to C++ link error Pin
jimNLX9-Oct-03 5:05
jimNLX9-Oct-03 5:05 
GeneralRe: C to C++ link error Pin
Joaquín M López Muñoz9-Oct-03 7:51
Joaquín M López Muñoz9-Oct-03 7:51 
GeneralRe: C to C++ link error Pin
jimNLX9-Oct-03 7:57
jimNLX9-Oct-03 7:57 
GeneralRe: C to C++ link error Pin
jimNLX9-Oct-03 8:02
jimNLX9-Oct-03 8:02 
GeneralRe: C to C++ link error Pin
Joaquín M López Muñoz9-Oct-03 8:06
Joaquín M López Muñoz9-Oct-03 8:06 
GeneralRe: C to C++ link error Pin
jimNLX9-Oct-03 8:16
jimNLX9-Oct-03 8:16 
GeneralRe: C to C++ link error Pin
Joaquín M López Muñoz9-Oct-03 8:24
Joaquín M López Muñoz9-Oct-03 8:24 
Generalresizing of dialog boxes Pin
b_girl9-Oct-03 4:06
b_girl9-Oct-03 4:06 
GeneralRe: resizing of dialog boxes Pin
Ravi Bhavnani9-Oct-03 7:36
professionalRavi Bhavnani9-Oct-03 7:36 
GeneralRe: resizing of dialog boxes Pin
b_girl9-Oct-03 8:17
b_girl9-Oct-03 8:17 
Generalchanging language Pin
dudic9-Oct-03 3:44
dudic9-Oct-03 3:44 
GeneralRe: changing language Pin
Atif Mushtaq10-Oct-03 0:12
Atif Mushtaq10-Oct-03 0:12 

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.