|
|
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)
|
|
|
|
|
I think the problem may be the smiley faces scattered throughout the code.
Steve
|
|
|
|
|
Hello!
If I define a type, MyClass, for example, and do the following:
MyClass *pObj = new MyClass;
void *pv = pObj;
I know that I must NOT do something like this: delete pv;
because the destructor pObj->MyClass::~MyClass() will NOT be called.
But why does the destructor get called when I delete pObj;
because the operator delete function gets a void * as parameter. Isn't it the same problem?
I mean, how does the operator delete function "know" that pObj converted to void * is actually a MyClass object?
Thanks in advance!
|
|
|
|
|
Eikthrynir wrote: But why does the destructor get called when I delete pObj;
Because that's what happens when you use delete on an object.
Eikthrynir wrote: because the operator delete function gets a void * as parameter.
Destructors don't take arguments.
"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
|
|
|
|
|
Wow, I can barely read his post but yours is rated a '1'? Well, I'll just have to do something about that.
led mike
|
|
|
|
|
We're number one! We're number one!
"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
|
|
|
|
|
Eikthrynir wrote: But why does the destructor get called when I delete pObj;
The compiler does the job: it sees that you are calling delete on a MyClass object, so it supposes that it is a MyClass object and calls its destructor. If you delete a void pointer, the compiler only sees a void pointer.
|
|
|
|
|
Cedric Moonen wrote: so it supposes that it is a MyClass object
I reckon so.
led mike
|
|
|
|
|
Hi
I am using a DateTimePicker control, using the Time format
Is there anyway i can get the time to display without showing the seconds ?
thanks
Simon
|
|
|
|
|
I believe there is a way to set the format for the display of the control. You can just specify a format that does not show the seconds, perhaps?
Have a good look at the messages the control supports to see.
Note that the control's internal time value will still have a seconds component...
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
m_TimePicker.SetFormat(..... etc);
|
|
|
|
|
I have a program running as a service. I am using the IUpdateSearcher and IUpdateInstall interfaces. I can perform a WSUS search, find out what updates the computer needs and launch the update wizard. At this point I get the update wizard GUI, it will download the updates but then fails to install them.
In looking at the WindowsUpdate log I see error, 0x80240020, and in doing a web search I see a lot of people suggesting to update the SensLogn registry key. However when I check that key it is there and looks fine.
If I run my program from within the context of the user, we gave the program this capability also, then the update runs fine.
Has anyone run the runwizard GUI from within a service and had it work?
Thanks,
Bob
|
|
|
|
|
|
SetActivePage() seems like a good choice.
"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
|
|
|
|
|