Solved

How to get PostMessage to return control

Posted on 2001-07-12
2
172 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
List out all word 7 317
maven archtype selection in eclipse 1 57
wordcount challenge 11 132
Excel file not created as expected 7 79
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.

860 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