NativeWindow.ReleaseHandle

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi;

I want to use NativeWindow to wrap the hwnd of Word (which is already
running and so the window exists). I need to release the handle and dispose
my NativeWindow object when the window goes away.

As Word is not a .net app, it does not have .net windows and therefore I
can't have it call an event. Do I just watch for the WM_DESTROY message in
the message pump?
 
Hi dave,

Thanks for your post.

I am not sure how you do this, but I think word runs in another process,
and NativeWindow class can not do the subclassing for a window of another
process. Can you clarify this for us? Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hello;

Yes, Word is another process and not running under .net. But the
documentation for NativeWindow does not say same process AFAIK. I think as
long as I can get a hwnd, it can be any process.

???
 
David,
But the documentation for NativeWindow does not say same process AFAIK.

It does actually. Look at the docs for the AssignHandle method.


Mattias
 
Hi dave,

I think MVP Mattias has pointed out the official document for this.

Normally, .Net code can seldom do cross-process communication, unless the
target is your own .Net process, then we can use .Net Remoting to
communicate each other.

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi;

I have it working fine now. So either a Word Add-In counts as the same
application as Word itself or this does work cross application.
 
Hi dave,

I am not sure how you get subclassing work cross-process. Normally, the
wndproc we provided only resides in the .Net calling process, we can not
substitute the winword.exe process' window procedure with our calling
process' wndproc. Anyway, if you really get it work, I think it is a not
supported scenario, which may result in strange behavior.

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
hwnd's are global objects - you can call PostMessage() to any hwnd. So my
guess is the same rule applies here.
 
Hi dave,

Thanks for your feedback.

Yes, we can p/invoke PostMessage() to post a message to any window(event
the window resides in another process). However, I am not sure if this has
anything to do with our original issue. How do you use the NativeWindow
class do with Word window? We normally use NativeWindow to do subclassing
with certain control/window in the winform application. However, we can not
use it to do subclassing on another process window.

If I misunderstand you, please feel free to feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
So either a Word Add-In counts as the same application

Yes add-ins are loaded into the same process.


Mattias
 
Oh, if you are using word addin, and they will reside in the same process.
Then I think NativeWindow should can do the subclass for you. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top