Stefano,
[quoted text, click to view] > 2. In this C DLL function, the code creates an invisible window with
> CreateWindow() using for the message loop the function pointer passed.
> 3. C DLL saves the window handle in a DLL global variable for future uses
> 4. C DLL function sends a PostMessage( saved_handle, WM_custom, xx, yy)
but this
> message is never received from VB.NET function (the message is visible
with
> Spy++)
It is not clear why should the VB .NET callback receive the message in the
first place? Is this VB .NET function actually a window procedure? If yes, I
would advice to pay maximum attention on HOW do you pass the function
pointer to the C DLL. Ensure you specify the right calling convention
(WINAPI that is), and that all parameters will be marshalled properly.
Then, it's not clear what is meant under "the message is never received". If
you would post some standard message, would it be received by the VB .NET
procedure? Does it gets called at all?
I am just trying to focus on the root of the problem, so please be patient
to tons of my questions :-)
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
[quoted text, click to view] "Ste M" <stefano_mora@hotmail.com> wrote in message
news:bpi4bk$fdq$1@fata.cs.interbusiness.it...
> Hi Dmitriy,
> i try to explain better, i know it is a little complex.. :-)
>
> 1. VB .NET application makes a call to C DLL function. One of the function
> parameters is a pointer to a VB.NET function.
> 2. In this C DLL function, the code creates an invisible window with
> CreateWindow() using for the message loop the function pointer passed.
> 3. C DLL saves the window handle in a DLL global variable for future uses
> 4. C DLL function sends a PostMessage( saved_handle, WM_custom, xx, yy)
but this
> message is never received from VB.NET function (the message is visible
with
> Spy++)
> 5. Even if C DLL sends a message (custom or standard) just after the
> CreateWindow(..), VB.NET function never receive it.
> 6. VB.NET message loop receives startup standard messages as WM_CREATE,
WM_SIZE,
> WM_MOVE,
> ....
>
> Thanks
> --
> Stefano M
> email: *@*
> (remove *)
>
>
>
[quoted text, click to view] > The VB.NET window procedure receives all the standard messages fired
> (internally) from the CreateWindow() call.
> When i explicitly want to post a message (custom or not) to the invisible
window
> from my DLL code,
> i think the message will be sent to its window procedure but the .NET
window
> procedure is not fired !
A-ha, now it's much more clear. So my suggestions are:
1. Check the custom message is registered (I believe there's an API function
to do that). Not sure the receiving party should also register the custom
message though.
2. The PostMessage function has some difficulties with marshalling custom
messages. Not sure what they meant in MSDN but here's the quote:
=== Cut ===
The system only does marshalling for system messages (those in the range 0
to WM_USER). To send other messages (those above WM_USER) to another
process, you must do custom marshalling.
=== Cut ===
I'd also suggest asking the more detailed question in the
dotnet.framework.interop newsgroup as it seems to be not related to the VB
..NET lanugage itself.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
[quoted text, click to view] "SM" <stefano_mora@hotmail.com> wrote in message
news:ue7IMH2rDHA.2340@TK2MSFTNGP12.phx.gbl...
> Dmitriy,
> thanks again for your attention,
>
> > It is not clear why should the VB .NET callback receive the message in
the
> > first place? Is this VB .NET function actually a window procedure? If
yes, I
> > would advice to pay maximum attention on HOW do you pass the function
> > pointer to the C DLL. Ensure you specify the right calling convention
> > (WINAPI that is), and that all parameters will be marshalled properly.
>
> Yes, it is a window procedure for the window created into the C DLL.
> OK, i'll re-check all the parameters .... but i think if the address was
wrong,
> i should have a crash !!
>
> > Then, it's not clear what is meant under "the message is never
received". If
> > you would post some standard message, would it be received by the VB
..NET
> > procedure? Does it gets called at all?
>
> The VB.NET window procedure receives all the standard messages fired
> (internally) from the CreateWindow() call.
> When i explicitly want to post a message (custom or not) to the invisible
window
> from my DLL code,
> i think the message will be sent to its window procedure but the .NET
window
> procedure is not fired !
>
> > I am just trying to focus on the root of the problem, so please be
patient
> > to tons of my questions :-)
>
> Oh, don't worry !!! I understand that is not a clear architecture but
> i'm migrating from an existent situation (VB6+C DLL), this
> situation was created from previous programmer and I'm trying
> to leave untouched the just-tested DLL. Maybe in the future I'll
> have time to re-write also the DLL.....
>
> Thanks a lot !
> --
> Stefano M
> email: *@*
> (remove *)
>
>
>
Don't see what you're looking for? Try a search.