-
October 21st, 2008, 08:03 AM
#1
CRichEditCtrl - margins and emdedded docs
I have a CRichEditCtrl embedded on a dialog, and I'm filling it by loading up a RTF doc and streaming it into the control. Two questions:
1) Is there a way I can embed the RTF document in the resources and have a CFile object open up the resource instead of providing an actual file system path?
2) Is there a way to specify margins on the Rich Edit Control? Right now when the text is streamed into the control, it starts at the very top left. Ideally, I'd like a 10-15 pixel area of margin around the inside of the control.
Thanks for any help!
-
October 21st, 2008, 06:11 PM
#2
Re: CRichEditCtrl - margins and emdedded docs
Re: 1, have you checked EM_STREAMIN. I am guessing you could send this message and in the callback pass in the buffer to the data.
You could get the buffer by adding a resource to your exe and using LoadResource/LockResource to read the data into a buffer. Just a possibility.
-
October 22nd, 2008, 09:38 AM
#3
Re: CRichEditCtrl - margins and emdedded docs
I ended up finding a solution to both my question below through a little research. I'll post them here in case anyone had similar questions:
1. I did pretty much what you were suggesting. I called FindResource, LoadResource, then LockResource. I got a void* back from LockResource which I then copied to the buffer in the "stream-in" callback using a CMemFile.
2. I ended up using SetParaFormat on the Rich Edit Control. To set right and left margins, I selected all the text (SetSel(0, -1)), then called SetParaFormat using a PARAFORMAT2 object where I set the dxStartIndent and dxRightIndent. For the top margin, I selected the entire first line (SetSel(0, m_richEdit.LineLength(0)), then called SetParaFormat using a PARAFORMAT2 object where I set the dySpaceBefore.
Thanks for your response.
-
October 22nd, 2008, 10:44 AM
#4
Re: CRichEditCtrl - margins and emdedded docs
cool. Glad you worked it out. Thanks for sharing your solution
-
October 22nd, 2008, 01:24 PM
#5
Re: CRichEditCtrl - margins and emdedded docs
Actually, as I was reading the CRichEditCtrl documentation more closely, I found a way better solution for my second question (about setting margins). Instead of doing all that paragraph formatting, I called SetRect on my Rich Edit control with the client rect deflated by a few pixels. Much cleaner solution =)
-
November 23rd, 2018, 07:32 AM
#6
Re: CRichEditCtrl - margins and emdedded docs
@sjc It is 2018, 10 years later and i have to say your answer helped me on your 2nd question.
Here is a reference to SetRect which worked pretty well.. Thanks again
https://docs.microsoft.com/en-us/cpp...s-2017#setrect
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
On-Demand Webinars (sponsored)
|