Getting function pointer/creating delegate with Reflection

A

azerty

Hello !

In previous message (see below), Dominic Cooney try to create a delagate by
reflexion

but MethodInfo.GetFunctionPointer doesn't exist on CF

I try another technique (work fine on PC platform)
I create a temporary Delegate on my function and use reflection to load
value in private member "_methodPtr"

The code is :

Delegate tmpDelegate = new EventHandler(Form1_EventTest);

FieldInfo fi = typeof(Delegate).GetField("_methodPtr",
BindingFlags.NonPublic |
BindingFlags.Instance);
Int32 ptrMethod = (Int32)fi.GetValue(tmpDelegate);

Delegate newDelegate = (Delegate)MyConstructorInfo.Invoke(new object[]
{this , ptrMethod } );

it work fine on PC but throw an exception on PPC (InvalidProgramException)

Do you know why ?

Another question : is it possible to include MSIL instruction in C# program
(like ASM instruction in C/C++ or Delphi program) ???

thanks for your help !



De :Tim Gerken [MSFT] ([email protected])
Objet :RE: Getting function pointer/creating delegate with Reflection


View this article only
Groupes de discussion :microsoft.public.dotnet.framework.compactframework
Date :2003-03-05 15:24:03 PST


Sorry, Dominic, there is no way to get at this information on the .NET
Compact Framework.

Tim
This posting is provide "AS IS" with no warranties, and confers no rights.
--------------------
| From: (e-mail address removed) (Dominic Cooney)
| Subject: Getting function pointer/creating delegate with Reflection
| Date: 5 Feb 2003 16:48:40 -0800
|
| Is there any way to get the same pointer that ldftn returns, without
| using ldftn (i.e. via a MethodInfo or RuntimeMethodHandle)?
|
| My situation is this: Given a MethodInfo I want to create a delegate
| via Reflection. Delegate constructors require a function pointer,
| usually retrieved by ldftn. On .NET, you can retrieve a method pointer
| via Reflection using methodInfo.MethodHandle.GetFunctionPointer(),
| however that is not supported on .NET CF.
|
| I'm not concerned about future portability. I'd be happy to know a
| hack to get the pointer.
 
A

Alex Feinman [MVP]

Because the native runtime does not support it. It's not enough to fake a
pointer - there needs to be a mechanism to transfer execution from unmanaged
to managed. We've been down this way. The answer is still, no

--
Alex Feinman
---
Visit http://www.opennetcf.org
azerty said:
Hello !

In previous message (see below), Dominic Cooney try to create a delagate
by
reflexion

but MethodInfo.GetFunctionPointer doesn't exist on CF

I try another technique (work fine on PC platform)
I create a temporary Delegate on my function and use reflection to load
value in private member "_methodPtr"

The code is :

Delegate tmpDelegate = new EventHandler(Form1_EventTest);

FieldInfo fi = typeof(Delegate).GetField("_methodPtr",
BindingFlags.NonPublic |
BindingFlags.Instance);
Int32 ptrMethod = (Int32)fi.GetValue(tmpDelegate);

Delegate newDelegate = (Delegate)MyConstructorInfo.Invoke(new object[]
{this , ptrMethod } );

it work fine on PC but throw an exception on PPC (InvalidProgramException)

Do you know why ?

Another question : is it possible to include MSIL instruction in C#
program
(like ASM instruction in C/C++ or Delphi program) ???

thanks for your help !



De :Tim Gerken [MSFT] ([email protected])
Objet :RE: Getting function pointer/creating delegate with Reflection


View this article only
Groupes de discussion :microsoft.public.dotnet.framework.compactframework
Date :2003-03-05 15:24:03 PST


Sorry, Dominic, there is no way to get at this information on the .NET
Compact Framework.

Tim
This posting is provide "AS IS" with no warranties, and confers no rights.
--------------------
| From: (e-mail address removed) (Dominic Cooney)
| Subject: Getting function pointer/creating delegate with Reflection
| Date: 5 Feb 2003 16:48:40 -0800
|
| Is there any way to get the same pointer that ldftn returns, without
| using ldftn (i.e. via a MethodInfo or RuntimeMethodHandle)?
|
| My situation is this: Given a MethodInfo I want to create a delegate
| via Reflection. Delegate constructors require a function pointer,
| usually retrieved by ldftn. On .NET, you can retrieve a method pointer
| via Reflection using methodInfo.MethodHandle.GetFunctionPointer(),
| however that is not supported on .NET CF.
|
| I'm not concerned about future portability. I'd be happy to know a
| hack to get the pointer.
 
A

azerty

thanks a lot for your answer, It can help me for another point
I could use this technic with PC, all is not missing for me ;-)

In fact, The real purpose of my research is to override the WndProc of
Control object to intercept some Windows Messages.

WndProc of System.Windows.Forms.Control (CF) is virtual BUT internal !!
I can't override it

I see with reflector in _InitInstance a private delegate (m_wnproc) witch
use by Control code to intercep Windows Message of native win32 TextBox
control.

I wanted to add my own method on it with reflection methods but it is not
possible ...

May be, do you have another way to do it ???

thanks for your help !


Alex Feinman said:
Because the native runtime does not support it. It's not enough to fake a
pointer - there needs to be a mechanism to transfer execution from unmanaged
to managed. We've been down this way. The answer is still, no

--
Alex Feinman
---
Visit http://www.opennetcf.org
azerty said:
Hello !

In previous message (see below), Dominic Cooney try to create a delagate
by
reflexion

but MethodInfo.GetFunctionPointer doesn't exist on CF

I try another technique (work fine on PC platform)
I create a temporary Delegate on my function and use reflection to load
value in private member "_methodPtr"

The code is :

Delegate tmpDelegate = new EventHandler(Form1_EventTest);

FieldInfo fi = typeof(Delegate).GetField("_methodPtr",
BindingFlags.NonPublic |
BindingFlags.Instance);
Int32 ptrMethod = (Int32)fi.GetValue(tmpDelegate);

Delegate newDelegate = (Delegate)MyConstructorInfo.Invoke(new object[]
{this , ptrMethod } );

it work fine on PC but throw an exception on PPC (InvalidProgramException)

Do you know why ?

Another question : is it possible to include MSIL instruction in C#
program
(like ASM instruction in C/C++ or Delphi program) ???

thanks for your help !



De :Tim Gerken [MSFT] ([email protected])
Objet :RE: Getting function pointer/creating delegate with Reflection


View this article only
Groupes de discussion :microsoft.public.dotnet.framework.compactframework
Date :2003-03-05 15:24:03 PST


Sorry, Dominic, there is no way to get at this information on the .NET
Compact Framework.

Tim
This posting is provide "AS IS" with no warranties, and confers no rights.
--------------------
| From: (e-mail address removed) (Dominic Cooney)
| Subject: Getting function pointer/creating delegate with Reflection
| Date: 5 Feb 2003 16:48:40 -0800
|
| Is there any way to get the same pointer that ldftn returns, without
| using ldftn (i.e. via a MethodInfo or RuntimeMethodHandle)?
|
| My situation is this: Given a MethodInfo I want to create a delegate
| via Reflection. Delegate constructors require a function pointer,
| usually retrieved by ldftn. On .NET, you can retrieve a method pointer
| via Reflection using methodInfo.MethodHandle.GetFunctionPointer(),
| however that is not supported on .NET CF.
|
| I'm not concerned about future portability. I'd be happy to know a
| hack to get the pointer.
 
G

Guest

You cannot reassign a WndProc in the CF - there's just no way without
function pointers. You can use an IMessageFilter and pre-process messages
bound for the control, which may help.

-Chris


azerty said:
thanks a lot for your answer, It can help me for another point
I could use this technic with PC, all is not missing for me ;-)

In fact, The real purpose of my research is to override the WndProc of
Control object to intercept some Windows Messages.

WndProc of System.Windows.Forms.Control (CF) is virtual BUT internal !!
I can't override it

I see with reflector in _InitInstance a private delegate (m_wnproc) witch
use by Control code to intercep Windows Message of native win32 TextBox
control.

I wanted to add my own method on it with reflection methods but it is not
possible ...

May be, do you have another way to do it ???

thanks for your help !


Alex Feinman said:
Because the native runtime does not support it. It's not enough to fake a
pointer - there needs to be a mechanism to transfer execution from unmanaged
to managed. We've been down this way. The answer is still, no

--
Alex Feinman
---
Visit http://www.opennetcf.org
azerty said:
Hello !

In previous message (see below), Dominic Cooney try to create a
delagate
by
reflexion

but MethodInfo.GetFunctionPointer doesn't exist on CF

I try another technique (work fine on PC platform)
I create a temporary Delegate on my function and use reflection to load
value in private member "_methodPtr"

The code is :

Delegate tmpDelegate = new EventHandler(Form1_EventTest);

FieldInfo fi = typeof(Delegate).GetField("_methodPtr",
BindingFlags.NonPublic |
BindingFlags.Instance);
Int32 ptrMethod = (Int32)fi.GetValue(tmpDelegate);

Delegate newDelegate = (Delegate)MyConstructorInfo.Invoke(new
object[]
{this , ptrMethod } );

it work fine on PC but throw an exception on PPC (InvalidProgramException)

Do you know why ?

Another question : is it possible to include MSIL instruction in C#
program
(like ASM instruction in C/C++ or Delphi program) ???

thanks for your help !





De :Tim Gerken [MSFT] ([email protected])
Objet :RE: Getting function pointer/creating delegate with Reflection


View this article only
Groupes de discussion :microsoft.public.dotnet.framework.compactframework
Date :2003-03-05 15:24:03 PST


Sorry, Dominic, there is no way to get at this information on the .NET
Compact Framework.

Tim
This posting is provide "AS IS" with no warranties, and confers no rights.
--------------------
| From: (e-mail address removed) (Dominic Cooney)
| Subject: Getting function pointer/creating delegate with Reflection
| Date: 5 Feb 2003 16:48:40 -0800
|
| Is there any way to get the same pointer that ldftn returns, without
| using ldftn (i.e. via a MethodInfo or RuntimeMethodHandle)?
|
| My situation is this: Given a MethodInfo I want to create a delegate
| via Reflection. Delegate constructors require a function pointer,
| usually retrieved by ldftn. On .NET, you can retrieve a method
pointer
| via Reflection using methodInfo.MethodHandle.GetFunctionPointer(),
| however that is not supported on .NET CF.
|
| I'm not concerned about future portability. I'd be happy to know a
| hack to get the pointer.
 
P

Peter Foot [MVP]

The Wnproc in the .NETCF control class doesn't receive all standard windows
messages as they have been pre-processed and it only passes through a subset
of messages (those already supported in .NETCF). So although you can
intercept these with a lot of nasty reflection code you don't actually gain
anything. Use the IMessageFilter approach with OpenNETCF's ApplicationEx
class to intercept all native windows messages (www.opennetcf.org/sdf/)

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

azerty said:
thanks a lot for your answer, It can help me for another point
I could use this technic with PC, all is not missing for me ;-)

In fact, The real purpose of my research is to override the WndProc of
Control object to intercept some Windows Messages.

WndProc of System.Windows.Forms.Control (CF) is virtual BUT internal !!
I can't override it

I see with reflector in _InitInstance a private delegate (m_wnproc) witch
use by Control code to intercep Windows Message of native win32 TextBox
control.

I wanted to add my own method on it with reflection methods but it is not
possible ...

May be, do you have another way to do it ???

thanks for your help !


Alex Feinman said:
Because the native runtime does not support it. It's not enough to fake a
pointer - there needs to be a mechanism to transfer execution from unmanaged
to managed. We've been down this way. The answer is still, no

--
Alex Feinman
---
Visit http://www.opennetcf.org
azerty said:
Hello !

In previous message (see below), Dominic Cooney try to create a
delagate
by
reflexion

but MethodInfo.GetFunctionPointer doesn't exist on CF

I try another technique (work fine on PC platform)
I create a temporary Delegate on my function and use reflection to load
value in private member "_methodPtr"

The code is :

Delegate tmpDelegate = new EventHandler(Form1_EventTest);

FieldInfo fi = typeof(Delegate).GetField("_methodPtr",
BindingFlags.NonPublic |
BindingFlags.Instance);
Int32 ptrMethod = (Int32)fi.GetValue(tmpDelegate);

Delegate newDelegate = (Delegate)MyConstructorInfo.Invoke(new
object[]
{this , ptrMethod } );

it work fine on PC but throw an exception on PPC (InvalidProgramException)

Do you know why ?

Another question : is it possible to include MSIL instruction in C#
program
(like ASM instruction in C/C++ or Delphi program) ???

thanks for your help !





De :Tim Gerken [MSFT] ([email protected])
Objet :RE: Getting function pointer/creating delegate with Reflection


View this article only
Groupes de discussion :microsoft.public.dotnet.framework.compactframework
Date :2003-03-05 15:24:03 PST


Sorry, Dominic, there is no way to get at this information on the .NET
Compact Framework.

Tim
This posting is provide "AS IS" with no warranties, and confers no rights.
--------------------
| From: (e-mail address removed) (Dominic Cooney)
| Subject: Getting function pointer/creating delegate with Reflection
| Date: 5 Feb 2003 16:48:40 -0800
|
| Is there any way to get the same pointer that ldftn returns, without
| using ldftn (i.e. via a MethodInfo or RuntimeMethodHandle)?
|
| My situation is this: Given a MethodInfo I want to create a delegate
| via Reflection. Delegate constructors require a function pointer,
| usually retrieved by ldftn. On .NET, you can retrieve a method
pointer
| via Reflection using methodInfo.MethodHandle.GetFunctionPointer(),
| however that is not supported on .NET CF.
|
| I'm not concerned about future portability. I'd be happy to know a
| hack to get the pointer.
 
A

azerty

I just read the ApplicationEx code.

I have a delphi culture, so, I can see in ApplicationEx code, rouglhly the
same code as Application object of Forms.Pas !

We develop differents applications for differents customer so if we choice
this way, is a very important fact because this choice touch all the
application.

Do you have executing benchmark evaluation to compare ApplicationEx Pump
function and native pump function ?


From reflector ....
[DllImport("AGL", EntryPoint="@93")]
public static extern PAL_ERROR EnterMainLoop(IntPtr hwnMain); in reflector.

this way seems very interesting, fox example, we could reproduce the
OnThreadException of PC framework (very usefull to generate a warning
exception to show something for the user but don't close the application, or
just save in report each exception for debuging and much more ...)

your opinion strongly interests me ...

best regards

PS : Real purpose :
I want to intercept clic action on TextBox
I want to intercept every clic action out a Datagrid to hide it, even if the
focus doesn't change(because for big quantity of row, datagrid is better (it loads only what it
shows ....)I need the preceded point ....


Peter Foot said:
The Wnproc in the .NETCF control class doesn't receive all standard windows
messages as they have been pre-processed and it only passes through a subset
of messages (those already supported in .NETCF). So although you can
intercept these with a lot of nasty reflection code you don't actually gain
anything. Use the IMessageFilter approach with OpenNETCF's ApplicationEx
class to intercept all native windows messages (www.opennetcf.org/sdf/)

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

azerty said:
thanks a lot for your answer, It can help me for another point
I could use this technic with PC, all is not missing for me ;-)

In fact, The real purpose of my research is to override the WndProc of
Control object to intercept some Windows Messages.

WndProc of System.Windows.Forms.Control (CF) is virtual BUT internal !!
I can't override it

I see with reflector in _InitInstance a private delegate (m_wnproc) witch
use by Control code to intercep Windows Message of native win32 TextBox
control.

I wanted to add my own method on it with reflection methods but it is not
possible ...

May be, do you have another way to do it ???

thanks for your help !


"Alex Feinman [MVP]" <[email protected]> a écrit dans le message
de news:[email protected]...
Because the native runtime does not support it. It's not enough to fake a
pointer - there needs to be a mechanism to transfer execution from unmanaged
to managed. We've been down this way. The answer is still, no

--
Alex Feinman
---
Visit http://www.opennetcf.org
Hello !

In previous message (see below), Dominic Cooney try to create a
delagate
by
reflexion

but MethodInfo.GetFunctionPointer doesn't exist on CF

I try another technique (work fine on PC platform)
I create a temporary Delegate on my function and use reflection to load
value in private member "_methodPtr"

The code is :

Delegate tmpDelegate = new EventHandler(Form1_EventTest);

FieldInfo fi = typeof(Delegate).GetField("_methodPtr",
BindingFlags.NonPublic |
BindingFlags.Instance);
Int32 ptrMethod = (Int32)fi.GetValue(tmpDelegate);

Delegate newDelegate = (Delegate)MyConstructorInfo.Invoke(new
object[]
{this , ptrMethod } );

it work fine on PC but throw an exception on PPC (InvalidProgramException)

Do you know why ?

Another question : is it possible to include MSIL instruction in C#
program
(like ASM instruction in C/C++ or Delphi program) ???

thanks for your help !





De :Tim Gerken [MSFT] ([email protected])
Objet :RE: Getting function pointer/creating delegate with Reflection


View this article only
Groupes de discussion :microsoft.public.dotnet.framework.compactframework
Date :2003-03-05 15:24:03 PST


Sorry, Dominic, there is no way to get at this information on the ..NET
Compact Framework.

Tim
This posting is provide "AS IS" with no warranties, and confers no rights.
--------------------
| From: (e-mail address removed) (Dominic Cooney)
| Subject: Getting function pointer/creating delegate with Reflection
| Date: 5 Feb 2003 16:48:40 -0800
|
| Is there any way to get the same pointer that ldftn returns, without
| using ldftn (i.e. via a MethodInfo or RuntimeMethodHandle)?
|
| My situation is this: Given a MethodInfo I want to create a delegate
| via Reflection. Delegate constructors require a function pointer,
| usually retrieved by ldftn. On .NET, you can retrieve a method
pointer
| via Reflection using methodInfo.MethodHandle.GetFunctionPointer(),
| however that is not supported on .NET CF.
|
| I'm not concerned about future portability. I'd be happy to know a
| hack to get the pointer.
 
A

azerty

thanks a lot for your help !

I try to use this technic to realize my real purpose and everything work
fine EXCEPT
when I use ShowDialog method of a form

It is normal ! >> ShowDialog use another pump function of Framework

I did not find this type of function in OpenNetCF

may be someone developed it somewhere ?

PS : Real purpose :
I want to intercept clic action on TextBox
I want to intercept every clic action out a textBox to do sommething else,
even if the
focus doesn't change

NB : TheApplicationEx contains all method and technic to do it, I think ...


Peter Foot said:
The Wnproc in the .NETCF control class doesn't receive all standard windows
messages as they have been pre-processed and it only passes through a subset
of messages (those already supported in .NETCF). So although you can
intercept these with a lot of nasty reflection code you don't actually gain
anything. Use the IMessageFilter approach with OpenNETCF's ApplicationEx
class to intercept all native windows messages (www.opennetcf.org/sdf/)

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

azerty said:
thanks a lot for your answer, It can help me for another point
I could use this technic with PC, all is not missing for me ;-)

In fact, The real purpose of my research is to override the WndProc of
Control object to intercept some Windows Messages.

WndProc of System.Windows.Forms.Control (CF) is virtual BUT internal !!
I can't override it

I see with reflector in _InitInstance a private delegate (m_wnproc) witch
use by Control code to intercep Windows Message of native win32 TextBox
control.

I wanted to add my own method on it with reflection methods but it is not
possible ...

May be, do you have another way to do it ???

thanks for your help !


"Alex Feinman [MVP]" <[email protected]> a écrit dans le message
de news:[email protected]...
Because the native runtime does not support it. It's not enough to fake a
pointer - there needs to be a mechanism to transfer execution from unmanaged
to managed. We've been down this way. The answer is still, no

--
Alex Feinman
---
Visit http://www.opennetcf.org
Hello !

In previous message (see below), Dominic Cooney try to create a
delagate
by
reflexion

but MethodInfo.GetFunctionPointer doesn't exist on CF

I try another technique (work fine on PC platform)
I create a temporary Delegate on my function and use reflection to load
value in private member "_methodPtr"

The code is :

Delegate tmpDelegate = new EventHandler(Form1_EventTest);

FieldInfo fi = typeof(Delegate).GetField("_methodPtr",
BindingFlags.NonPublic |
BindingFlags.Instance);
Int32 ptrMethod = (Int32)fi.GetValue(tmpDelegate);

Delegate newDelegate = (Delegate)MyConstructorInfo.Invoke(new
object[]
{this , ptrMethod } );

it work fine on PC but throw an exception on PPC (InvalidProgramException)

Do you know why ?

Another question : is it possible to include MSIL instruction in C#
program
(like ASM instruction in C/C++ or Delphi program) ???

thanks for your help !





De :Tim Gerken [MSFT] ([email protected])
Objet :RE: Getting function pointer/creating delegate with Reflection


View this article only
Groupes de discussion :microsoft.public.dotnet.framework.compactframework
Date :2003-03-05 15:24:03 PST


Sorry, Dominic, there is no way to get at this information on the ..NET
Compact Framework.

Tim
This posting is provide "AS IS" with no warranties, and confers no rights.
--------------------
| From: (e-mail address removed) (Dominic Cooney)
| Subject: Getting function pointer/creating delegate with Reflection
| Date: 5 Feb 2003 16:48:40 -0800
|
| Is there any way to get the same pointer that ldftn returns, without
| using ldftn (i.e. via a MethodInfo or RuntimeMethodHandle)?
|
| My situation is this: Given a MethodInfo I want to create a delegate
| via Reflection. Delegate constructors require a function pointer,
| usually retrieved by ldftn. On .NET, you can retrieve a method
pointer
| via Reflection using methodInfo.MethodHandle.GetFunctionPointer(),
| however that is not supported on .NET CF.
|
| I'm not concerned about future portability. I'd be happy to know a
| hack to get the pointer.
 
C

Chris Tacke, eMVP

It's a known limitation of ApplicationEx that IMessageFilter implementations
don't get messages from Forms shown with ShowDialog

--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate


azerty said:
thanks a lot for your help !

I try to use this technic to realize my real purpose and everything work
fine EXCEPT
when I use ShowDialog method of a form

It is normal ! >> ShowDialog use another pump function of Framework

I did not find this type of function in OpenNetCF

may be someone developed it somewhere ?

PS : Real purpose :
I want to intercept clic action on TextBox
I want to intercept every clic action out a textBox to do sommething else,
even if the
focus doesn't change

NB : TheApplicationEx contains all method and technic to do it, I think
...


Peter Foot said:
The Wnproc in the .NETCF control class doesn't receive all standard windows
messages as they have been pre-processed and it only passes through a subset
of messages (those already supported in .NETCF). So although you can
intercept these with a lot of nasty reflection code you don't actually gain
anything. Use the IMessageFilter approach with OpenNETCF's ApplicationEx
class to intercept all native windows messages (www.opennetcf.org/sdf/)

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

azerty said:
thanks a lot for your answer, It can help me for another point
I could use this technic with PC, all is not missing for me ;-)

In fact, The real purpose of my research is to override the WndProc of
Control object to intercept some Windows Messages.

WndProc of System.Windows.Forms.Control (CF) is virtual BUT internal !!
I can't override it

I see with reflector in _InitInstance a private delegate (m_wnproc) witch
use by Control code to intercep Windows Message of native win32 TextBox
control.

I wanted to add my own method on it with reflection methods but it is not
possible ...

May be, do you have another way to do it ???

thanks for your help !


"Alex Feinman [MVP]" <[email protected]> a écrit dans le message
de Because the native runtime does not support it. It's not enough to
fake a
pointer - there needs to be a mechanism to transfer execution from
unmanaged
to managed. We've been down this way. The answer is still, no

--
Alex Feinman
---
Visit http://www.opennetcf.org
Hello !

In previous message (see below), Dominic Cooney try to create a
delagate
by
reflexion

but MethodInfo.GetFunctionPointer doesn't exist on CF

I try another technique (work fine on PC platform)
I create a temporary Delegate on my function and use reflection to load
value in private member "_methodPtr"

The code is :

Delegate tmpDelegate = new EventHandler(Form1_EventTest);

FieldInfo fi = typeof(Delegate).GetField("_methodPtr",
BindingFlags.NonPublic |
BindingFlags.Instance);
Int32 ptrMethod = (Int32)fi.GetValue(tmpDelegate);

Delegate newDelegate = (Delegate)MyConstructorInfo.Invoke(new
object[]
{this , ptrMethod } );

it work fine on PC but throw an exception on PPC
(InvalidProgramException)

Do you know why ?

Another question : is it possible to include MSIL instruction in C#
program
(like ASM instruction in C/C++ or Delphi program) ???

thanks for your help !





De :Tim Gerken [MSFT] ([email protected])
Objet :RE: Getting function pointer/creating delegate with
Reflection


View this article only
Groupes de discussion
:microsoft.public.dotnet.framework.compactframework
Date :2003-03-05 15:24:03 PST


Sorry, Dominic, there is no way to get at this information on the .NET
Compact Framework.

Tim
This posting is provide "AS IS" with no warranties, and confers no
rights.
--------------------
| From: (e-mail address removed) (Dominic Cooney)
| Subject: Getting function pointer/creating delegate with
Reflection
| Date: 5 Feb 2003 16:48:40 -0800
|
| Is there any way to get the same pointer that ldftn returns, without
| using ldftn (i.e. via a MethodInfo or RuntimeMethodHandle)?
|
| My situation is this: Given a MethodInfo I want to create a delegate
| via Reflection. Delegate constructors require a function pointer,
| usually retrieved by ldftn. On .NET, you can retrieve a method
pointer
| via Reflection using methodInfo.MethodHandle.GetFunctionPointer(),
| however that is not supported on .NET CF.
|
| I'm not concerned about future portability. I'd be happy to know a
| hack to get the pointer.
 
A

azerty

Do you known the reason ?

For me it seems the more difficulty is already implemented (find the good
interop method, find the good method to manipulate a message, etc. ...)

I certainly do not see the real difficulty !

Do you think It is "creazy" to try do do a specific loop message for Modal
form ?


Chris Tacke said:
It's a known limitation of ApplicationEx that IMessageFilter implementations
don't get messages from Forms shown with ShowDialog

--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate


azerty said:
thanks a lot for your help !

I try to use this technic to realize my real purpose and everything work
fine EXCEPT
when I use ShowDialog method of a form

It is normal ! >> ShowDialog use another pump function of Framework

I did not find this type of function in OpenNetCF

may be someone developed it somewhere ?

PS : Real purpose :
I want to intercept clic action on TextBox
I want to intercept every clic action out a textBox to do sommething else,
even if the
focus doesn't change

NB : TheApplicationEx contains all method and technic to do it, I think
...


"Peter Foot [MVP]" <[email protected]> a écrit dans le message
de news:%[email protected]...
The Wnproc in the .NETCF control class doesn't receive all standard windows
messages as they have been pre-processed and it only passes through a subset
of messages (those already supported in .NETCF). So although you can
intercept these with a lot of nasty reflection code you don't actually gain
anything. Use the IMessageFilter approach with OpenNETCF's ApplicationEx
class to intercept all native windows messages (www.opennetcf.org/sdf/)

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

thanks a lot for your answer, It can help me for another point
I could use this technic with PC, all is not missing for me ;-)

In fact, The real purpose of my research is to override the WndProc of
Control object to intercept some Windows Messages.

WndProc of System.Windows.Forms.Control (CF) is virtual BUT internal !!
I can't override it

I see with reflector in _InitInstance a private delegate (m_wnproc) witch
use by Control code to intercep Windows Message of native win32 TextBox
control.

I wanted to add my own method on it with reflection methods but it is not
possible ...

May be, do you have another way to do it ???

thanks for your help !


"Alex Feinman [MVP]" <[email protected]> a écrit dans le message
de Because the native runtime does not support it. It's not enough to
fake a
pointer - there needs to be a mechanism to transfer execution from
unmanaged
to managed. We've been down this way. The answer is still, no

--
Alex Feinman
---
Visit http://www.opennetcf.org
Hello !

In previous message (see below), Dominic Cooney try to create a
delagate
by
reflexion

but MethodInfo.GetFunctionPointer doesn't exist on CF

I try another technique (work fine on PC platform)
I create a temporary Delegate on my function and use reflection to load
value in private member "_methodPtr"

The code is :

Delegate tmpDelegate = new EventHandler(Form1_EventTest);

FieldInfo fi = typeof(Delegate).GetField("_methodPtr",
BindingFlags.NonPublic |
BindingFlags.Instance);
Int32 ptrMethod = (Int32)fi.GetValue(tmpDelegate);

Delegate newDelegate = (Delegate)MyConstructorInfo.Invoke(new
object[]
{this , ptrMethod } );

it work fine on PC but throw an exception on PPC
(InvalidProgramException)

Do you know why ?

Another question : is it possible to include MSIL instruction in C#
program
(like ASM instruction in C/C++ or Delphi program) ???

thanks for your help !





De :Tim Gerken [MSFT] ([email protected])
Objet :RE: Getting function pointer/creating delegate with
Reflection


View this article only
Groupes de discussion
:microsoft.public.dotnet.framework.compactframework
Date :2003-03-05 15:24:03 PST


Sorry, Dominic, there is no way to get at this information on the .NET
Compact Framework.

Tim
This posting is provide "AS IS" with no warranties, and confers no
rights.
--------------------
| From: (e-mail address removed) (Dominic Cooney)
| Subject: Getting function pointer/creating delegate with
Reflection
| Date: 5 Feb 2003 16:48:40 -0800
|
| Is there any way to get the same pointer that ldftn returns, without
| using ldftn (i.e. via a MethodInfo or RuntimeMethodHandle)?
|
| My situation is this: Given a MethodInfo I want to create a delegate
| via Reflection. Delegate constructors require a function pointer,
| usually retrieved by ldftn. On .NET, you can retrieve a method
pointer
| via Reflection using methodInfo.MethodHandle.GetFunctionPointer(),
| however that is not supported on .NET CF.
|
| I'm not concerned about future portability. I'd be happy to know a
| hack to get the pointer.
 
C

Chris Tacke, eMVP

The "reason" is that when I wrote the classes I didn't think of it. I'll
agree it's not terribly difficulty, but I've not considered it a priority to
do it as I've got plenty of other things to do.

--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate


azerty said:
Do you known the reason ?

For me it seems the more difficulty is already implemented (find the good
interop method, find the good method to manipulate a message, etc. ...)

I certainly do not see the real difficulty !

Do you think It is "creazy" to try do do a specific loop message for Modal
form ?


"Chris Tacke, eMVP" <[email protected]> a écrit dans le
message
de news:[email protected]...
It's a known limitation of ApplicationEx that IMessageFilter implementations
don't get messages from Forms shown with ShowDialog

--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate


azerty said:
thanks a lot for your help !

I try to use this technic to realize my real purpose and everything work
fine EXCEPT
when I use ShowDialog method of a form

It is normal ! >> ShowDialog use another pump function of Framework

I did not find this type of function in OpenNetCF

may be someone developed it somewhere ?

PS : Real purpose :
I want to intercept clic action on TextBox
I want to intercept every clic action out a textBox to do sommething else,
even if the
focus doesn't change

NB : TheApplicationEx contains all method and technic to do it, I think
...


"Peter Foot [MVP]" <[email protected]> a écrit dans le message
de The Wnproc in the .NETCF control class doesn't receive all standard
windows
messages as they have been pre-processed and it only passes through a
subset
of messages (those already supported in .NETCF). So although you can
intercept these with a lot of nasty reflection code you don't actually
gain
anything. Use the IMessageFilter approach with OpenNETCF's ApplicationEx
class to intercept all native windows messages
(www.opennetcf.org/sdf/)

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

thanks a lot for your answer, It can help me for another point
I could use this technic with PC, all is not missing for me ;-)

In fact, The real purpose of my research is to override the WndProc of
Control object to intercept some Windows Messages.

WndProc of System.Windows.Forms.Control (CF) is virtual BUT internal !!
I can't override it

I see with reflector in _InitInstance a private delegate (m_wnproc)
witch
use by Control code to intercep Windows Message of native win32 TextBox
control.

I wanted to add my own method on it with reflection methods but it
is
not
possible ...

May be, do you have another way to do it ???

thanks for your help !


"Alex Feinman [MVP]" <[email protected]> a écrit dans le
message
de Because the native runtime does not support it. It's not enough to
fake
a
pointer - there needs to be a mechanism to transfer execution from
unmanaged
to managed. We've been down this way. The answer is still, no

--
Alex Feinman
---
Visit http://www.opennetcf.org
Hello !

In previous message (see below), Dominic Cooney try to create a
delagate
by
reflexion

but MethodInfo.GetFunctionPointer doesn't exist on CF

I try another technique (work fine on PC platform)
I create a temporary Delegate on my function and use reflection
to
load
value in private member "_methodPtr"

The code is :

Delegate tmpDelegate = new EventHandler(Form1_EventTest);

FieldInfo fi = typeof(Delegate).GetField("_methodPtr",
BindingFlags.NonPublic |
BindingFlags.Instance);
Int32 ptrMethod = (Int32)fi.GetValue(tmpDelegate);

Delegate newDelegate = (Delegate)MyConstructorInfo.Invoke(new
object[]
{this , ptrMethod } );

it work fine on PC but throw an exception on PPC
(InvalidProgramException)

Do you know why ?

Another question : is it possible to include MSIL instruction in C#
program
(like ASM instruction in C/C++ or Delphi program) ???

thanks for your help !





De :Tim Gerken [MSFT] ([email protected])
Objet :RE: Getting function pointer/creating delegate with
Reflection


View this article only
Groupes de discussion
:microsoft.public.dotnet.framework.compactframework
Date :2003-03-05 15:24:03 PST


Sorry, Dominic, there is no way to get at this information on the
.NET
Compact Framework.

Tim
This posting is provide "AS IS" with no warranties, and confers
no
rights.
--------------------
| From: (e-mail address removed) (Dominic Cooney)
| Subject: Getting function pointer/creating delegate with
Reflection
| Date: 5 Feb 2003 16:48:40 -0800
|
| Is there any way to get the same pointer that ldftn returns,
without
| using ldftn (i.e. via a MethodInfo or RuntimeMethodHandle)?
|
| My situation is this: Given a MethodInfo I want to create a
delegate
| via Reflection. Delegate constructors require a function pointer,
| usually retrieved by ldftn. On .NET, you can retrieve a method
pointer
| via Reflection using methodInfo.MethodHandle.GetFunctionPointer(),
| however that is not supported on .NET CF.
|
| I'm not concerned about future portability. I'd be happy to
know a
| hack to get the pointer.
 
A

azerty

Ok ! It is very good "reason" !! ;-) we are very often in this situation !!

Now, I must choice if I go in this way or not ?
In fact, It seems a very important choice, may be I will meet another
problems with this technic ?
Do you have a reverse engening of native Pump function (or exchange with
author of this function ?) to determine the better way to develop the new
function ?
Do you know big application witch use this Message Pump ?

Best Regards


Chris Tacke said:
The "reason" is that when I wrote the classes I didn't think of it. I'll
agree it's not terribly difficulty, but I've not considered it a priority to
do it as I've got plenty of other things to do.

--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate


azerty said:
Do you known the reason ?

For me it seems the more difficulty is already implemented (find the good
interop method, find the good method to manipulate a message, etc. ...)

I certainly do not see the real difficulty !

Do you think It is "creazy" to try do do a specific loop message for Modal
form ?


"Chris Tacke, eMVP" <[email protected]> a écrit dans le
message
de news:[email protected]...
It's a known limitation of ApplicationEx that IMessageFilter implementations
don't get messages from Forms shown with ShowDialog

--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate


thanks a lot for your help !

I try to use this technic to realize my real purpose and everything work
fine EXCEPT
when I use ShowDialog method of a form

It is normal ! >> ShowDialog use another pump function of Framework

I did not find this type of function in OpenNetCF

may be someone developed it somewhere ?

PS : Real purpose :
I want to intercept clic action on TextBox
I want to intercept every clic action out a textBox to do sommething else,
even if the
focus doesn't change

NB : TheApplicationEx contains all method and technic to do it, I think
...


"Peter Foot [MVP]" <[email protected]> a écrit dans le message
de The Wnproc in the .NETCF control class doesn't receive all standard
windows
messages as they have been pre-processed and it only passes through a
subset
of messages (those already supported in .NETCF). So although you can
intercept these with a lot of nasty reflection code you don't actually
gain
anything. Use the IMessageFilter approach with OpenNETCF's ApplicationEx
class to intercept all native windows messages
(www.opennetcf.org/sdf/)

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

thanks a lot for your answer, It can help me for another point
I could use this technic with PC, all is not missing for me ;-)

In fact, The real purpose of my research is to override the
WndProc
of
Control object to intercept some Windows Messages.

WndProc of System.Windows.Forms.Control (CF) is virtual BUT
internal
!!
I can't override it

I see with reflector in _InitInstance a private delegate (m_wnproc)
witch
use by Control code to intercep Windows Message of native win32 TextBox
control.

I wanted to add my own method on it with reflection methods but it
is
not
possible ...

May be, do you have another way to do it ???

thanks for your help !


"Alex Feinman [MVP]" <[email protected]> a écrit dans le
message
de Because the native runtime does not support it. It's not enough to
fake
a
pointer - there needs to be a mechanism to transfer execution from
unmanaged
to managed. We've been down this way. The answer is still, no

--
Alex Feinman
---
Visit http://www.opennetcf.org
Hello !

In previous message (see below), Dominic Cooney try to create a
delagate
by
reflexion

but MethodInfo.GetFunctionPointer doesn't exist on CF

I try another technique (work fine on PC platform)
I create a temporary Delegate on my function and use reflection
to
load
value in private member "_methodPtr"

The code is :

Delegate tmpDelegate = new EventHandler(Form1_EventTest);

FieldInfo fi = typeof(Delegate).GetField("_methodPtr",
BindingFlags.NonPublic |
BindingFlags.Instance);
Int32 ptrMethod = (Int32)fi.GetValue(tmpDelegate);

Delegate newDelegate = (Delegate)MyConstructorInfo.Invoke(new
object[]
{this , ptrMethod } );

it work fine on PC but throw an exception on PPC
(InvalidProgramException)

Do you know why ?

Another question : is it possible to include MSIL instruction
in
C#
program
(like ASM instruction in C/C++ or Delphi program) ???

thanks for your help !





De :Tim Gerken [MSFT] ([email protected])
Objet :RE: Getting function pointer/creating delegate with
Reflection


View this article only
Groupes de discussion
:microsoft.public.dotnet.framework.compactframework
Date :2003-03-05 15:24:03 PST


Sorry, Dominic, there is no way to get at this information on the
.NET
Compact Framework.

Tim
This posting is provide "AS IS" with no warranties, and confers
no
rights.
--------------------
| From: (e-mail address removed) (Dominic Cooney)
| Subject: Getting function pointer/creating delegate with
Reflection
| Date: 5 Feb 2003 16:48:40 -0800
|
| Is there any way to get the same pointer that ldftn returns,
without
| using ldftn (i.e. via a MethodInfo or RuntimeMethodHandle)?
|
| My situation is this: Given a MethodInfo I want to create a
delegate
| via Reflection. Delegate constructors require a function pointer,
| usually retrieved by ldftn. On .NET, you can retrieve a method
pointer
| via Reflection using methodInfo.MethodHandle.GetFunctionPointer(),
| however that is not supported on .NET CF.
|
| I'm not concerned about future portability. I'd be happy to
know a
| hack to get the pointer.
 
C

Chris Tacke, eMVP

The challenge is getting the modal form's events passed to the
IMessageFilter. I'd write a new ShowDialog method in ApplicationEx. In it,
create a new message pump and pass all IMessageFilters from the base into
it. This was my thinking anyway - implementation usually changes as I start
doing the actual work.

--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate


azerty said:
Ok ! It is very good "reason" !! ;-) we are very often in this situation
!!

Now, I must choice if I go in this way or not ?
In fact, It seems a very important choice, may be I will meet another
problems with this technic ?
Do you have a reverse engening of native Pump function (or exchange with
author of this function ?) to determine the better way to develop the new
function ?
Do you know big application witch use this Message Pump ?

Best Regards


"Chris Tacke, eMVP" <[email protected]> a écrit dans le
message
de news:[email protected]...
The "reason" is that when I wrote the classes I didn't think of it. I'll
agree it's not terribly difficulty, but I've not considered it a priority to
do it as I've got plenty of other things to do.

--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate


azerty said:
Do you known the reason ?

For me it seems the more difficulty is already implemented (find the good
interop method, find the good method to manipulate a message, etc. ...)

I certainly do not see the real difficulty !

Do you think It is "creazy" to try do do a specific loop message for Modal
form ?


"Chris Tacke, eMVP" <[email protected]> a écrit dans le
message
de It's a known limitation of ApplicationEx that IMessageFilter
implementations
don't get messages from Forms shown with ShowDialog

--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate


thanks a lot for your help !

I try to use this technic to realize my real purpose and everything
work
fine EXCEPT
when I use ShowDialog method of a form

It is normal ! >> ShowDialog use another pump function of Framework

I did not find this type of function in OpenNetCF

may be someone developed it somewhere ?

PS : Real purpose :
I want to intercept clic action on TextBox
I want to intercept every clic action out a textBox to do sommething
else,
even if the
focus doesn't change

NB : TheApplicationEx contains all method and technic to do it, I think
...


"Peter Foot [MVP]" <[email protected]> a écrit dans le
message
de The Wnproc in the .NETCF control class doesn't receive all standard
windows
messages as they have been pre-processed and it only passes through a
subset
of messages (those already supported in .NETCF). So although you
can
intercept these with a lot of nasty reflection code you don't actually
gain
anything. Use the IMessageFilter approach with OpenNETCF's
ApplicationEx
class to intercept all native windows messages
(www.opennetcf.org/sdf/)

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

thanks a lot for your answer, It can help me for another point
I could use this technic with PC, all is not missing for me ;-)

In fact, The real purpose of my research is to override the WndProc
of
Control object to intercept some Windows Messages.

WndProc of System.Windows.Forms.Control (CF) is virtual BUT internal
!!
I can't override it

I see with reflector in _InitInstance a private delegate (m_wnproc)
witch
use by Control code to intercep Windows Message of native win32
TextBox
control.

I wanted to add my own method on it with reflection methods but
it
is
not
possible ...

May be, do you have another way to do it ???

thanks for your help !


"Alex Feinman [MVP]" <[email protected]> a écrit dans
le
message
de Because the native runtime does not support it. It's not enough to
fake
a
pointer - there needs to be a mechanism to transfer execution from
unmanaged
to managed. We've been down this way. The answer is still, no

--
Alex Feinman
---
Visit http://www.opennetcf.org
Hello !

In previous message (see below), Dominic Cooney try to create
a
delagate
by
reflexion

but MethodInfo.GetFunctionPointer doesn't exist on CF

I try another technique (work fine on PC platform)
I create a temporary Delegate on my function and use
reflection
to
load
value in private member "_methodPtr"

The code is :

Delegate tmpDelegate = new EventHandler(Form1_EventTest);

FieldInfo fi = typeof(Delegate).GetField("_methodPtr",
BindingFlags.NonPublic |
BindingFlags.Instance);
Int32 ptrMethod = (Int32)fi.GetValue(tmpDelegate);

Delegate newDelegate =
(Delegate)MyConstructorInfo.Invoke(new
object[]
{this , ptrMethod } );

it work fine on PC but throw an exception on PPC
(InvalidProgramException)

Do you know why ?

Another question : is it possible to include MSIL instruction in
C#
program
(like ASM instruction in C/C++ or Delphi program) ???

thanks for your help !





De :Tim Gerken [MSFT] ([email protected])
Objet :RE: Getting function pointer/creating delegate with
Reflection


View this article only
Groupes de discussion
:microsoft.public.dotnet.framework.compactframework
Date :2003-03-05 15:24:03 PST


Sorry, Dominic, there is no way to get at this information on the
.NET
Compact Framework.

Tim
This posting is provide "AS IS" with no warranties, and
confers
no
rights.
--------------------
| From: (e-mail address removed) (Dominic Cooney)
| Subject: Getting function pointer/creating delegate with
Reflection
| Date: 5 Feb 2003 16:48:40 -0800
|
| Is there any way to get the same pointer that ldftn returns,
without
| using ldftn (i.e. via a MethodInfo or RuntimeMethodHandle)?
|
| My situation is this: Given a MethodInfo I want to create a
delegate
| via Reflection. Delegate constructors require a function
pointer,
| usually retrieved by ldftn. On .NET, you can retrieve a method
pointer
| via Reflection using
methodInfo.MethodHandle.GetFunctionPointer(),
| however that is not supported on .NET CF.
|
| I'm not concerned about future portability. I'd be happy to
know
a
| hack to get the pointer.
 
A

azerty

Thanks for you help, Chris

Even if I will not use in real application, I can try to develop it, just
for fun !

Another way to find the good implementation is to reverse the pump message
of full Framework ...

In the version, Microsoft use the same pump function with "Reason" int
parameter ....


Chris Tacke said:
The challenge is getting the modal form's events passed to the
IMessageFilter. I'd write a new ShowDialog method in ApplicationEx. In it,
create a new message pump and pass all IMessageFilters from the base into
it. This was my thinking anyway - implementation usually changes as I start
doing the actual work.

--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate


azerty said:
Ok ! It is very good "reason" !! ;-) we are very often in this situation
!!

Now, I must choice if I go in this way or not ?
In fact, It seems a very important choice, may be I will meet another
problems with this technic ?
Do you have a reverse engening of native Pump function (or exchange with
author of this function ?) to determine the better way to develop the new
function ?
Do you know big application witch use this Message Pump ?

Best Regards


"Chris Tacke, eMVP" <[email protected]> a écrit dans le
message
de news:[email protected]...
The "reason" is that when I wrote the classes I didn't think of it. I'll
agree it's not terribly difficulty, but I've not considered it a
priority
to
do it as I've got plenty of other things to do.

--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate


Do you known the reason ?

For me it seems the more difficulty is already implemented (find the good
interop method, find the good method to manipulate a message, etc. ....)

I certainly do not see the real difficulty !

Do you think It is "creazy" to try do do a specific loop message for Modal
form ?


"Chris Tacke, eMVP" <[email protected]> a écrit dans le
message
de It's a known limitation of ApplicationEx that IMessageFilter
implementations
don't get messages from Forms shown with ShowDialog

--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate


thanks a lot for your help !

I try to use this technic to realize my real purpose and everything
work
fine EXCEPT
when I use ShowDialog method of a form

It is normal ! >> ShowDialog use another pump function of Framework

I did not find this type of function in OpenNetCF

may be someone developed it somewhere ?

PS : Real purpose :
I want to intercept clic action on TextBox
I want to intercept every clic action out a textBox to do sommething
else,
even if the
focus doesn't change

NB : TheApplicationEx contains all method and technic to do it, I think
...


"Peter Foot [MVP]" <[email protected]> a écrit dans le
message
de The Wnproc in the .NETCF control class doesn't receive all standard
windows
messages as they have been pre-processed and it only passes
through
a
subset
of messages (those already supported in .NETCF). So although you
can
intercept these with a lot of nasty reflection code you don't actually
gain
anything. Use the IMessageFilter approach with OpenNETCF's
ApplicationEx
class to intercept all native windows messages
(www.opennetcf.org/sdf/)

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

thanks a lot for your answer, It can help me for another point
I could use this technic with PC, all is not missing for me ;-)

In fact, The real purpose of my research is to override the WndProc
of
Control object to intercept some Windows Messages.

WndProc of System.Windows.Forms.Control (CF) is virtual BUT internal
!!
I can't override it

I see with reflector in _InitInstance a private delegate (m_wnproc)
witch
use by Control code to intercep Windows Message of native win32
TextBox
control.

I wanted to add my own method on it with reflection methods but
it
is
not
possible ...

May be, do you have another way to do it ???

thanks for your help !


"Alex Feinman [MVP]" <[email protected]> a écrit dans
le
message
de Because the native runtime does not support it. It's not
enough
to
fake
a
pointer - there needs to be a mechanism to transfer execution from
unmanaged
to managed. We've been down this way. The answer is still, no

--
Alex Feinman
---
Visit http://www.opennetcf.org
Hello !

In previous message (see below), Dominic Cooney try to create
a
delagate
by
reflexion

but MethodInfo.GetFunctionPointer doesn't exist on CF

I try another technique (work fine on PC platform)
I create a temporary Delegate on my function and use
reflection
to
load
value in private member "_methodPtr"

The code is :

Delegate tmpDelegate = new EventHandler(Form1_EventTest);

FieldInfo fi = typeof(Delegate).GetField("_methodPtr",
BindingFlags.NonPublic |
BindingFlags.Instance);
Int32 ptrMethod = (Int32)fi.GetValue(tmpDelegate);

Delegate newDelegate =
(Delegate)MyConstructorInfo.Invoke(new
object[]
{this , ptrMethod } );

it work fine on PC but throw an exception on PPC
(InvalidProgramException)

Do you know why ?

Another question : is it possible to include MSIL
instruction
in
C#
program
(like ASM instruction in C/C++ or Delphi program) ???

thanks for your help !





De :Tim Gerken [MSFT] ([email protected])
Objet :RE: Getting function pointer/creating delegate with
Reflection


View this article only
Groupes de discussion
:microsoft.public.dotnet.framework.compactframework
Date :2003-03-05 15:24:03 PST


Sorry, Dominic, there is no way to get at this information
on
the
.NET
Compact Framework.

Tim
This posting is provide "AS IS" with no warranties, and
confers
no
rights.
--------------------
| From: (e-mail address removed) (Dominic Cooney)
| Subject: Getting function pointer/creating delegate with
Reflection
| Date: 5 Feb 2003 16:48:40 -0800
|
| Is there any way to get the same pointer that ldftn returns,
without
| using ldftn (i.e. via a MethodInfo or RuntimeMethodHandle)?
|
| My situation is this: Given a MethodInfo I want to create a
delegate
| via Reflection. Delegate constructors require a function
pointer,
| usually retrieved by ldftn. On .NET, you can retrieve a method
pointer
| via Reflection using
methodInfo.MethodHandle.GetFunctionPointer(),
| however that is not supported on .NET CF.
|
| I'm not concerned about future portability. I'd be happy to
know
a
| hack to get the pointer.
 
Top