Solved

How to get PostMessage to return control

Posted on 2001-07-12
2
168 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
Comment Utility
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
Comment Utility
That did the trick, thank you very much. (Of course, new problems have arisen, but that's for another topic...) --Dennis
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

772 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now