Board index » Visual Studio » How to get the active document

How to get the active document

Visual Studio190
Hi. How can I get the active document object (to clarify, the document

object associated with the view that has focus) in an MDI application? I'm

using a worker thread for communication and I need to tell the active

document about communication event that occur.



Thanks,

Isaac.


-
 

Re:How to get the active document

You can get the active document in MDI using GetActiveFrame(), checking its

validity and then calling GetActiveDocument on it. The only catch here is

that you are doing it in a worker thread. I think it should work there as

well because you are not using the (CWnd,handle) map of MFC that is not

valid in your thread. In worst case, you can pass the document pointer to

the thread at the beginning.



--

Ajay Kalra [MVP - VC++]

ajaykalra@yahoo.com





"Isaac Raway" <isaac@blueapples.org>wrote in message

Quote
Hi. How can I get the active document object (to clarify, the document

object associated with the view that has focus) in an MDI application? I'm

using a worker thread for communication and I need to tell the active

document about communication event that occur.



Thanks,

Isaac.









-