|
|
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
|
|
|
|
|
|
dd314159 wrote:
I know there are the four member functions that would be created - constructor, destructor, assignment and copy.
but what else?
Not always. For instance, the compiler will provide constructor only if there are some virtual functions(to prepare vtable), or if any of the member variables have constructors. I strongly recommend you to read the book "Inside C++ Object Model". http://www.amazon.com/Inside-Object-Model-Stanley-Lippman/dp/0201834545[^]
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Thanks - this is just the type of book I've been looking for to know what's really going on.
|
|
|
|
|
This is my first post to this forum ,I am a self learnt c++ programmer,but now i am learning win32 api,and asm .In c++ i know linked list,oop,pointers,file handling(in dos mode).But now i am learning winsock in dos mode.But i have some problem .please guys can you help me.My client software is Win-Connect which is a in the project winsock.The code that i have written is :-
<br />
#include<windows.h>;<br />
#include<iostream>;<br />
int main()<br />
{<br />
WSAData wsadata;<br />
if(WSAStartup(MAKEWORD(2,0),&wsadata)!=0)<br />
{<br />
std::cout<<"1:)startup failed\n"<<WSAGetLastError();<br />
WSACleanup();<br />
return -1;<br />
}<br />
else<br />
{<br />
std::cout<<"2:)Socket Init Success\n"<<WSAGetLastError();<br />
}<br />
SOCKET mysock=socket(AF_INET,SOCK_STREAM,0); <br />
if(mysock==INVALID_SOCKET )<br />
{<br />
std::cout<<"3:)Socket Init Failed\n";<br />
WSACleanup();<br />
return -1;<br />
} <br />
<br />
else<br />
{<br />
std::cout<<"4:)Socket Init Success\n"; <br />
sockaddr_in sin;<br />
sin.sin_port=htons(80); <br />
sin.sin_addr.s_addr=inet_addr("127.0.0.1");<br />
sin.sin_family=AF_INET;<br />
if (connect(mysock,(sockaddr*)&sin,sizeof(sin))==SOCKET_ERROR)<br />
{std::cout<<"5:(Socket Init FAiled\n"<<WSAGetLastError();<br />
WSACleanup();<br />
return -1;<br />
}<br />
<br />
<br />
std::cout<<"connection sucessful";<br />
closesocket(mysock);<br />
<br />
return 0;<br />
} <br />
}</iostream></windows.h>
When i compile and run the code the dos windows flashes for a sceond and then goes away,so i have to run this programme from the commmand line
Like this D:\>Dev-Cpp\winsock.exe
My server software:-
#include<windows.h><br />
#include<iostream><br />
int main()<br />
{<br />
WSAData wsadata;<br />
if (WSAStartup(MAKEWORD(2,0),&wsadata)!=0)<br />
{std::cout<<;"winsock startup failed\n"<<WSAGetLastError();<br />
WSACleanup();<br />
return -1;<br />
}<br />
std::cout<<"winsock startup is succes\n";<br />
SOCKET servsock=socket(AF_INET,SOCK_STREAM,0);<br />
if(servsock ==INVALID_SOCKET)<br />
{std::cout<<"socket init failed\n";<br />
return -1;<br />
}<br />
std::cout<<"socket init\n"; <br />
sockaddr_in sin;<br />
sin.sin_port=htons(80);<br />
sin.sin_addr.s_addr=INADDR_ANY;<br />
sin.sin_family=AF_INET;<br />
if (bind(servsock,(sockaddr*)&sin,sizeof(sin))==SOCKET_ERROR)<br />
{std::cout<<"FAILED TO BIND"<<WSAGetLastError();<br />
WSACleanup();<br />
return -1;<br />
}<br />
std::cout<<"Bind successful!\n";<br />
WSACleanup();<br />
while (listen(servsock,SOMAXCONN)==SOCKET_ERROR);<br />
SOCKET client;<br />
int len = sizeof(sin);<br />
client=accept( servsock,(sockaddr*)&sin,&len);<br />
std::cout<<"Connection established!\n";<br />
closesocket(client);<br />
closesocket(servsock);<br />
WSACleanup();<br />
return 0;<br />
} </iostream></windows.h> When i run the software the dos windows shows "bind sucessful" but the dos windows stays there.it does not dissapear like the prevoius one
But the beginner tutorial from where i am learning said that the win-connect will display
"connection sucessful" and the win-listen will display "connection established"
when they are running at the same time .But i could not find a way to run two programmes from same compiler(by clicking on run).So i opened the the win-listen and ran the programme from the compiler((by clicking on run). and the win-connect from the command line.But i never got the required output "win-connect will display
connection sucessful and the win-listen will display connection established".So please please please can antbody tell me where i am going wrong .i am stuck with this code for 4 days, i will be really thankful whoever helps me out.And another thing is that when i am putting the socket in listening
mode:-while (listen(servsock,SOMAXCONN)==SOCKET_ERROR);
Should i keep the SOMAXCONN like this or i have to give a vaLUE LIKE 5 or 10
while (listen(servsock,10)==SOCKET_ERROR);
Please help me out brothers thank you
|
|
|
|
|
I don't know if you're trying to use UDP or TCP (the third argument in the socket() function determines this). IPPROTO_TCP or IPPROTO_UDP is what I usually use but I forget the #'s
Then, connect() is only really used with TCP sockets. UDP sockets need only bind() and then they're ready to...
sendto() is what you use with UDP, send() is for TCP, or your sockets can...
listen() is a function that returns whether or not your socket is ready to listen for data. It isn't a good one to use for an empty while loop, as it will likely not change, but...
accept() and recvdata() are functions that will return once a client has connected. One of these would be what you want to fill your while loop with. You have several errors in your programs, but they are close.
p.s.
for a freebie, go to books.google.com, search for the book
TCP/IP sockets in C and then search the book for "TCPEchoServer" and "TCPEchoClient" I think that is what you want exactly (pg 13 and pg18)
|
|
|
|
|