Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Goes Blank

Status
Not open for further replies.

msstrang

Programmer
Sep 19, 2005
62
US
Hi Everybody,
I'm trying to figure out a silly little issue I've got going on here.

I've written a windows form project using VS c++ 2005 Express.

I have it set up so when the user presses the "connect" button the code jumps to another module I currently have that opens a winsocket port and sets it to listen at the computer's internal IP address.

However, while the code is waiting for someone to connect, the window form "goes blank", meaning all of the pushbuttons/ radiobuttons/ listboxes disappear and are replaced with a all white background in the form.

I'd like this not to happen, obviously, but espcially because I want the user to be able to press the "disconnect" push button if they do not want the port on the computer to be open anymore.
 
hi,
when we used first time Windows programming 15-20years ago,
we have to manage all "Messages" that Operating System sends to application (your program) when it runs. A mouse movement, a click on a button or a key press, sends to your program a message. If you don't intercept it with
an appropriate Function, Windows has a default one that does it. When you define an event Function as a OnOK in a simple OK button in a simple dialog box, you add your code at begin of function, then you leave CDialog::OnOK() that
continues with default actions (closes dlg, frees something and so on). When Framework was not used, the main program was a big loop with a switch case as first statement in which you defined which actions for every message: in the dafault case, there was a call to default function.

If you stop the execution of your program in a big file read/write loop, or you place a Sleep(10000), the computer continues to run other applications, but your program hangs in that point: no messages (as refresh, window movements, ecc) are captured; they goes in a queue and at the completion of your wait/I/O are de-queued.

What you can do is to use a more complex architecture as:
a modless window from wich you can press a halt button
but, while the window is on, your code continue in the I/O;
your ReadFile or what you have used, mey be used in asynchronous mode.

I try later to explain better the details

bye
vittorio

 
i think i follow some of what you are saying.

i figured out the part of my program that is causing the issue.

its winsocket server application - so when the code reaches
"SOCKET accept (...);"
it basically waits until another comptutuer connects into the assigned open socket. This doesn't allow me to run an "Application::DoEvents();"; which is what I usually would put for a normal loop causing a similar issue.

would a modeless work in the above instance when the code is waiting for another user to connect to a open socket using "SOCKET accept" winsocket server code?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top