|
hello sir!!i am new to MFC programming and i am developing an FTP client. the code is as shown below. i call the same code when i first connect to the FTP server and the code does the directory listing successfully. but when i call the same code to refresh the directory listing, the code fails.. just see where i am doing the mistake..
//delete all items in the listCtrl
m_cListDir.DeleteAllItems();
try
{ CString pStrptr;
CString str;
BOOL nRC = pConnect->GetCurrentDirectory(pStrptr);
pStrptr.Format("%s is the current directory", pStrptr);
MessageBox(pStrptr, " Info", MB_OK);
// use a file find object to enumerate files
CFtpFileFind finder1(pConnect);
pConnect->SetCurrentDirectory(pStrptr);
BOOL bWorking = finder1.FindFile( _T("*"));
if(bWorking)
{
int i = 0;
CString str;
CTime time;
while (bWorking)
{
bWorking = finder1.FindNextFile();
//display the file name, file size and last modified in a listctrl box
str.Format("%u byte(s)",finder1.GetLength());
m_cListDir.InsertItem (i,((LPCTSTR) finder1.GetFileTitle()));
m_cListDir.SetItemText(i,1,(LPCSTR)str);
finder1.GetLastAccessTime(time);
str.Format("%d-%d-%d",time.GetDay(),time.GetMonth(), time.GetYear());
m_cListDir.SetItemText(i++,2,(LPCSTR)str);
}
}
else
{
CString str;
MessageBox("'/' is empty", "Info", MB_ICONINFORMATION);
str.Format("Error : %s", GetLastError());
MessageBox(str, "Error",MB_ICONERROR);
}
}
catch (CException* pEx)
{
TCHAR sz[1024];
pEx->GetErrorMessage(sz, 1024);
MessageBox("Cannot retrive the server drive information","ERROR!",MB_ICONERROR);
pEx->Delete();
}
vijay aroli
|
|
|
|
|
aroli vijay wrote: ...when refresh button is pressed, the directory listing fails.
Which means what exactly? Set a breakpoint in your code and narrow the problem down to just a few statements.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
hi!! thanks to everyone. the problem has been solved. i didnot close the find file object after enumerating all the files once. that was the cause for the problem. thanks to everyone
vijay aroli
|
|
|
|
|
I am looking for the most basic example of word automation. I have looked at all of them on this webiste and they are all too complex for me. All I need is couple of lines of code (no interface at all) on how to create a completely blank word file with the path specified by me (like c:\\myfile.doc). How can I do that??
Thanks in advance!
|
|
|
|
|
Search microsoft MSDN site for:
Q180616: HOWTO: Use Automation to Create & Show a PowerPoint Presentation
Q178784: HOWTO: Use Automation to Open and Print a Word 97 Document
Old articles, but easiest way. Searching for automate brings nice examples as well.
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
where can I find the msword.h file??
-- modified at 9:54 Friday 18th August, 2006
|
|
|
|
|
great_tommy wrote: where can I find the msword.h file??
It, along with a .cpp file, is created by ClassWizard when you import the type library.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
VC6.0
My Application: the same window explore
I cut 2 files in window explore, then in my application
I paste them there. How to know that:
1. 2 files are cutting
2. Path is exist
3. ListCtrl control: how to sort folders are top, files are bottom
Thanks
|
|
|
|
|
|
VC6.0
My Application: the same window explore
I cut 2 files in window explore, then in my application
I paste them there. How to know that:
1. 2 files are cutting
2. Path is exist
3. ListCtrl control: how to sort folders are top, files are bottom
Thanks
|
|
|
|
|
Hi,
plz tell me. how can i read excel sheet using visual c++ MFC.
i have write following code but it reads only three rows.
void CReadExcelDlg::OnButton1()
{
CDatabase database;
CString sSql;
CString sItem1, sItem2,sItem3;
CString sDriver;
CString sDsn;
CString sFile = "ReadExcel.xls"; // the file name. Could also be something like C:\\Sheets\\WhatDoIKnow.xls
// Clear the contents of the listbox
m_ctrlList.ResetContent();
sDriver = GetExcelDriver();
if( sDriver.IsEmpty() )
{
// Blast! We didn´t find that driver!
AfxMessageBox("No Excel ODBC driver found");
return;
}
sDsn.Format("ODBC;DRIVER={%s};DSN='';DBQ=%s",sDriver,sFile);
TRY
{
database.Open(NULL,false,false,sDsn);
CRecordset recset( &database );
sSql = "SELECT field_1, field_2 "
"FROM demo_table "
"ORDER BY field_1";
recset.Open(CRecordset::forwardOnly,sSql,CRecordset::readOnly);
while( !recset.IsEOF() )
{
// Read the result line
recset.GetFieldValue("field_1",sItem1);
recset.GetFieldValue("field_2",sItem2);
// recset.GetFieldValue("field_3",sItem3);
// Insert result into the list
m_ctrlList.AddString( sItem1 + " --> "+ sItem2 );
// Skip to the next resultline
recset.MoveNext();
}
// Close the database
database.Close();
}
CATCH(CDBException, e)
{
// A database exception occured. Pop out the details...
AfxMessageBox("Database error: "+e->m_strError);
}
END_CATCH;
}
////plz help me
|
|
|
|
|
kamlesh9873 wrote: how can i read excel sheet using visual c++ MFC
may be this[^] helps
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
kamlesh9873 wrote: ...but it reads only three rows.
Out of how many?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
It doesn't matter to me one way or the other, but I'm just curious why you'd repeat what _AnShUmAn_ did but to another site?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I wanted said to you ...and now I'm curious why you think its a repeat and i was wondered why you said it but when i see authors from these articles now I'm curious and wonder (one authors,one object) all things are same now i can say
|
|
|
|
|
As it happens I have just created a set of classes which is able to read Excel files without MFC, COM or even having to have excel stored on the machine. I found it to be some 1000% faster than convensional means.
I will make it public just as soon as I find the time to write a CP article. In the meantime if anybody is interested drop me a message.
|
|
|
|
|
I have a view derived from CListView.
In a button handler i wrote
CListCtrl &listCtl=GetListCtrl();<br />
for(int j =0 ;j<4;j++)<br />
listCtl.SetItemText(i,j,arr->GetAt(j))
arr is a CStrinArray. GetAt is returning the string right. and value of i is 1. And i have set 4 coulumns for the ListView.
But the SetItemText is always returning 0.
Can you please show me the reason.
Thank you
KIRAN PINJARLA
|
|
|
|
|
What is arr ?
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
it's a CStringArray, it's written in the original post.
|
|
|
|
|
Maximilien wrote: it's written in the original post
me tired. Thanks.
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
of course CStringArray *arr; and it seems to it has two for i,j but he writes a for
|
|
|
|
|
kiran.pinjarla wrote: and value of i is 1.
So you are wanting to change the second row, correct?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Just out of curiosity; Have you inserted any item in list control, before setting text? Or there are items present in control ?
kiran.pinjarla wrote: for(int j =0 ;j<4;j++)
initialize j with 1 and check.
|
|
|
|
|
Ok I got it. The Problem was i did not do InsertItem before going for InsertItemText. that was the problem.
Thank You.
KIRAN PINJARLA
|
|
|
|