Click here to Skip to main content
16,009,575 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How do you scroll text in a CEdit? Pin
Abin17-Mar-03 15:55
Abin17-Mar-03 15:55 
Generalto link the dialog box with window using mfc Pin
khb82110217-Mar-03 14:20
khb82110217-Mar-03 14:20 
GeneralDrawItem for CTreeCtrl Pin
Florin Ochiana17-Mar-03 12:58
Florin Ochiana17-Mar-03 12:58 
GeneralRe: DrawItem for CTreeCtrl Pin
Neville Franks17-Mar-03 17:47
Neville Franks17-Mar-03 17:47 
GeneralCAsyncSockets Pin
chrisedgington17-Mar-03 12:18
chrisedgington17-Mar-03 12:18 
GeneralRe: CAsyncSockets Pin
Florin Ochiana17-Mar-03 12:55
Florin Ochiana17-Mar-03 12:55 
GeneralRe: CAsyncSockets Pin
Moak18-Mar-03 1:40
Moak18-Mar-03 1:40 
GeneralRe: CAsyncSockets Pin
chrisedgington18-Mar-03 23:18
chrisedgington18-Mar-03 23:18 
Thanks for taking the time to reply. I have attempted to go through some of the other code that uses the Async sockets, but I can't seem to follow what's going on. If I want to use them, I need to be able to override the OnAccept() and OnSend() etc. member functions; but when are these called?
If I define my own class derived from CAsyncSocket and override the member functions, what is the order of events that must occur for these functions to work?
<br />
class Mysocket : public CAsyncSocket<br />
{<br />
public:<br />
virtual void OnAccept(int nErrorCode);<br />
virtual void OnClose(int nErrorCode);<br />
//OnSend, OnReceive, OnConnect here too<br />
}<br />
<br />
Mysocket::OnAccept(int nErrorCode)<br />
{ //when will it get to here?:confused:<br />
SleepEx(1000,FALSE); //just for illustration purposes<br />
CAsyncSocket::OnAccept(nErrorCode);<br />
}<br />

Say for instance that I have a function in an mfc document class that is meant to do the job of recieving, its code currently looks like this: (this code is what I have ported from a CSocket version which is why it looks a little funny)
<br />
int CAsyncItDoc::RecieveStuff()<br />
{<br />
int status =0;<br />
Mysocket Myskt;<br />
char theString[4096];<br />
if(Myskt.Create(5001) == 0) //create socket<br />
{<br />
status = Myskt.GetLastError();<br />
return status;<br />
}<br />
if(Myskt.Listen() == 0) //listen on socket<br />
{<br />
status = Myskt.GetLastError();<br />
return status;<br />
}<br />
Mysocket theRec; //new socket to pass call onto<br />
if(Myskt.Accept(theRec) == 0) //accept call (should this be here?):~ <br />
{<br />
status = Myskt.GetLastError();<br />
return status;<br />
}<br />
//////////////<br />
//this is the i/o bit -> should this be here?:~ <br />
ofstream outfile;<br />
outfile.open("igotthis.txt");<br />
while (theReciever.Receive(theString,4096) != 0)<br />
{<br />
outfile << theString <<endl;<br />
status++;<br />
}<br />
//////////////<br />
//tidy up-> maybe this should be in Onclose()?:~ <br />
outfile.close();<br />
Myskt.Close();<br />
return status;<br />
}<br />


I realise this sounds awfully lazy but some of the other code uses CDialogs which I've never used, and all the overridden member functions end up really long and complex. All I'm after is a simple implementation and at the moment all I have is a good way of getting confused.
Thanks for any (further) advice. Smile | :)
GeneralRe: CAsyncSockets Pin
Moak19-Mar-03 3:36
Moak19-Mar-03 3:36 
GeneralRe: CAsyncSockets Pin
chrisedgington19-Mar-03 4:31
chrisedgington19-Mar-03 4:31 
GeneralRe: CAsyncSockets Pin
Moak19-Mar-03 4:47
Moak19-Mar-03 4:47 
GeneralRe: CAsyncSockets Pin
chrisedgington19-Mar-03 4:58
chrisedgington19-Mar-03 4:58 
GeneralRe: CAsyncSockets Pin
Moak19-Mar-03 5:08
Moak19-Mar-03 5:08 
GeneralRe: CAsyncSockets Pin
chrisedgington19-Mar-03 6:07
chrisedgington19-Mar-03 6:07 
GeneralWin 32 Tooltip Pin
Anonymous17-Mar-03 12:18
Anonymous17-Mar-03 12:18 
GeneralRe: Win 32 Tooltip Pin
Neville Franks17-Mar-03 17:44
Neville Franks17-Mar-03 17:44 
GeneralRe: Win 32 Tooltip Pin
georgiek5017-Mar-03 22:46
georgiek5017-Mar-03 22:46 
GeneralRe: Win 32 Tooltip Pin
Neville Franks17-Mar-03 23:35
Neville Franks17-Mar-03 23:35 
GeneralRe: Win 32 Tooltip Pin
georgiek5018-Mar-03 1:28
georgiek5018-Mar-03 1:28 
GeneralReal quick question... Pin
CherezZaboro17-Mar-03 12:16
CherezZaboro17-Mar-03 12:16 
GeneralRe: Real quick question... Pin
_Theo_18-Mar-03 0:14
_Theo_18-Mar-03 0:14 
GeneralRe: Real quick question... Pin
Lakitu18-Mar-03 0:16
Lakitu18-Mar-03 0:16 
QuestionDisable overlay for a MCI window ? Pin
squizz17-Mar-03 11:41
squizz17-Mar-03 11:41 
QuestionOnItemChanged() - how to "reset" it? Pin
ns17-Mar-03 10:59
ns17-Mar-03 10:59 
AnswerRe: OnItemChanged() - how to "reset" it? Pin
Ravi Bhavnani17-Mar-03 11:11
professionalRavi Bhavnani17-Mar-03 11:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.