|
-
January 4th, 2005, 08:25 PM
#1
MFC Bug or My Bug
I've written a very simple MFC Dialog Program
A dialog contain a OK Button and a edit control
then i write the following code
UINT TestThread(LPVOID lpParam)
{
CSocket s;
s.Create(0,SOCK_DGRAM);
while (1) {
//...
Sleep(1000);
}
}
void CTestDialog::OnOK()
{
AfxSocketInit(NULL);
AfxBeginThread(TestThread,0);
}
when the thread start, all things seems well, but when i want to shift another input method in the edit box, the mainthread is hang~
What's the problem in my code .
Any advice will be appreciate
-
January 4th, 2005, 09:05 PM
#2
Re: MFC Bug or My Bug
Call the AfxInitSocket() function only once in your CWinApp::InitInstance.
A.M.
My Latest Articles:
CCustomBitmapButton - An owner-draw button and a frame for the caption bar, in one class.
CCustomTabCtrl - A clone of the Excel tab sheet control.
-
January 4th, 2005, 09:13 PM
#3
Re: MFC Bug or My Bug
Also specify the lpszSockAddress (third parameter in Create function) as a pointer to a string containing the network address of the connected socket.
A.M.
My Latest Articles:
CCustomBitmapButton - An owner-draw button and a frame for the caption bar, in one class.
CCustomTabCtrl - A clone of the Excel tab sheet control.
-
January 4th, 2005, 10:28 PM
#4
Re: MFC Bug or My Bug
thanks amarcode, but i've try your way before, and the error still~
when i Replace all the CSocket Function with SOCKET function , the whole scenario work very well.
but it really a problem that confused me for 2 days . 
i think the core thing is:
when i use a MFC Class with MessageQueue in a Thread, Something happen but i do not know.
any new advice?
-
January 5th, 2005, 04:05 AM
#5
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|