|
Perfect... Thanks a bunch!
Rob (Bonehead)
|
|
|
|
|
i know, i have posted this question some days ago ...
but this example :
CHARRANGE cr;
cr.cpMax = LONG_MAX;
cr.cpMin = LONG_MAX;
richedit.SetSel( cr ); // move selection to the bottom
richedit.ReplaceSel( (LPCSTR)string ); // insert your text
// force the rich edit to scroll to the bottom
richedit.SendMessage( SB_BOTTOM, NULL, NULL );
doesn't work correctly. (for richedit)
Maybe anybody else knows, how ara many clients prints channel text (mIRC, Client, etc... )
it would be better give some examples (full sources of small exampl-programs) ...
thanks
----------------------------
never stop coding.
|
|
|
|
|
sorry, the topic is "irc like textoutput" ... nevermind ..
----------------------------
never stop coding.
|
|
|
|
|
You could try this
CString strRecvd;
m_cRichEdit.GetWindowText(strRecvd);
if(strRecvd.IsEmpty())
m_wndMonitor.SetWindowText(strMessage);
else if(!strRecvd.Right(1).CompareNoCase("\n"))
m_cRichEdit.SetWindowText(strRecvd + strMessage);
else
m_cRichEdit.SetWindowText(strRecvd +"\n"+ strMessage );
m_cRichEdit.SetSel(-1, -1);
m_cRichEdit.SendMessage(EM_SCROLLCARET);
Hope it helps
Rob
|
|
|
|
|
Hello,
I'm trying to implement a CListCtrl that will add items from a database but for some reason (that I can't figure out) the CListCtrl is adding only blank strings. My code is as follows:
for (i = res.begin (); i != res.end (); i++) {
dateinfo = *i;
lvi.mask = LVIF_TEXT;
lvi.iItem = j++;
lvi.iSubItem = 0;
lvi.pszText = (LPTSTR)(LPCTSTR) dateinfo["created"].c_str ();
m_listDate.InsertItem (&lvi);
} I've checked the lvi.pszText attribute of the LV_ITEM struct and it contains the string right before the call to CListCrtl.InsertItem .
Any ideas as to why blank strings are being added? Any help is much appreciated.
Thanks
- monrobot13
|
|
|
|
|
A quick addition to the stuff above. As you probably guessed I'm using the CListCtrl in report mode but if I use it in list mode and just use CListCtrl::InsertItem (int nItem, LPCTSTR lpszItem) the text inserts fine but it isn't one long list which is what I need. Just thought I'd let you all know that. As well if anyone knows a way to make a CListCtrl in list mode just have one long list (instead of scrolling sideways) I could just do that instead.
Thanks again.
- monrobot13
|
|
|
|
|
|
ARGH! Nope, I didn't even think of it. If I set the style not to have column headers will I still need to add the column? I only ask because I did set it to have no column headers and it still wouldn't work.
Thanks Again!
- monrobot13
|
|
|
|
|
monrobot13 wrote:
If I set the style not to have column headers will I still need to add the column?
Yes, without columns there's no place for the list to display any data.
--Mike--
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Alright, thanks for the help Mike.
- monrobot13
|
|
|
|
|
hello!
i want to read a .txt file after i clicked a button in a dialogbased mfc-program.
can somebody give me an example code or links or tipps?
somebody gave me a short overview (here in this forum), but i make mistakes and don´t understand everything.
The overview:
create an ifstream object
call open
set file pointer to end using seekg
call tellg to get the number of bytes in the file
allocate that number of chars
set file pointer to beginning using seekg
call read
call close
Thanks
Sunny
|
|
|
|
|
If you're using MFC then it is easier to use CFile or CStdioFile to read the contents of a txt file.
CFile file("C:\\foo.txt", CFile::modeRead);
file.Read(...)
Make sure to check for any errors.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
thanks for your reply.
i tried your idea, but what must i write behind the file.read(..??..).
i read inside the help: read(void* lpBuf, UINT nCount).
i tried several things, like file.read(*buffer, 50), file.read(buffer, 50), etc...
but each time it was wrong.
where is my error?
sunny
|
|
|
|
|
I do it like this..
CString strBuff;
CFile file;
if(file.Open(_T("anyfile.dat"),CFile::modeRead))
{
char cBuf[2048];
UINT uBytesRead;
while(uBytesRead = file.Read(cBuf, sizeof(cBuf)-1))
{
cBuf[uBytesRead] = NULL;
strBuff += CString(cBuf);
}
file.Close();
...
}
else
{
}
Hope it helps
Rob
|
|
|
|
|
COOL, thank you very much!
now, i have another question:
my .txt looks like that:
1 2 3 4 10
4 6 23 11 66
my problem is, i don´t know the number of rows and columns. do you (or somebody else) know, how i can find that out inside the program?
Sunny
|
|
|
|
|
That would depend on what constitutes a column and a row, however the following would probably work.
each column is seperated by a space character ASCII (32) and each row is seperated by a carriage return (13) line feed (10).
Iterate your buffer and look for these characters and add a counter to track them, whola!!! You've calculated number of columns and rows...
p.s-This kinda sounds like a school project.
"No more answer for U" - Word Nazi
Cheers
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
hi!
what do you mean with Iterate your buffer and look for these characters ? How can I do that?
it sounds like a school project but i finished school.
it`s a project for personal use, only. but at the moment i have no idea´s in this field of reading txt files.
thanks for everything
sunny
|
|
|
|
|
Iterate = repeat a task
buffer = temporary storage
You loaded your file into a CString buffer successfully and now it's time to iterate the characters in your buffer and count the CRLF and SPACE characters.
CFile myFile("myfile.txt", CFile::modeRead);
UINT nFileLen = myFile.GetLength();
const unsigned char* pTemp = new char[nFileLen+1];
memset(pTemp, 0, nFileLen+1);
myFile.Read(pTemp, nFileLen);
CString buff=pTemp;
for(int i=0; i<buff.GetLength(); i++){
if(buff.GetAt(i)==32)
nColumnCount++;
else if(buff.GetAt(i)==13 && buff.GetAt(i+1)==10)
nRowCount++;
}
delete[] pTemp;
Should give you rough idea as to how things are done
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
For some time now i been working on c++ and i just got to the point where i cant find anything on the subject i need.
Here is the problem
I want to add a command to the general contexmenue "the one when you right click on some file.some_extiention" Like winrar or winzip has it. the problem is that i don't want it just for some particular file exetion but for all extensions whenever it has an extension or not.
Like the open command,open with or the sendto command. Puting an enty on each file extension is not a solution so where do i find any exemples or help on this.
Thank you.
|
|
|
|
|
|
How can I tell the MFC CDialog class not to create the empty CControlBar* m_pWndEmptyCB under Embedded Visual C++ 3.0.
Is there any WS_??? or WS_EX_??? flag to tell the CDialog class with ModifyStyleEx not to create this empty CControlBar ?
--
Nice greets, Daniel.
|
|
|
|
|
Hi.
I would like to know what are some recommended advanced C++ book for both design and implementation including STL? I began learning C++ over a year ago and have been fasinated by C++ and its powerful OOP paradign since that time. I have studied these pure books.
- C++ How to Program by Deitel&Deitel
- The C++ Standard Library: A Tutorial and Reference
by Nicolai M. Josuttis
- Accelerated C++: Practical Programming by Example
by Andrew Koenig, Barbara E. Moo
- The C++ Programming Language (Special 3rd Edition)
by Bjarne Stroustrup
I am looking into books:
- Exceptional C++
- More Exceptional C++, Effective STL: 50 Specific Ways to Improve Your Use of the Standard Template Library
- More Effective C++: 35 New Ways to Improve Your Programs and Designs
Thanks,
Kuphryn
|
|
|
|
|
Advanced C++ - Coplien
This book goes over many of the advanced idioms and design strategies that you can achieve using C++. Some of the things presented in here are old hat like reference counting (at least if you are familiar with COM). Other techniques are new and point out techniques that you do not think of every day.
There is a good apendix in Rector/Sells book ATL Internals for templates. The appendix goes over basic templates, then it describes how ATL is able to accomplish some of the amazing things that it does. I have used a few of these techniques myself. I think this is definetly worth checking out.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
|
The best place I can come to think of to find out about this FAQ is comp.lang.c++.moderated. Try searching it from groups.google.com and I'm sure you'll find answers from the best there is.
|
|
|
|