Shoutbox

Button in chat window - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Forum: Plug-Ins (/forumdisplay.php?fid=28)
+------ Thread: Button in chat window (/showthread.php?tid=53432)

Button in chat window by posseke on 11-29-2005 at 09:39 AM

Hi,

Is it possible to add a similar button in the chat window like the one patchou added for quicktext and sounds next to the typing area?

I would like to be able to change settings for my plugin in each chat window, whereas now I'm stuck on a external application that reads config settings from an XML file

Thanks for your opinion/remarks


Kenny


RE: Button in chat window by RaceProUK on 11-29-2005 at 01:02 PM

Why not use the menu on the menubar? (Press Alt).


RE: Button in chat window by posseke on 11-29-2005 at 01:26 PM

That is an option I considered, but is there any way to create something as I described in my first post?
The plugin is kkinda ready for use, but I need a good spot/position for the users to access the functionalities...


RE: Button in chat window by matty on 11-29-2005 at 02:24 PM

Check this out: http://forums.msnfanatic.com/index.php?showtopic=11496

Obviously needing to be changed for the Conversation Window.


RE: Button in chat window by posseke on 11-29-2005 at 05:25 PM

Thx matty, i'm diggin' into that stuff right now, looks very nice indeed... exactly what i was looking for!

When my plugin(MsnFrag) is ready, I'll post it out here so you guys can beta test...


RE: Button in chat window by Stigmata on 11-29-2005 at 05:51 PM

quote:
Originally posted by Matty
Check this out: http://forums.msnfanatic.com/index.php?showtopic=11496

Obviously needing to be changed for the Conversation Window.

http://forum.mess.be/index.php?showtopic=4318

^^ A version for a chat window i did a long time ago :)

RE: Button in chat window by posseke on 11-29-2005 at 07:24 PM

Here's one thing I don't understand, the form created to handle the textbox/button/image, it must exist at all time, but not visible?


RE: Button in chat window by Stigmata on 11-29-2005 at 07:28 PM

basically yes :P


RE: Button in chat window by posseke on 11-29-2005 at 07:46 PM

K, it's working real nice for me, viva los handles ^^


RE: Button in chat window by posseke on 11-29-2005 at 08:32 PM

K, sorry to whine again, but i'm getting an error in VB.NET saying the ShowWindow method is wrongly declared.
Is it possible that in .NET, this method has new paramaters? or am I just making the worst mistake ever?

Public Class FragMsnIMButton
    Private WithEvents oMessenger As MessengerAPI.Messenger
    Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    <Runtime.InteropServices.DllImport("user32.dll")> _
    Private Shared Function ShowWindow(ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    End Function


    Private Sub FragMsnIMButton_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        oMessenger = New MessengerAPI.Messenger
    End Sub

    Private Sub oMessenger_OnIMWindowCreated(ByVal pIMWindow As Object) Handles oMessenger.OnIMWindowCreated
        'ShowWindow(pIMWindow.hwnd, 2) ' maximize the window so that it works
        Dim newBtn As Object
        Dim imhwnd As Long
        newBtn = New FragMsnIMButton ' create a copy of FragMsnIMButton
        imhwnd = pIMWindow.hwnd
        SetParent(newBtn.btnFrag.hwnd, imhwnd)
        newBtn.btnFrag.left = 13500 'Moving the textbox under the display picture
        newBtn.btnFrag.top = 2800 ' ^^ look up
    End Sub


RE: Button in chat window by matty on 11-29-2005 at 09:17 PM

You declared it wrong (Atleast this is what Microsoft says it should be after a VB6 form being upgraded to .Net)

code:
Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Integer, _
                                                 ByVal nCmdShow As Integer) _
                                                 As Integer


And as well dont set the oMessenger object to MessengerApi.Messenger as this will cause the Windows Messenger application to actual run. Instead set it to oMessenger when you actually make the plugin.
RE: Button in chat window by posseke on 11-29-2005 at 10:03 PM

code:
    Private Sub oMessenger_OnIMWindowCreated(ByVal pIMWindow As Object) Handles oMessenger.OnIMWindowCreated
        Dim newBtn As Object
        Dim imhwnd As System.IntPtr
        newBtn = New FragMsnIMButton ' create a copy of FragMsnIMButton
        imhwnd = pIMWindow.hwnd
        Me.Parent = SetParent(newBtn.btnFrag.hwnd, imhwnd)
        GetWindowRect(pIMWindow.hwnd, R)
        newBtn.btnFrag.left = R.Height - 200 'Moving the textbox under the display picture
        newBtn.btnFrag.right = R.Width - 100
    End Sub


I have one problem here, when I open a IM window, the code executes untill

code:
...
imhwnd = pIMWindow.hwnd


executes this last line, shows the window, and then stops executing the rest of the code...

Any ideas?
RE: Button in chat window by RaceProUK on 11-29-2005 at 10:14 PM

That line's a simple assignment, so should work fine. Are you sure it's not hanging on the SetParent?


RE: Button in chat window by posseke on 11-29-2005 at 10:16 PM

SetParent is also giving the same problem...


RE: Button in chat window by posseke on 11-29-2005 at 10:45 PM

OK, solved one part of the problem, the code now executes untill setParent, but this last method won't work because the button I put on the form doens't have a 'hwnd'...


code:
Try
            SetParent(newBtn.btnFrag.hwnd, imhwnd)
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        End Try


It's all about conversion from VB6 -> VB.NET . I found in this last error that one must use the button.Handle method to obtain the correct pointer for that object.

So now I'm still converting code :p

BTW, I'm using VS 2005 Professional, in case you're wondering.
Built on the 2.0 NET Framework
RE: Button in chat window by posseke on 11-29-2005 at 11:36 PM

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