|
Start up a secondary thread that will call that function. Then call WaitForSingleObject() specifying 3000 for the timeout interval. If the return value is WAIT_TIMEOUT , then you know that the function is still running.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I actualy subclassing WinProc of ActiveX control. This is bad written control which I don't have source code. Now some times control recieve message from parent and opens socket connection. All my code freeze until ActiveX finish connection. I already make my own UI thread but still parent window calls child windows inluding activex directy via WinProc.
So I subclass ActiveX find bad message but I want timmed it. If it not done ReplyMessage(TRUE) and escape. I already tryied CallWinowsProc in sepparete worker thread. Doesn't help.
Thats my story.
Thanks for reply.
|
|
|
|
|
I gone through MSDN it mentioned that CSyncsocket can be used as blocking as well in nonbloicking i,e synchronous and asyncronous both where we can get event notification
while CSocket can used in only blocking mode i.e synchronous mode.
I am not getting this explanation.
Can anybody somebody clear this more briefly
|
|
|
|
|
blocking sockets are sockets that are waiting for datas to be incoming... while nothing came to the recipient, it is blocked...
Asynchronous sockets can set a timeout, that means that when no packets entered after a certain duration, the receive function passes to the next instruction...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Thanx TOXCCT.
Could u explain this in terms of CSOcket and CAsyncsocket
according to MSDN CSyncsocket returns WSAEWOULDBLOCK but not CSocket.
As CSocket derived from CAsynsocket why we wold not override OnRecieve and called recieve method as its vitual
i think i am confused abt this operation
Anyone have good link abt this ...
|
|
|
|
|
read up on how recv/connect/send/etc work.
The basics are that they all perform some work on a socket handle (like attempt to read data from it, connect to the address, etc). When the function returns it will return some error code. Typically the error code is 0, -1, or some value that indicates how many bytes were processed. A -1 value is generally an error. The difference in CSocket or CSyncsocket is whether the socket can be set to blocking mode. Blocking mode means that the functions (recv/connect/send/etc )will NOT return until the function is complete. So if you attempt to connect to a blocking socking using connect() (or whatever it's called on CSocket), the connect9) function will NOT return until a connection has been established. Likewise calling recv in blocking mode will mean that the recv() function will NOT return until it has been able to extract the specified number of bytes from the socket.
If, however, you are using NON blocking sockets, then the functions will return immediately, and the return code will be -1. But it's not neccessarily an error. You need to call WSAGetLastError() to determine this. If this returns WSAEWOULDBLOCK, then this means that function completed OK, and it's potentially going to complete later on.
Typically you create a socket, connect, set it's blocking mode, and then start trying to send/recv from it (assuming this is a client socket). With an asnych, or non blocking socket, you'll need to poll it from time to time to see if you can get any data from it. Polling can be done using a crude while loop, sleeping for X n umber of milliseconds, and then calling recv or send, or you can use the select() function to query if the socket is ready to be read from or written to. Alternately you can even fancier by using overlapped IO, and if you're a complete masochist, migraqte to the madness that is IO completion ports.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
Thanx JIM for information
Typically you create a socket, connect, set it's blocking mode
how we set the blocking mode for that.
|
|
|
|
|
look up ioctlsocket - this is a BSD style socket function and it operates on a valid socket handle. I don't know what the equivalent with CSocket would be. You might use it like so:
void setBlocking( SOCKET s, const bool& isBlockingSocket )
{
unsigned long val = isBlockingSocket ? 0 : 1;
int err = ioctlsocket( s, FIONBIO, &val );
if ( err == SOCKET_ERROR ) {
err = WSAGetLastError();
}
}
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
ok JIM i go through that
Thax for for your explaination
|
|
|
|
|
I need to implement conditional drop source, which will behave differently if drop target is in the same process as a source. I override OnRenderData but can not figureout how can I get to the Drag Target from there.
VC++ and MFC
Thanks
Edit: Sorry, I made a mistake in original post. I do need to know Target, Not a source. I do create a source myself.
|
|
|
|
|
I thought you set it when you start to drag
OnDrag(...)
|
|
|
|
|
Alex, you are right. I made a mistake in original post. I do need to know Target. I edit orignal post.
Thanks
|
|
|
|
|
Derive your own class CMyTree : CTree
CMyTree::OnCreate
{
//REGISTER THIS WINDOW AS AN OLE DROP TARGET.
m_DropTarget.Register(this);
}
where m_DropTarget
class CDropTarget : public COleDropTarget // make him friend in CMyTree
{
public:
virtual DROPEFFECT OnDragEnter(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
virtual DROPEFFECT OnDragOver(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
virtual BOOL OnDrop( CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point );
};
DROPEFFECT CDropTarget::OnDragEnter(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
{
return ((CMyTree*)pWnd)->OnDragEnter(pDataObject, dwKeyState, point);
}
DROPEFFECT CDropTarget::OnDragOver(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
{
return ((CMyTree*)pWnd)->OnDragOver(pDataObject, dwKeyState, point);
}
BOOL CDropTarget::OnDrop( CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point )
{
return ((CMyTree*)pWnd)->OnDrop(pDataObject, dropEffect, point);
}
and finaly
DROPEFFECT CMyTree::OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
{
if (pDataObject->IsDataAvailable(...))
{
UINT nFlags;
HTREEITEM hDropTarget = HitTest(point, &nFlags);
if(nFlags & TVHT_ONITEM)
{
SelectDropTarget(hDropTarget);
m_pTree->SelectDropTarget(hDropTarget);
// my custom message to my code process can I drop here or not
if(1 == GetOwner()->SendMessage(MYTW_CAN_DROP_HERE, 0, (LPARAM)hDropTarget))
return DROPEFFECT_MOVE;
else
return DROPEFFECT_NONE;
}
}
return DROPEFFECT_NONE;
}
Sorry if it lot. But this thing is not really obvious.
|
|
|
|
|
|
Hello!
My problem on C ++ is such:
In the program-text converter I use many times function Replace:
... <br />
if(m_bVocView) m_sReadFromFile.Replace(" # "," \r\n "); <br />
if(m_bVocView) m_sReadFromFile.Replace("\\\\ ","\r\n\r\n ");<br />
if(m_bVocView) m_sReadFromFile.Replace("\\ ","\r\n ");<br />
if(m_bVocView) m_sReadFromFile.Replace("\r\n~~~",""); <br />
....
As a result the program should read a file from the beginning up to the end many times. How to make all replacements on one fly?.. How to merge all this conditions into one single continuous and pretty program pass, for example:
if (m_bVocView) <br />
{<br />
if ("\\\\ ")<br />
{<br />
m_sReadFromFile.Replace("\\\\ ","\r\n\r\n ");<br />
if ("\\ ")<br />
{<br />
m_sReadFromFile.Replace("\\ ","\r\n ");<br />
}<br />
...
How to determine, that the string for replacements can be one, another, the third and based on these variants to proceed the demand to the program to make that or another replacement by one pass?.. How to joint all variants (which are not superimposed against each other) in one line-up?..
And the second part of this problem. To make replacements in a file I sequentially activate functions:
CreateFile
ReadFile
WriteFile
How to join all this functions onto one like as COPY or openURL? Is it possible to make replacements during function openURL for text file?..
|
|
|
|
|
fallologia wrote:
As a result the program should read a file from the beginning up to the end many times.
Why? Just read the file once into a CString variable, and then make the calls to Replace() .
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hi!
I've developed a client program in VS 2005 beta. in C++ / MFC. This works perfectly on the computer I develop on. However when I tried to run it on another computer ( that don't have VS 2005 installed ) I get:
"The requested section was not present in the activation context" error when launching the application. It is compiled in release mode.
Any ideas how to find what's wrong? I guess it's some dependency, but how do I find out what's missing?
|
|
|
|
|
the machine you're trying to run on don't have the right libraries... if you did program in MFC, you'll have to provide a file called something like mfc8xx.dll
doesn't the error code tell your more ?
moreover, what sort of resources do you reach by your code (servers or so) ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote:
the machine you're trying to run on don't have the right libraries... if you did program in MFC, you'll have to provide a file called something like mfc8xx.dll
That's what I thought...
I tried to copy the redistributable MFC-dlls. ( mfc80u.dll / mfc80.dll / mfcm80u.dll / mfcm80.dll ) and msvcrt.dll.
It did not help at all. The same error.
toxcct wrote:
doesn't the error code tell your more ?
I only get a dialog with this error message. No code or anything
toxcct wrote:
moreover, what sort of resources do you reach by your code (servers or so) ?
I communicate with a web server using CHttpConnection-class and the like. So should not be anything special?
I don't use any database or anythin like that either.
Thanks for the help! Got any more ideas?
|
|
|
|
|
To be certain change the MFC settings to static link rather than chared DLL.
Elaine
The tigress is here
|
|
|
|
|
Trollslayer wrote:
To be certain change the MFC settings to static link rather than chared DLL.
Thanks! That solved the problem!
|
|
|
|
|
Henrik Pettersson wrote:
That solved the problem!
Which indicates that not all required libraries were present on the target machine.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
There is a question very confusing to me
I studied from MSDN sample codes about CFtpFileFind Class
and I want to show all files(including directories) in one ftp site so I use such codes like
CFtpFileFind FF(...)
BOOL bCont=FF.FindFile(_T("*"));
if(bCont)
while(FF.GetNextFile())
{
//classify files or dirs and do different things;
//of course when meeting dirs do recursive proc;
}
But the result is that it can list all files and dirs in some ftp sites
but in other sites it will return some "." ".." dirs and lost some dirs.
I do not know why this happens,Please help
PS: When I wrote the ftp program,I called CInternetFile's GetLength Function but it can not return correct file length,also very strange,Can somebody Help,Thanks!!
|
|
|
|
|
I had problems with this as well when I was using this function. I figured out that apparently this function fails when there is a space in the name of file/directory. Check out for this.
Steve Mayfield: "Coding in VB is like riding a tricycle...once you figured out how to peddle, its really hard to fall off."
My Articles
|
|
|
|
|
First Thank you for help
Then If what you said is right,Does that mean using this method I can not deal with those files/dirs with a space in its name,No Alternative ways??
|
|
|
|