Solved

Problems with SendMessage

Posted on 1998-12-06
3
196 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
ID: 1325797
Edited text of question
0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1325798
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
ID: 1325799
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

840 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