Hi, I'm here with the last error I think will come up:
Everything goes well, the setParent works, but i can't see the button I just added to the IM window.
When looking closer, I see there is an error while processing
the 'GetWindowRect(pIMWindow.hwnd, R)' statement(at bottom of code sample).
What am I doing wrong?? please, this is probably my last error, so I appreciate your help!
code:
Imports MessengerAPI
Public Class FragMsnIMButton
Private WithEvents oMessenger As Messenger
Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr
Public Declare Function GetWindowRect Lib "user32.dll" (ByVal hwnd As Long, ByVal lpRect As RECT) As Long
Public Structure RECT
Dim x As Long
Dim y As Long
Dim Width As Long
Dim Height As Long
End Structure
Public R As RECT
Public newBtn As Object
Private Sub FragMsnIMButton_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
oMessenger = New Messenger
End Sub
Private Sub oMessenger_OnIMWindowCreated(ByVal pIMWindow As Object) Handles oMessenger.OnIMWindowCreated
'
Try
newBtn = New FragMsnIMButton ' create a copy of FragMsnIMButton
Dim child As System.IntPtr = newBtn.btnFrag.Handle.ToString
Dim par As System.IntPtr = pIMWindow.hwnd.ToString
'
SetParent(child, par)
'
Try
GetWindowRect(pIMWindow.hwnd, R)
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
'
newBtn.btnFrag.left = 13500 'Moving the textbox under the display picture
newBtn.btnFrag.right = 2800
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub
End Class