|
Im not sure its helpful for you or no but you can see an example of david crow about resources
|
|
|
|
|
Hi,
I have a cdialog window which contains a webbrowser activex control. I want to be able to select some text from a control on the dialog (but not inside the webbrowser), and drag it into a textarea element within the webbrowser control. How do I do this? Can someone point me in the right direction?
Thanks,
derek
|
|
|
|
|
Hi there,
I have an application that uses TCP/IP socket connection to another application and I was wondering how I can check if the connection is up or not in the other word I need to notify a 3rd application if the connection between the first two has droped for any reasons. I tested today that if I am connecting to the second application that sits in another computer and I turn off the wireless connection button on the second computer so that the connection would be dropped, when I run the netstat command in dos command window, it shows that the connection is still up and my application does not recognises that the connection is actually dropped until I physically close the second application.
Could any one inform me that how these things work and how can I make my application underestands that the connection between the sockets is dropped do to wireless or network problem and so on?
I really appreciate any suggestions.
Best reagards,
Nahi
|
|
|
|
|
What state is the connection in (according to netstat)? CLOSE_WAIT?
When the connection drops, recv() will either return 0 or SOCKET_ERROR (WSAGetLastError() will get
the error code) - I can't remember which right off hand (brain in screen-saver mode). Either
way, when you get an error on send() or recv() you can notify the 3rd application that the
connection dropped. A breakpoint right after a recv() call will show you which occurs when you
switch off the connection.
Lost connections will linger (you'll see them in netstat) until you officially close the socket or the
application. Therefore, when you detect the network down you should close the socket when unrecoverable
error codes are returned (they are listed in the send()/recv() API specs).
Hope this helps a little
Mark
|
|
|
|
|
Thanks for the tip, as I mentioned before when I disconnect the wireless network of the computer so that the connection ids dropped, netstat still shows that the connection is stablished!? until I close one of the application. and as my application should receive messages from the other application through the socket, I do not understand that the connection is down. Only when IN close the second application, I get the socket closed message and in netstat I can see close_wait.
Thanks,
|
|
|
|
|
Yes, you'll see the connection in netstat because the socket is still allocated even though it
may be disconnected physically. It will remain in CLOSE_WAIT (waiting for close as the name
implies) until you call closesocket(). Even after calling closesocket(), if there is/was pending
data on the connection it will "linger" by default for I think 120 seconds (so you'll see it in
netstat for that long). To force it to close immediately you can turn off the linger option for
the socket, something like:
linger Linger;
Linger.l_onoff = 1;
Linger.l_linger = 0;
::setsockopt(hSocket, SOL_SOCKET, SO_LINGER, (const char *)&Linger, sizeof(linger));
::closesocket(hSocket);
hSocket = INVALID_SOCKET;
|
|
|
|
|
Send a ping packet to the other IP address. If it doesnt come back, youknow the link is dead.
Truth is the subjection of reality to an individuals perception
|
|
|
|
|
You could wait until the TCP/IP stack reports that the connection is down (can take very long). Alternatively send a small connection testing packet (e.g. smilar to IRC's PING/PONG mechnism), sometimes you will receive immediately an error saying that the connection is down... or you can timeout the connection if you haven't received a connection test packets from the other peer for a while.
[corrected typos]
|
|
|
|
|
Why does the mousewheel event not scroll the window in a CRichEditView?
Mark
|
|
|
|
|
CRichEditView class doesn't handle the WM_MOUSEWHEEL event.
You can derive a class from CRichEditView and handle it yourself.
Mark
|
|
|
|
|
It works on Win98 machines. Trying it on XP machines I find that the mouse wheel button doesn't scroll the view window. Anyway, I fixed it by handling the OnMouseWheel() event.
BOOL CMyEditView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
CRichEditCtrl & rc = GetRichEditCtrl();
if( zDelta < 0 )
rc.LineScroll(3, 0);
else
rc.LineScroll(-3, 0);
return CRichEditView::OnMouseWheel(nFlags, zDelta, pt);
}
-- modified at 21:19 Monday 23rd October, 2006
Mark
|
|
|
|
|
Mark F. wrote: It works on Win98 machines. Trying it on XP machines I find that the mouse wheel button doesn't scroll the view window.
Oh ok - At first I thought maybe different common controls library. Checked and it's feature
from Rich Edit 1.0 on.
All I can think of off hand is the control doesn't have focus. Does it still not scroll if you
click in the control somewhere then turn the wheel?
Mark
|
|
|
|
|
Which is the best to use? char*, vector or std::string
I'm searching for the best way to manipulate strings. I've historically used char* with strstr, strtok, etc. I've also used CStrings, but trying to get away from them.
I'm hoping to join the present and use containers whenever possible. I'm wondering if I can use a vector instead or is it best to use std::string.
I have to do all the standard string stuff, copying, searching, parsing, etc.
Ideas?
-C
|
|
|
|
|
That all depends on what you are doing. Use char* as little as possible. string is nice when you don't have to worry about multithreaded issues. If you are passing strings between threads, use vector<char> since it isn't reference counted.
For more descriptive details, check out Effective C++ and Effective STL by Scott Meyers.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Zac Howland wrote: since it isn't reference counted.
So how does that solve all the synchronization issues? Depending on the use-model you could create just as many problems using a vector.
led mike
|
|
|
|
|
led mike wrote: So how does that solve all the synchronization issues?
Reference counting is not multithreading-friendly by default Having said that, not all versions aof std::string are reference counted - for instance the Dinkumware one that ships with VC++ is not. Of course, relying on a particular internal implementation is generally a bad idea.
|
|
|
|
|
Nemanja Trifunovic wrote: for instance the Dinkumware one that ships with VC++ is not.
Last time I checked, it was. Link
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
led mike wrote: So how does that solve all the synchronization issues?
It doesn't solve all synchronization issues. STL isn't threadsafe, so you have to use protection around any access to it anyway, but there are issues with passing strings around. I can't remember all the details (and I don't have my copy of Effective STL with me at the moment to look it up) off the top of my head.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Zac Howland wrote: It doesn't solve all synchronization issues.
Ok, sorry my post was probably just stupid.
Zac Howland wrote: I can't remember all the details
This is not simply an oversight; current reference counted implementations may fail for
more complicated examples. They may fail even for s[1] == s[2] if the string s is simultaneously
examined (merely examined, not necessarily modified) by another thread.
SGI Reference[^]
led mike
|
|
|
|
|
|
If you are doing MFC (or want to include the specific headre) then use CString. Otherwise use the string template.
Truth is the subjection of reality to an individuals perception
|
|
|
|
|
How can i access CDialog class from antoher class
that declare in CDialog base application?
best regards,
M.J.M.
|
|
|
|
|
mostafa_pasha wrote: How can i access CDialog class...
Do you mean a CDialog -derived class?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
for example i have CMyFile that is generic class
(my project is CDialog base such as CMyDialog) how
can i access CMyDialog through CMyFile?
is that anyway that call CMyDialog's function from CMyFile
class?
Best regards.
M.J.M.
|
|
|
|
|
CMyFile::Method()
{
CMyDialog dlg;
dlg.DoModal();
}
?
--
Not a substitute for human interaction
|
|
|
|