|
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??
|
|
|
|
|
jdnx wrote:
but in other sites it will return some "." ".." dirs and lost some dirs.
Some OSs support the . and .. convention while others do not.
jdnx wrote:
...I called CInternetFile's GetLength Function but it can not return correct file length,also very strange...
Not all FTP software running on the server has implemented the "length" function.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
i have a error when i used function NetMessageBufferSend.These are "error LNK2001: unresolved external symbol _NetMessageBufferSend@20" and"fatal error LNK1120: 1 unresolved externals"
|
|
|
|
|
Hope you have not missed to link with Netapi32.lib
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
VC++2003: Question about "Pointers to member functions" ~~~ when the pointers are inside a struct data member of the class type.
I am using VC++ .NET 2003.
It is OK when the case as F1 in the sample code below. But it can not compile in the case as F2 in the thread in sample code below.
Any idea? Thanks!!
-----------------
class CMyLoopbackDlg : public CDialog
{
public:
afx_msg void OnBnClickedStart();
public:
void PutMsg(CString sTxt, bool bDbgOnly = false);
public:
CWinThread* m_pThTest;
void (CMyLoopbackDlg::*F1) (CString, bool);
struct InfoThTest
{
void (CMyLoopbackDlg::*F2) (CString, bool);
HANDLE hEvent_A;
HANDLE hEvent_B;
} m_InfoTest;
};
void CMyLoopbackDlg::OnBnClickedStart()
{
#define __CASE_STRUCT__ // The option switch here.
#ifndef __CASE_STRUCT__ // This case works well.
F1 = PutMsg;
(this->*F1) ("1: Using Ptr_to_member in Start().", false);
if(!m_pThTest) {
m_pThTest = AfxBeginThread(TestThreadProc, this);
}
#else
m_InfoTest.F2 = PutMsg;
(this->*m_InfoTest.F2) ("Struct: Using Ptr_to_member in Start().", false);
if(!m_pThTest) {
m_pThTest = AfxBeginThread(TestThreadProc, &m_InfoTest);
}
#endif // __CASE_STRUCT__
}
UINT TestThreadProc(LPVOID pParam)
{
#ifndef __CASE_STRUCT__
CMyLoopbackDlg& ref = *(CMyLoopbackDlg*)pParam;
ref.PutMsg("--> TestThreadProc ");
Sleep(5000);
ref.PutMsg("<-- TestThreadProc ");
#else
CMyLoopbackDlg::InfoThTest* pp = (CMyLoopbackDlg::InfoThTest*)pParam;
(pp->*F2) ("Test", false);
(*(pp->F2)) ("Test", false);
#endif // __CASE_STRUCT__
return 0;
}
Maxwell Chen
|
|
|
|
|
Hello,
Using heavy preprocessor switching like that greatly decreases code readability. It makes it very difficult to understand!
Anyway, I found your problem.
Take a deeper look at your following code section:
UINT TestThreadProc(LPVOID pParam)
{
#ifndef __CASE_STRUCT__
CMyLoopbackDlg& ref = *(CMyLoopbackDlg*)pParam;
ref.PutMsg("--> TestThreadProc ");
Sleep(5000);
ref.PutMsg("<-- TestThreadProc ");
#else
CMyLoopbackDlg::InfoThTest* pp = (CMyLoopbackDlg::InfoThTest*)pParam; (pp->*F2) ("Test", false);
(*(pp->F2)) ("Test", false);
#endif // __CASE_STRUCT__
return 0;
}
What do we see here?
<list>CMyLoopbackDlg& ref = *(CMyLoopbackDlg*)pParam; Here you cast the parameter to an object of type CMyLoopBackDlg This is OK, since you passed the this pointer to the function.
CMyLoopbackDlg::InfoThTest* pp = (CMyLoopbackDlg::InfoThTest*)pParam; Here you cast the parameter to an object of type InfoThTest* . This is OK, since you passed a pointer to the member variable.
In the first case you call a member function and you pass the this pointer implicitly.
In the second case, your error is that you call a member function without the implicit this pointer. The compiler has no object that it can use to call the member function with! There are two solutions to this problem.
1: Make the member function static so it doesn't need the this pointer
2: Pass the this pointer as a member of the struct and cast that to the dialog type:
struct InfoThTest
{
void (CMyLoopbackDlg::*F2) (CString, bool);
CMyLoopBackDlg* pThis;
HANDLE hEvent_A;
HANDLE hEvent_B;
} m_InfoTest;
See the C++ Faq Why can't I use member functions as callbacks?[^] for more information.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Hello Bob, thanks for your reply!!
I live at Taipei (+8 timezone) and it is Saturday now. My PC at home does not have a VC++ at all. I will try your suggestions next Monday at office, and continue the discussion ...
Bob Stanneveld wrote:
Using heavy preprocessor switching like that greatly decreases code readability. It makes it very difficult to understand!
That preprocessor switch was just seen in this demo only, in order to put two different methods in one single function body ( OnBnClickedStart() ) to post question on the forum. Otherwise people who play around with this sample code would have to alter some //'s (or /* */) instead of only one single line at:
#define __CASE_STRUCT__ // The option switch here.
I don't use it in my actual code. Sorry about that!
I do not quite remember / am not sure enough about this way failed also:
UINT TestThreadProc(LPVOID pParam)
{
CMyLoopbackDlg* pThis = (CMyLoopbackDlg*)pParam;
(pThis->*F1) ("Hello 123...", false);
return 0;
} Anyway, I'll be back next Monday!
-----------------
class CMyLoopbackDlg : public CDialog
{
public:
afx_msg void OnBnClickedStart();
public:
void PutMsg(CString sTxt, bool bDbgOnly = false);
public:
CWinThread* m_pThTest;
void (CMyLoopbackDlg::*F1) (CString, bool);
struct InfoThTest
{
void (CMyLoopbackDlg::*F2) (CString, bool);
HANDLE hEvent_A;
HANDLE hEvent_B;
} m_InfoTest;
};
void CMyLoopbackDlg::OnBnClickedStart()
{
#define __CASE_STRUCT__ // The option switch here.
#ifndef __CASE_STRUCT__ // This case works well.
F1 = PutMsg;
(this->*F1) ("1: Using Ptr_to_member in Start().", false);
if(!m_pThTest) {
m_pThTest = AfxBeginThread(TestThreadProc, this);
}
#else
m_InfoTest.F2 = PutMsg;
(this->*m_InfoTest.F2) ("Struct: Using Ptr_to_member in Start().", false);
if(!m_pThTest) {
m_pThTest = AfxBeginThread(TestThreadProc, &m_InfoTest);
}
#endif // __CASE_STRUCT__
}
UINT TestThreadProc(LPVOID pParam)
{
#ifndef __CASE_STRUCT__
CMyLoopbackDlg& ref = *(CMyLoopbackDlg*)pParam;
ref.PutMsg("--> TestThreadProc ");
Sleep(5000);
ref.PutMsg("<-- TestThreadProc ");
#else
CMyLoopbackDlg::InfoThTest* pp = (CMyLoopbackDlg::InfoThTest*)pParam;
(pp->*F2) ("Test", false);
(*(pp->F2)) ("Test", false);
#endif // __CASE_STRUCT__
return 0;
}
Maxwell Chen
|
|
|
|
|