Grazie ho risolto, ma mi si è presentato un altro problema che forse dovrebbe essere l'ultimo scoglio:
in VB .Net ho questo codice:
codice:
Friend Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Int32, ByVal msg As Int32, ByVal wParam As Int32, _
ByRef lParam As RECT) As Int32
dove RECT è una struttura di questo tipo:
codice:
Friend Structure RECT
Public left As Integer
Public top As Integer
Public right As Integer
Public bottom As Integer
Public Sub New(ByVal rect As Rectangle)
MyClass.New(rect.Left, rect.Top, rect.Right, rect.Bottom)
End Sub 'New
Public Sub New(ByVal left As Integer, ByVal top As Integer, ByVal right As Integer, ByVal bottom As Integer)
Me.left = left
Me.top = top
Me.right = right
Me.bottom = bottom
End Sub 'New
Public Function ToRectangle() As Rectangle
Return New Rectangle(Me.left, Me.top, Me.right - Me.left, Me.bottom - Me.top)
End Function 'ToRectangle
End Structure 'RECT
nella classe viene richiamata la sendmessage in questo modo
codice:
SendMessage(parent.Handle.ToInt32, WM_SYSCOMMAND, SC_CONTEXTHELP, Nothing)
La conversione in C# che ho fatto risulta quindi
codice:
//Strutture RECT
internal struct RECT
{
int left;
int top;
int right;
int bottom;
public RECT(Rectangle r) : this(r.Left, r.Top, r.Right, r.Bottom)
{
}
public RECT(int l, int t, int r, int b)
{
this.left = l;
this.top = t;
this.right = r;
this.bottom = b;
}
public Rectangle toRectangle()
{
return new Rectangle(this.left, this.top, this.right - this.left, this.bottom - this.top);
}
};
//API SendMessage
[DllImport("user32.dll", EntryPoint = "SendMessage", SetLastError = true, CharSet = CharSet.Auto)]
public static extern int SendMessage(int hwnd, int msg, int wParam, RECT lParam);
//Richiamo la funzione
SendMessage(parent.Handle.ToInt32(), WM_SYSCOMMAND, SC_CONTEXTHELP, null)
Quest'ultima operazione genera un errore di tipo:
"La corrispondenza migliore del metodo di overload per 'fourth_button.titleButton.SendMessage(int, int, int, fourth_button.titleButton.RECT)' presenta alcuni argomenti non validi"
e ovviamente in seguito
Argomento '4': impossibile convertire da '<null>' a 'fourth_button.titleButton.RECT'
Come posso risolvere?