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?

--
thanks - dave

RE: NativeWindow.ReleaseHandle by v-jetan

v-jetan
Wed Dec 07 03:46:25 CST 2005

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.


RE: NativeWindow.ReleaseHandle by thielen

thielen
Wed Dec 07 12:09:04 CST 2005

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.

???
--
thanks - dave


""Jeffrey Tan[MSFT]"" wrote:

> 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.
>
>

Re: NativeWindow.ReleaseHandle by Mattias

Mattias
Wed Dec 07 12:55:23 CST 2005

David,

>But the documentation for NativeWindow does not say same process AFAIK.

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


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

RE: NativeWindow.ReleaseHandle by v-jetan

v-jetan
Thu Dec 08 00:07:16 CST 2005

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.


Re: NativeWindow.ReleaseHandle by thielen

thielen
Thu Dec 08 08:46:02 CST 2005

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.

--
thanks - dave


"Mattias Sjögren" wrote:

> David,
>
> >But the documentation for NativeWindow does not say same process AFAIK.
>
> It does actually. Look at the docs for the AssignHandle method.
>
>
> Mattias
>
> --
> Mattias Sjögren [C# MVP] mattias @ mvps.org
> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> Please reply only to the newsgroup.
>

Re: NativeWindow.ReleaseHandle by v-jetan

v-jetan
Thu Dec 08 20:40:21 CST 2005

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.


Re: NativeWindow.ReleaseHandle by thielen

thielen
Thu Dec 08 21:34:02 CST 2005

hwnd's are global objects - you can call PostMessage() to any hwnd. So my
guess is the same rule applies here.

--
thanks - dave


""Jeffrey Tan[MSFT]"" wrote:

> 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.
>
>

Re: NativeWindow.ReleaseHandle by v-jetan

v-jetan
Thu Dec 08 23:39:50 CST 2005

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.


Re: NativeWindow.ReleaseHandle by Mattias

Mattias
Fri Dec 09 00:24:21 CST 2005

>So either a Word Add-In counts as the same application

Yes add-ins are loaded into the same process.


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Re: NativeWindow.ReleaseHandle by v-jetan

v-jetan
Fri Dec 09 01:38:36 CST 2005

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.