[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

displaying toolbar and menu!!!

Posted on 1999-10-27
5
Medium Priority
?
215 Views
Last Modified: 2013-11-20
i have an SDI application with a menu and toolbars. But when i run my
program, which involves windows sockets and reads infinitely from a
specific socket, then my menu and toolbar disappear from the
window. How do i prevent this from happening?

0
Comment
Question by:angshu
5 Comments
 
LVL 31

Expert Comment

by:Zoppo
ID: 2162685
Hi angshu,

try implementing the socket reading loop in a thread or make anyhow sure that the window's messages sent to you main window are processed via PeekMessage()/DispatchMessage().

hope that helps,

ZOPPO
0
 
LVL 2

Expert Comment

by:Gandalf32
ID: 2162700
I believe the problem is that your problem stays in a loop reading the socket, never letting the window process messages.
If this is the case, then you need to change your program in order to allow it to process messages. You can do this by eliminating the loop in the socket reading code, and instead reading the socket once during each call of the OnIdle method of the application. Otherwise, you can start a second thread (a work thread) and execute the polling code there.
0
 
LVL 12

Expert Comment

by:migel
ID: 2162819
Can you be more specific? How you read socket data? Show your code
0
 

Accepted Solution

by:
jzhang100 earned 300 total points
ID: 2163710
I believe this happens because your socket reading operation is in the same thread of your user interface. The socket read operation is blocking the  thread so no more message can be delivered before that socket reading API returned. When programming a socket on windows platform, it can be either in synchronized mode or asynchronized mode. The solution to your problem can be one of the following.
1. Program your socket in asyncronized mode, so that it will be blocking the thread, if you do not want to begin another thread. MFC has CAsyncSocket class for this kind of use.
2. If you really want to use synchronized read, start a seperate thread to do this.

Jenny
0
 

Expert Comment

by:jzhang100
ID: 2163712
I believe this happens because your socket reading operation is in the same thread of your user interface. The socket read operation is blocking the  thread so no more message can be delivered before that socket reading API returned. When programming a socket on windows platform, it can be either in synchronized mode or asynchronized mode. The solution to your problem can be one of the following.
1. Program your socket in asyncronized mode, so that it will not be blocking the thread, if you do not want to begin another thread. MFC has CAsyncSocket class for this kind of use.
2. If you really want to use synchronized read, start a seperate thread to do this.

Jenny
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.
Suggested Courses

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question