Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to get PostMessage to return control

Posted on 2001-07-12
2
Medium Priority
?
177 Views
Last Modified: 2013-11-20
I have a program that allows users to upload images to a web server. The web connection is handled by a class derived from CWnd that opens a CSocket, creates and new CSocketFile, then writes the image data to that CSocketFile. I have previously been calling the (CMySocket *)pMyWeb->Post() routine that handles the above from its parent window, and waiting for the function to complete before continuing. In order to improve efficiency, I decided instead to post a message to the CMySocket window and let it handle the post in the background. I used the command

 pMyWeb->PostMessage(WM_MYPOST, (WPARAM) &vImageInfoObject);
 AfxMessageBox("Post is queued");

where WM_MYPOST is defined as WM_USER+1. The post proceeds fine, the wait cursor doesn't appear, but I cannot activate my main window until the post has been completed, and although the program steps through the MessageBox, the message doesn't display until AFTER any messages created by the post are displayed. It seems to be behaving like a SendMessage. What am I doing wrong?

Thanks --Dennis
0
Comment
Question by:DenMan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 300 total points
ID: 6279491
There is nothing wrong. It should be like this since there is only one thread in your program. You need to create another thread in order to achieve what you want. Check out my sample at CodeGuru to see how to do it.

Download a File Using URLDownloadToCacheFile
http://www.codeguru.com/internet/urlfile.shtml

The URLDownloadToCacheFile function is like your Post routine. It does not return until it finishes.
0
 

Author Comment

by:DenMan
ID: 6319793
That did the trick, thank you very much. (Of course, new problems have arisen, but that's for another topic...) --Dennis
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

609 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