|
kcynic wrote: I only pass a thread point which was create and start in the parent dialog.
What do you mean by "passing a thread point"?
Are you, or are you not, using multiple threads?
You'd better post some code snippets showing how you create your dialogs as well.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Oh,I had usint the example [^]" rel="nofollow"> [^][ [^]">^]you send to me somedays before,and I also sent a e-mail to you of my problem of testing such example.I have pass the CClientThread point between some dialogs.
|
|
|
|
|
Ok, so you've used Newcomer's example as starting point.
As I understand it, you're passing the CClientThread pointer between dialogs. I don't see why though... You have to explain this because this could be part of your problem.
When I asked about some code snippets I wasn't joking; it's impossible to help you further if you don't show what you've done so far. It should be sufficient with the code that creates the dialogs.
For some reason I feel like your dialogs are created in the threads that contains the sockets. This is not a good thing for many reasons. You should post messages to the main thread to do this stuff so that the main window is the parent for your dialogs.
By the way:
I haven't received any mail from you regarding your problems and even if I did I would would have informed you not to post to me, or anyone on the boards, directly.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Yes,you are right,I did really using the example and passed CClientThread pointer between dialogs.
And it worked well at begining.But when it is connected with the server,I want to pass the connection to other dialogs and keep it active and no-recreated.What should I do?
Thanks.
|
|
|
|
|
I passed the thread like this:
parentDialog::function()
{
CThirdDlg* dlg=new CThirdDlg(this);
m_pClientThread->SetTarget(dlg);
m_pClientThread->m_socket.SetTarget(dlg);
...//other initializing
dlg->Create(IDD_MYDIALOG,this);
dlg->ShowDialog(TRUE);//i didn't know why it didn't show itself if no such code.
}
|
|
|
|
|
kcynic wrote: m_pClientThread->m_socket.SetTarget(dlg);
This implies that you've modified the original source code that Newcomer wrote since the m_socket member was originally protected and the above would generate a compiler error if it still is. So you "fixed" the compiler error by making the member publicly declared instead.
The bad news is that you've made this change to the original code in order to use it in a way it wasn't intended.
The design that Newcomer made is built on the idea that each socket informs the main window/thread about things of interest, such as when the socket thread has started and when the user has to be notified for some reason. You should not brake this design.
When the socket thread needs to notify the main window, it posts a user defined message to it. This is what the target member is for. Changing the target to a "temporary" window while the thread is running will create various race conditions that eventually will lead to the ASSERT you got. This may happen since at some point the socket thread will try to post a message to a window that doesn't exist any longer or for some other obscure reason. You may find the reason if you follow Naveen.R's advice about the call stack. You will probably find a call to CWnd::PostMessage() or CWnd::SendMessage() in the call stack in a socket thread.
What you should do is keep the design and let the main window be the "information collector". If you want to create other windows, they could register themselves as observers to the main window so the main window can inform them about events of interest.
But whatever you do you cannot change the "target" window after the socket thread has been allowed to start.
I guess it boils down to a question about design.
What are your dialog windows supposed to do?
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Here,I want the client connect the sever using translate its username and password in the login dialog.When the server checked the user account correct, the server would return a success flag to the client,then,the client create the second dialog. Others who using the likely second dialog would send messages to it and it also cound return messages to the others.
There also would create the third dialog and translate messages each other.
But all the clients should keep connected to the server and doesn't create second connect. I have no idea to resolve such problems.
I had done such things by changing the m_socket from protected to public as you said. Since there will be some wrong way,I could not know how to do,now.
Thanks
|
|
|
|
|
kcynic wrote: I want the client connect the sever using translate its username and password in the login dialog.
When you've received the request for authentication in the main window, you should pop up a modal dialog asking the user for login information, i.e. user name and password. This means that the main window is the parent of the "login dialog" and the dialog itself doesn't need to have a connection; it simply takes some user input that the main window can get when the dialog is dismissed by the user. The login information should then be sent by the socket thread by the main window in order to reach the server for authentication.
kcynic wrote: There also would create the third dialog and translate messages each other.
I don't really understand the point of this third dialog.
In Newcomer's example there is a control that displays the data sent and received. Does the third dialog substitute this control?
If the answer is 'yes' I suggest you create the third dialog modeless and put the information there from the main window, keeping the main window as "information collector".
kcynic wrote: But all the clients should keep connected to the server and doesn't create second connect. I have no idea to resolve such problems.
If you by "all clients" mean "all your windows", you don't need more than one connection. Simply let the main window be the central point that gathers the information and reacts to it, dispatching the information to other windows if needed.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
And the theApp is the main thread.But if I pass messages to it,how to retrieve returns from theApp?
|
|
|
|
|
how to insert a picture control in following article :::
http://www.codeproject.com/directx/LiveVideo.asp?df=100&forumid=50103&fr=26
i wanna know the steps...
NT
|
|
|
|
|
tyagineha wrote: i wanna know the steps...
You could always download the source code from the article - I bet the steps are there
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Mark Salsbery wrote: You could always download the source code from the article - I bet the steps are there
I think yes but if we always have source code.;)
|
|
|
|
|
Can u tell me the link........
NT
|
|
|
|
|
I got the link from you
The Link[^]
Look for the "Download source files" link at the top of the article.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
It can be done with GetExtendedXXXTable functions of IPHelper API , but i cannot use under Windows2000 , i only have GetXXXTable for it but they dont give me process ids , i mean i want to learn which processes do any thing on tcp/udp ports in Win2000. How can it be done like TCPView on Pre-XP Systems ?
Thank you very much...
|
|
|
|
|
Hi,
I have a for loop, which executes for 100 times. I want to skip initial 50 iterations, and from 51st iteration, I want to execute the code statement by statement.
Please suggest, if any easy method is there.
Thanks and regards,
Raja Pratap
|
|
|
|
|
|
I want to debug using the visual studio debugger. Meaning using F9 and F10..etc mechanism.
I meant to ask, if there is some way to iterate for 'n' many times in a particular loop.
|
|
|
|
|
Raj Prathap wrote: I meant to ask, if there is some way to iterate for 'n' many times in a particular loop.
I see ... well Naveen solotion should work
Regrads
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
you can put a conditional break point. To do this follow this steps
eg
for( int nIdx =0;nIdx<100;nIdx++)
{
...
}
1. Put a break point in the next line after for loop.
2. Take the breakpoint window( uner the edit menu or press ctr + B )
3. select the break point you put in the for loop
4. Press the "condition" button.
5. In the new dialog box apperared enter put nIdx>=50
|
|
|
|
|
Thanks, that solved my problem
|
|
|
|
|
Naveen.R wrote: eg
for( int nIdx =0;nIdx<100;nIdx++)
{
...
}
1. Put a break point in the next line after for loop.
2. Take the breakpoint window( uner the edit menu or press ctr + B )
3. select the break point you put in the for loop
4. Press the "condition" button.
5. In the new dialog box apperared enter put nIdx>=50
Another suggestion is...
#ifdef _DEBUG
#define DBREAK( condition ) if(( condition )){ _asm int 3; }
#else
#define DBREAK( condition )
#endif
for( int nIndex = 0; nIndex < 100; ++nIndex )
{
DBREAK( nIndex == 50 )
}
|
|
|
|
|
Hi all
Let me explain my requirement.
I want to create a Activex control which has two methods SetPicture() and GetPicture().
SetPicture(VARIANT data) should copy the contents of the data to the clipboard and VARIANT GetPicture should return the contents of the clipboard. I know how to manage clipboard.
But I dont know how to manage the VARIANT to hold the bitmap. Could anyone point me to a good resource or spare time to tell me how to accomplish this.
Regards
The Best Religion is Science.
Once you understand it, you will know God.
|
|
|
|
|
Zainu wrote: SetPicture(VARIANT data) should copy the contents of the data to the clipboard and VARIANT GetPicture should return the contents of the clipboard
Since you need to pass the bitmap between the same process, it better to pass the handle of the bitmap to and from the active-x.
Other option is to pass the bitmap's pixel data. i.e retrive the pixel data. set the pointer of the bits array to the VARIANT object then pass it. The activex should again covert this pixel data to bitmap.
I think the first one is simple.
|
|
|
|
|
Thankyou
If I want to pass the handle of the bitmap what should be the type of the VARIANT?
Regards
The Best Religion is Science.
Once you understand it, you will know God.
|
|
|
|