Solved

How to get PostMessage to return control

Posted on 2001-07-12
2
173 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
2 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 75 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

726 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