|
You cannot put a int variable directly in a AfxMessageBox() function like in VB.If you want to show the count in message box, modify as follows
CString csCount;
csCount.Format( _T("%d"), count );
AfxMessageBox( csCount );
|
|
|
|
|
Thanks..it worked now...Now how to copy the files?
I have to copy all files from "D:\mframes" to "D:\new"
Have declared both as below.
mframes is declared as such to copy all files in it.
CString file="D:\\mframes\\*.*"; <br />
CString next="D:\\new";
|
|
|
|
|
CFileFind f;
CString file="D:\\mframes\\*.*";
CString next="D:\\new\\";
BOOL bFound = f.FindFile(file);
while( bFound )
{
bFound = f.FindNextFile();
if( !f.IsDirectory())
{
CString csFilePath = f.GetFilePath();
CString csNewPath = next + f.GetFileName();
CopyFile( csFilePath, csNewPath, TRUE );
}
}
|
|
|
|
|
Count is one more than the actual and the fioles are not copied to d:\new.rather they are just copied to d:\
|
|
|
|
|
ok. Debug and find the cause...
BTW did you notice the "\\" in the end of line CString next="D:\\new\\"; in the above post?
|
|
|
|
|
|
yea..now it gets copied to d:new.
Here i have already specified the folders.what if i want to check whether the directory i am going to create exists?
|
|
|
|
|
|
Gives an error "'PathFileExists' : undeclared identifier"
|
|
|
|
|
projectip wrote: Now how to copy the files?
I have to copy all files from "D:\mframes" to "D:\new"
As has already been mentioned, use SHFileOperation() .
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
There is an example in this MSDN page[^] which might help you.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
I have created an MFC application in Visual Studio.
I have x and y values to be plotted for the graph which will display a curve.
I have no idea at all how to draw a graph in VS.
Is there any free tool, a fast and easy method I can incorporate into my application?
I just want to display a simple graph.
Ema
|
|
|
|
|
|
I want to send a string between 2 dialog. So I try to use SendMessage() with WM_COPYDATA message
Here is the code in send dialog
COPYDATASTRUCT cds;
....
::SendMessage(hWnd, WM_COPYDATA, (WPARAM) m_hWnd, (LPARAM) &cds );
And receive dialog code:
BEGIN_MESSAGE_MAP(RcvDlg, CDialog)
.....
ON_WM_COPYDATA()
END_MESSAGE_MAP()
BOOL RcvDlg::OnCopyData(){
...
}
It works, but while sending messeage, it locks the send dialog. So I want to change to another way, PostMessage. But I don't know how to implement. I tried to look on the internet, but cannot find what I want.
Can anyone help me? Thanks in advance,
|
|
|
|
|
Don't you see the following comments just below the help of WM_COPYDATA in MSDN[^]
An application must use the SendMessage function to send this message, not the PostMessage function.
|
|
|
|
|
oh, that's why I wasn't success.
thank you very much, Naveen.
So this means that when dialog A sends a string message to dialog B, it must be locked until receive the reply.
Is it correct??
|
|
|
|
|
tataxin wrote: So this means that when dialog A sends a string message to dialog B, it must be locked until receive the reply.
Is it correct??
Yes.
|
|
|
|
|
|
|
tataxin wrote: It works, but while sending messeage, it locks the send dialog.
Since SendMessage is blocking call, it will return only after the WM_COPYMESSAGE handler returns. So don't do any heavy processing in your WM_COPYMESSAGE handler. The best method is copy the data and trigger the processing in another thread so that the handler can return immediately.
tataxin wrote: It works, but while sending messeage, it locks the send dialog. So I want to change to another way, PostMessage.
You should not use PostMessage for WM_COPYDATA , since its asynchronous.
This article might be helpful - http://www.codeguru.com/cpp/w-p/win32/article.php/c1429/[^]
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
thank you everyone, I will do like that
|
|
|
|
|
You need a class that handles the post msgs....
void FACTORY::addWindow(HWND hWnd)
{
m_Windows.push_back(hWnd);
}
thus, regsiter all the windows with this class with the function above. (FACTORY::instance().addWindow(m_hWnd);)
then, you send these messages to the different classes that registered to this via the PostMessage function....
void FACTORY::PostMessage(UINT Msg, WPARAM wParam, LPARAM lParam)
{
list<HWND>::iterator i;
int count = 0;
HWND hWnd;
for( i = m_Windows.begin(); i != m_Windows.end(); i++)
{
hWnd = *i;
::PostMessage(hWnd, Msg, wParam, lParam);
}
} Then simply post the message and catch it in the class....
FACTORY::instance().PostMessage(THE_MESSAGE, (long)VAL1, (long)VAL2);
and "catch" it in you PretranslateMessage functions....
if(pMsg->message == THE_MESSAGE)
then get the vals...
int VAL1 = (long)pMsg->wParam;
int VAL2 = (long)pMsg->lParam;
OR SOMETHING LIKE THAT....
modified on Tuesday, June 24, 2008 3:04 AM
|
|
|
|
|
Thank you, bonkers. I just wonder if the receive dialog can get a string message ("Hello" for example) by this way?
|
|
|
|
|
Hey there - what happens when someone creates a class:
class empty{
};
I know there are the four member functions that would be created - constructor, destructor, assignment and copy.
but what else?
I was asked this in an interview and confidently replied with the four functions above - only to be told that really knowledgable C++ folks would be able to name anywhere between 6 - 9 things.
Any other answers out there? I've looked online and in all my c++ books.
Thanks!
|
|
|
|
|
dd314159 wrote: Any other answers out there?
The compiler might also create address-of operators. That said, these (five) items don't always get created, only when they are needed.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|