|
U can make use of the function GetCurSel() to get the current selected item index. Now you can use GetText(index,string) to get the selected item text into the string. Set the retrieved string into the Edit box using SeWindowText().
|
|
|
|
|
my code
const int sz=100;
char buf[sz];
CString LString;
m_AListCtrl.ResetContent();
CString Filename = "C:\\Documents and Settings\\Owner\\list.txt";
ifstream ListFile( Filename );
while( ListFile.get ( buf,sz ) )
{
ListFile.get();
LString = (LPCSTR)buf;
m_AListCtrl.AddString(LString);
}
the problem is it doesnt read my last Line in the Text
(my Text's Form)
xxxx
yyyyy
zz
iiii
...
|
|
|
|
|
I took your snippet as is and ran it against a notepad file with 4 lines of text.
It populated the ListBox with all 4 lines even if I removed the last newline. Not sure what might be different on yours. Was your list.txt file created manually with notepad?
|
|
|
|
|
no a previous function create it/Edit it
if (file.Open(sFilePath,CFile::modeReadWrite|CFile::modeNoTruncate|CFile::modeCreate))
{
CString str = "\n"+Filetitle+".mp3";
file.SeekToEnd();
file.WriteString(str);
file.Close();
}
|
|
|
|
|
call these two functions like so (adjust the filepath)... (This appears to work)
PerformTask();
PerformTask2();
void CTestfileDlg::PerformTask()
{
CString sFilePath="c:\\temp\\list.txt";
CStdioFile file;
CString sOutput="0000000000111111111122222222223333333333444444444455";
int nCount=sOutput.GetLength();
try {
if (file.Open(sFilePath,CFile::modeReadWrite|CFile::modeCreate)) {
for (int i=0;i<nCount;i+=10) {
file.WriteString(sOutput.Mid(i,10)+"\r\n"); // Append text
}
file.Close();
}
}
catch (CException * e) {
e->ReportError(); // Popup description of exception
e->Delete(); // Clean up.
}
catch (...) { // Catch any other exceptions
AfxMessageBox("Failed to open file!");
}
}
void CTestfileDlg::PerformTask2()
{
const int sz=100;
char buf[sz];
CString LString;
m_AListCtrl.ResetContent();
CString Filename = "C:\\temp\\list.txt";
ifstream ListFile( Filename );
while( ListFile.get ( buf,sz ) )
{
ListFile.get();
LString = (LPCSTR)buf;
m_AListCtrl.AddString(LString);
}
}
-- modified at 1:41 Tuesday 30th May, 2006
|
|
|
|
|
|
i got 1 function OnButton();
(1) Upload file
(2) Download list
(3) write file list (update with new filename)
(4) Upload updated list
and while i can see (with my eyes) that list got one more line my reader cant see that
|
|
|
|
|
We are using the XListCtrl from code project and would like to have multiple lines in a column for tool tips. I have tried \r\n and I have looked at some other information in code project and else where. When a particular row/column has the mouse over it to have a tool tip appear but possible have multiple lines. the lines could be 80+ characters if we could. Could someone point me to a simple and quick solution?
thank you
|
|
|
|
|
I use "\n" for a newline in balloon tooltips. Not sure if this works for standard but I thought I'd post it in case you hadn't tried it yet.
-- modified at 23:54 Monday 29th May, 2006
I just verified that it works for both types of tooltip...
m_ToolTip.Create(this,TTS_BALLOON); // Balloon
m_ToolTip.Create(this); //for no balloon
|
|
|
|
|
bob16972 wrote: Not sure if this works for standard but I thought I'd post it in case you hadn't tried it yet.
its not working!!!
SaRath
"D on't blindly follow rules you read somewhere without verifying that it makes sense for your situation!"
|
|
|
|
|
What does the XListCtrl use for it's tooltips? I would have guessed it used CToolTipCtrl internally but I guess not.
Sorry about the misinformation then. That'll teach me to make assumptions.
|
|
|
|
|
bob16972 wrote: What does the XListCtrl use for it's tooltips?
In XListCtrl too it has normal tool tip, ther is no tool wrapped text inside the tooltip. I have tried in XListCtrl too by putting "\n" and "\r\n" to make the text wrap. but I failed to do that
SaRath
"D on't blindly follow rules you read somewhere without verifying that it makes sense for your situation!"
|
|
|
|
|
I have a Check Box and a OnTimer
while i run my application , when i press the Check Box it get the TRUE (looks as checked) but after 2 sec (OnTimer tick) it is become unchecked (FALSE)
Any way to avoid that?
|
|
|
|
|
What I guess is that you have called the funtion
UpdateData in the OnTimer funtion.
check for that.
Regards
Anil
|
|
|
|
|
hmm...I think so...
|
|
|
|
|
Immunity18 wrote: hen i press the Check Box it get the TRUE (looks as checked) but after 2 sec (OnTimer tick) it is become unchecked (FALSE)
Handle On CLick Event on The CheckBox and Call UpdateDate(TRUE);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I beg your pardon in advance for asking such a question.
How do I save the contents of the Rich Edit View that a user types? Is there a variable that holds this information or do I have to create it - if so how?
Also, how do I send text out to the Rich Edit View? I tried to get a Device Context then use dc.TextOut(...) but it didn't work. Any ideas?
Thanks in advance,
BP
-- modified at 17:33 Monday 29th May, 2006
|
|
|
|
|
|
Hi all,
suppose I have a XML that is represented by the following string:
<tag a="1" b="2">
notice this xml doesn't have the regular xml header ( the tag that begins with <xlms=...>)
if i call the IXMLDOMDocument method loadXML, it fails...i think it is because the string lacks the tag <xmls...>... i heard there is a propery of IXMLDOMDocument i can set that it won't need the tag <xmls..>...but i don't know what it is
can some1 help?
thanks in advanced
Yaron
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
Hi
The LoadXML funtion fails if the XML is having error. In your case there is no end to the tag you provide.
Load any one of <tag a="1" b="2"></tag> or <tag a="1" b="2"/> and hope you won't have problem; though I haven't tested it myself.
Regards
Anil
-- modified at 20:21 Monday 29th May, 2006
|
|
|
|
|
i do have a closure tag. that is not the problem....
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
Ok if this is the case I want to confirm one more thing.
Since you are using IXMLDOMDocument, have you initialize the pointer with statement like this?
SUCCEEDED (CoCreateInstance(CLSID_DOMDocument,
NULL,
CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument,
reinterpret_cast<void**>(&m_pDoc))));
m_pDoc->loadXML("<a></a>");
Regards
Anil
|
|
|
|
|
yes i did
i know there is a IXMLDOMParseErrorPtr object which i can get the error that has occurred but i can't seem to get it properly....
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
the bellow code working fine with me.
IXMLDOMDocument *m_pDoc;
m_pDoc = NULL;
if ( SUCCEEDED (CoCreateInstance(CLSID_DOMDocument,
NULL,
CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument,
reinterpret_cast<void**>(&m_pDoc))))
{
m_pDoc->loadXML("<a></a>");
}
and also the bellow code
{
HRESULT hResult = E_FAIL;
long lErrorCode = E_FAIL;
IXMLDOMParseError *pXMLError = NULL;
if (SUCCEEDED(m_pDoc->get_parseError(&pXMLError))
&& SUCCEEDED(pXMLError->get_errorCode(&lErrorCode))
&& ( lErrorCode != 0 ) )
{
// do some error report procedure
}
//
// Clean-up pointers used.
//
if ( pXMLError )
{
pXMLError->Release();
pXMLError = NULL;
}
//
// Pass back the return code.
//
return lErrorCode;
}
Regards
Anil
|
|
|
|
|
YaronNir wrote: i know there is a IXMLDOMParseErrorPtr object which i can get the error that has occurred but i can't seem to get it properly....
What is the error?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|