Solved

Problems with SendMessage

Posted on 1998-12-06
3
191 Views
Last Modified: 2013-11-20
Hi!
 I use VC++5. My app is SDI. From the main thread (CWinApp), in the doc file,i create a new thread using a class derived from CWinThread giving in the constructor the handle to the doc view (derived from CEditView).
 The problem is, that in the new thread I try to post a message to the view of the doc using the PostMessage function and the handle to the view (HWND) as parameter --> there is not error, but the message doesn't reach the window queue.
 If I send a message to the AfxGetMainWnd()(so to the main window), its working. What's the problem?
0
Comment
Question by:visualc
3 Comments
 

Author Comment

by:visualc
Comment Utility
Edited text of question
0
 
LVL 8

Expert Comment

by:Answers2000
Comment Utility
Are you using SendMessage/PostMessage right for the view, to get the HWND you do

::PostMessage( pView->m_hWnd, ...etc...)
0
 
LVL 2

Accepted Solution

by:
prasanth earned 50 total points
Comment Utility
The problem lies with passing the thread a handle to the doc view. CWnds are thread-specific - you can't pass them between threads. You can, however, pass the HWNDs between threads. So change your constructor from taking a CWnd (or a CEditView, or whatever) to taking a HWND. Then call the constructor with pView->GetSafeHwnd() as the parameter. Then you can SendMessage(m_docviewhwnd, ...) from your thread.
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

Title # Comments Views Activity
MFC Dialog 9 47
Show shut-down message as Windows 8 shuts down. 9 74
repeateFront java challenge 31 87
sum67 challenge 35 89
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…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
This video discusses moving either the default database or any database to a new volume.

743 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

17 Experts available now in Live!

Get 1:1 Help Now