|
Does anybody know how to insert a new line
into a CRichEditCtrl/View?
for example like this:
rectrl.InsertText("\nnew line\");
thanks in advance
|
|
|
|
|
Use CRichEditCtrl::ReplaceSel. If there is no current selection, the replacement text is inserted at the insertion point, that is, the current caret location.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
is it no something weird like,
two carriage returns and then a line feed.....
Regards
Ray
"Je Suis Mort De Rire"
|
|
|
|
|
Can you please tell me what's wrong with this code:
CMyRichEditView *pView;
CRichEditCtrl& pCtrl = pView->GetRichEditCtrl();
pCtrl.ReplaceSel("\r\r\ntest");
I get a debug assertion in the third line.
thanks
|
|
|
|
|
I've never used a RichEditCtrl before, so I might be wrong, but it looks like you're declaring a pointer and never constructing it, so pCtrl is probably NULL or invalid somehow. Something like that
Jake
|
|
|
|
|
Yes, it seems to be NULL, by why?
|
|
|
|
|
If you have a Assertion is because your code didn get the RichEditCtrl.
In others words pCtrl is NULL.
Do you really have the view of the richedit?
Best Regards!!!
Carlos Antollini.
|
|
|
|
|
That's a good question.
I thought this is the correct way to get the CRichEditCtrl of a CRichEditView.
|
|
|
|
|
How you get the view of the richEdit?
You made something like this?
CRichEditCtrlView* pView = (CRichEditCtrlView*)GetDlgItem(IDC_RICHCTRL);
I saw taht you get the view from a derived class or from your own class of RichEditView I think that the problem start there....
Carlos Antollini.
|
|
|
|
|
NO, the other way round
I want to get the control from my SDI-application, which has a CRichEditView class
|
|
|
|
|
Have a look at the Wordpad example and all your problems will be solved.
Question: What does pView point to????????
Exactly so how can you call GetRichEditControl?
|
|
|
|
|
I think this is the problem.
pView points into nothing
I changed the code to
CMyRichEditFTPView *pView = (CBMyRichEditDoc*)GetView();
CRichEditCtrl& pCtrl = pView->GetRichEditCtrl();
pCtrl.ReplaceSel("\r\r\nTest");
But the compiler says that GetView() ist an undefined expression (or something like that, I have the german visual c++), although it is defined in the MSDN as follows:
CRichEditDoc::GetView
I'm totally confused now
|
|
|
|
|
You are a little confussed.
The getView is for get a view pointer from the RichEditDoc.
Please read how you can get a good view from a RichEdit Using the GetDlgItem function. I put an answer before.
After that you can get a pointer to the CRichEditCtrlCtrl
Regards!!!
Carlos Antollini.
|
|
|
|
|
In what class is this code?
|
|
|
|
|
It is in the MainFrame class of my SDI appliction, and all I want to do is to insert a line into the CRichEditView
|
|
|
|
|
does anybody know why it doesnt work?
CString str;
str = "c:\\test.bmp";
SystemParametersInfo(SPI_SETDESKWALLPAPER,0,str,SPIF_UPDATEINIFILE);
but the following works:
SystemParametersInfo(SPI_SETDESKWALLPAPER,0,"c:\\test.bmp",SPIF_UPDATEINIFILE);
pleaze help!!!!
|
|
|
|
|
|
I get this error:
error C2664: 'SystemParametersInfoA' : cannot convert parameter 3 from 'class CString' to 'void *'
|
|
|
|
|
1) Next time you post a question make clear that you have compiler error
2) The error message is self-describing. 3rd parameter to SystemParametersInfo is void *. You can't directly pass CString object as void *. You need to cast like this:
SystemParametersInfo(
SPI_SETDESKWALLPAPER,
0,
(void *)(const char*)strWallpaperFile,
TRUE);
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
thank you!!!!! I'm just a newbie in C++, thanks again!!!
|
|
|
|
|
Hi,
almost every one of my programs uses an ini-file.
I have written a class that scans the file at program start and stores all variables in a global dynamically allocated struct.
Because this takes some memory when the program gets larger, I was wondering if scanning the file for a particular entry when it is actually needed wouldn't be the better alternative.
What is the 'proper' way to use ini-files and why?
-Sebastian
|
|
|
|
|
Hi,
I don't want to start a flame war here, but since I'm not using MFC and most of my programs don't have a big GUI, I find it too much a bother to write an options dialog, etc. everytime.
-Sebastian
|
|
|
|
|
While the discussion on reading ini at startup versus on-demand would be interesting, I think you should ask yourself if it's worth the trouble. How much memory are you using for this global struct?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi,
its not very much for a smaller program, but I was wondering if I should really store every minor option like background colors, switches for controls or windows the whole time the program is running.
Thanks for your time.
-Sebastian
|
|
|
|
|
Assume that it's biggest program you're ever going to write. Multiply the struct size by 4. How much memory are you going to allocate?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|