Solved

How to get PostMessage to return control

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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: 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 …
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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

691 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