|
Hi,
I need your help very urgently....
I have only 2days left to complete my MCA Academic project can u please help me with the CRichEditCtrl control..
I am totaly new to VC++ and i have no idea how to work with CRichEditCtrl ..
Can u please tell how work with CRichEditCtrl ?
i want to pass the entire text file to CRichEditCtrl and i want to highlight some words after passing the text file to CRichEditCtrl
i have created rich edit control IDC_FCONT m_FCONT of type CRichEditCtrl
char ch;
FILE *fp;
fp=fopen(str,"r");
if(fp==NULL)
{
MessageBox("error opening file.",MB_OK | MB_ICONINFORMATION);
return;
}
ch=getc(fp);
while(!feof(fp))
{
//putch(ch);
ch=getc(fp);
}
// m_FCONT.SetWindowText();
fclose(fp);
}
can u please help me.....
Thanking you ....
i will be waiting...
Regards,
Vinay Charan.
|
|
|
|
|
VinayCool wrote: i want to pass the entire text file to CRichEditCtrl
Look up StreamIn and StreamOut
VinayCool wrote: and i want to highlight some words after passing the text file to CRichEditCtrl
Search in MSDN for Using CRichEditCtrl . This article covers almost all functions of CRichEditCtrl .
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
I get the vague feeling I'm doing someone's homework....
You can either lookup CRichEditCtrl's StreamIn function or if you need a quick and dirty file reader (for small files), do something like:
FILE *fp = fopen(str,"r");<br />
if (fp)<br />
{<br />
fseek(fp, 0L, SEEK_END);<br />
long fileLen = ftell(fp);<br />
rewind(fp);<br />
<br />
char* text = new char[fileLen + 1];<br />
<br />
fread(text, 1, fileLen, fp);<br />
<br />
m_FCONT.SetWindowText(text);<br />
<br />
delete [] text;<br />
<br />
fclose(fp);<br />
}<br />
else<br />
{<br />
MessageBox("error opening file.",MB_OK | MB_ICONINFORMATION);<br />
return;<br />
}<br />
This code is totally untested, but should give you the general idea. Good luck!
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Hi Steve Echols,
Thank you very much, code is 100% working.
But at the end of edit of edit box i am getting some junk values as shown below.
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍýýýýÝÝÝÝÝÝÝÝÝ
Can u please also tell me how to highlight a particular word in the Rich edit box.
if want to high light a word america in the rich edit box ,the word may apper more then once..
can u please give me some inforamtion...
Regards,
Vinay Charan.
|
|
|
|
|
VinayCool wrote: But at the end of edit of edit box i am getting some junk values as shown below.
You need a terminating null on the text (which I forgot):
Change the lines in bold:
<br />
char* text = new char[fileLen + 1];<br />
<br />
fread(text, 1, fileLen, fp);<br />
<br />
text[fileLen] = 0;<br />
<br />
VinayCool wrote: Can u please also tell me how to highlight a particular word in the Rich edit box.
Like I mentioned yesterday, you can do somthing like:
CHARFORMAT cf;<br />
memset(&cf, 0, sizeof(CHARFORMAT));<br />
cf.cbSize = sizeof(CHARFORMAT);<br />
cf.dwMask = CFM_BOLD;<br />
cf.dwEffects = CFE_BOLD;<br />
<br />
for (int i = 0; i < size of your word list; i++)<br />
{<br />
m_FCONT.SetSel(word_position[i], word_length[i]);<br />
m_FCONT.SetSelectionCharFormat(cf);<br />
}<br />
Hope that works!
- S
50 cups of coffee and you know it's on!
-- modified at 3:07 Thursday 25th May, 2006
|
|
|
|
|
Hi Steve Echols,
Thank for helping me for completing my project.
Code is working i declared these vaiables
char word_position[50];
char word_length[50];
Steve how to pass the word ??? where i ahve to pass the word which has to be highlighted ??
I have stored the word here which has to be hightlighted
w = m_WORD;
----------------------------------
<code>CHARFORMAT cf;
memset(&cf, 0, sizeof(CHARFORMAT));
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask = CFM_BOLD;
cf.dwEffects = CFE_BOLD;
UpdateData(TRUE);
CString w;
w = m_WORD;
int len = strlen(word);
char word_position[50];
char word_length[50];
// **** pseudo-code ****
for (int p = 0; p < len ; p++)
{
m_FCONT.SetSel(word_position[p], word_length[p]);
m_FCONT.SetSelectionCharFormat(cf);
}</code>
Regards,
Vinay Charan.
|
|
|
|
|
http://www.codeproject.com/richedit/htmlricheditctrlssl.asp
the above link can give you some idea.
Regards
Anil
|
|
|
|
|
Hi Anil,
Thanks for the link...
Regards,
Vinay Charan.
|
|
|
|
|
The most important thing you need to do is
Call AfxInitRichEdit() function in u r InitInstance() of u r application.AfxInitRichEdit loads RICHED32.DLL to initialize version 1.0 of the rich edit control.
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
Hi Appu,
Thanks for the information,it will be usefull for me.
Regards,
Vinay Charan.
|
|
|
|
|
|
HI,
I am suing ::SHFileOperation() to copy a file.
If File already exists on the destenation path then a message box appears that would you like to overwrite it ( same as the message in windows appears that asks about the overwrite option)
I dont want to display this message, file must be overwrite always.
How can I skip this message box?
thanks
Regards.
|
|
|
|
|
...but maybe you or user overwrite one important file
whitesky
|
|
|
|
|
We need to overwrite it (at any cost) thats why we not require that messagebox. becuase it will stop at the message box and the user must be there to click on Yes or No ,
In my application user interaction is not required so in absence of user the application will wait at the message to get response from user.
Since there is not user interaction and we also need to over write it always so we not require this message box
Thanks
Regards.
|
|
|
|
|
zahid_ash wrote: We need to overwrite it (at any cost) thats why we not require that messagebox. becuase it will stop at the message box and the user must be there to click on Yes or No ,
In my application user interaction is not required so in absence of user the application will wait at the message to get response from user.
Since there is not user interaction and we also need to over write it always so we not require this message box
Look up SHFILEOPSTRUCT . There is a flag field called fFlags which controls the interaction part. You can set appropriate values for it.
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
I'm sending string from C# to VC++ in the form of "Base64String"; how can i convert this string into general string. Make sure this string contains Bytes of data.
If it is a C# i will do the following code to get my string, what should i do for VC++. Insted of writting into file is there any possibilities to assing to string variable.
byte[] result = Convert.FromBase64String(str);
FileStream objStream = new FileStream ("D:\\SS.txt",FileMode.Open,FileAccess.Read );
BinaryWriter objWriter = new BinaryWriter (objStream);
objWriter.Write (result);
|
|
|
|
|
hai to everyone
I am working with checkboxes.i have placed them in the list control.when i check one check box it should perform the specified task by me.For doing that how can i capture the return value when a check box is checked.
|
|
|
|
|
Handle the BN_CLICKED message for the checkbox.
If you are using MFC then use the class wizard to handle it easily.
Regards
Anil
|
|
|
|
|
|
I'm using SafeArray to handle array of values, here i will itrate all the elements one be one and retriving the values.
Now, if i send large amount of data for example Byte[] how can i handle with out doing itration since it will take lot of time to loop through. Please provide me some example too. Is there any possibilities to copy entire
Byte[] to another array or to some dtring variable.
|
|
|
|
|
Does anybody knows about mpeg decoder which can be used with VC++, to decode and mpeg files and give frames?
Please help.
Thanks.
jay111
|
|
|
|
|
hi,
i've got a problem with getwindowtext. i've spent at least an hour trying to figure out why this won't work. (sad, huh?) i have this code:
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
LPSTR title = "";
CString thetitle = "";
GetWindowText(hwnd, title, 100);
thetitle = (CString) title;
AfxMessageBox(thetitle);
if(thetitle == "...") {
...
}
return TRUE;
}
onSomeButtonClick...() {
if(!EnumWindows((WNDENUMPROC) EnumWindowsProc, 0)) {
...
}
} for some reason, thetitle is always blank. can someone tell me why this is happening? any tips for fixing this would help.
thanks.
-- modified at 21:14 Wednesday 24th May, 2006
|
|
|
|
|
Try
<br />
char title[100];<br />
GetWindowText(hwnd, title, 100);<br />
Regards
Anil
|
|
|
|
|
it worked! thanks a lot.
1 more question... how do you put the text in that font?
|
|
|
|
|
Sorry did not get your question
Regards
Anil
|
|
|
|