Hi, a while ago I posted a thread about how to implement my own command button on a IM window of MSN.
This seems to work, at least the part of showing the button on the window.
I'm having problems with positioning the new button into the window:
The button is allways in the upper left corner of each window, and no matter what code i write to position the button, it doesn't work...
frustrating, I know
Maybe good to know: I'm programming in VBNET so the code I'm giving you is probably a lil different from VB6 syntax
code:
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 IntPtr, ByVal lpRect As RECT) As IntPtr
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 = New RECT
Public newBtn As FragMsnIMButton
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 = Me.btnFrag.Handle
Dim par As System.IntPtr = pIMWindow.hwnd.ToString
'
SetParent(child, par)
'
Try
'GetWindowRect(par, R)
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
'
newBtn.Left = 13500
newBtn.Top = 2800
'
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub
So that is my main concern. Another concern is the error I'm getting while executing the 'GetWindowRect(par, R)' method.
It's something like 'attempt to overwrite protected memory'... If anyone knows anything about that, all help is welcome.
Thanks,
Kenny