| | |
Separating socket code from GUI code
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2005
Posts: 69
Reputation:
Solved Threads: 0
This code is written in VC++.NET. I have a windows form that display data from a socket port using callbacks. I have main.cpp that calls Application::Run(new Form1). The socket processing code is currently in the Form's file. I want to separate the Form1 from the socket processing code. Put the socket processing code in main.cpp. But it seems that the call to Application::Run doesn't return until Form1 is closed. Is there another way of launching Form1 so timers may be set after Form1 is up? Thanks.
You just want to move source code from one file to another?
dwk
Seek and ye shall find.
"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.
"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison
"The only real mistake is the one from which we learn nothing."
-- John Powell
Seek and ye shall find.
"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.
"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison
"The only real mistake is the one from which we learn nothing."
-- John Powell
•
•
•
•
Originally Posted by DotNetUser
That's correct. If I have a global function in main that is "SendMessage" to socket, will I be able to call it from a class? My instance of the GUI class is not allowed to be global. How would I get around this? My callbacks needs to use some functions in the class.
When I yerked around with it some years ago I figured the easiet way to get an pointer to the calling class is to just add the overlapped struct data to the top of the class and send the object pointer as overlapped argument... Not nice, but works if you are careful not to delete memory to early when canceling results (had a bunch of those)... A better way is probably to put the pointer in the hEvent variable since it is not used when lpOverlapped is not null... Either you could put the pointer directly, or try some indirect table index / handle to avoid instances were you delete the object before the callback happens (as I said, had a bunch of those)...
*Edit, Ok I just read the original post and to me it does not seem to have anything at all to do with what I read into the second post... Well since its bad to leave an empty message I guess I'll just leave this post here anyway.
/pern.*/i
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. Albert Einstein
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. Albert Einstein
![]() |
Similar Threads
- What will a flash xml socket connect to - please help - insanity is near (PHP)
- Problem with Client-Server Socket Connection (Java)
- C# Get Socket from TcpClient (C#)
- Sane way of dynamically allocating arrays beyond declaration. (C)
- C++ development on Linux/Unix? (C++)
- how to send ARP packets in c++ (C++)
Other Threads in the C++ Forum
- Previous Thread: Scope Resolution Operator
- Next Thread: Memory allocation for typedef struct
| Thread Tools | Search this Thread |
api array based binary bitmap c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





