|
-
Apr 10th, 2004, 10:46 AM
#1
Thread Starter
Addicted Member
Little nudge in the right direction
OK, I'm stuck. What I'm trying to do is place MSN Messenger IM windows inside my form. The first way I thought of doing this was to use SetParent on them, remove the title bar, and resize it accordingly. This works well, except there are a lot of focus problems: you click in the IM window and my window does not get focus. This leads to many, many problems.
So, I thought, why not take just the actual chat box, and not the IM window. For those of you who don't know, there is the main IM window, which is of the IMWindowClass, and inside there is one child control called DirectUIHWND. So I thought I could just pull that out. This actually works, but there are redrawing issues, and I don't think the IM Window wants to let its only child go.
Below is the code I'm using... I'm wondering if anyone knows how to get it to redraw correctly., or how to possibly tell the main IM window to get over the fact the DirectUIHWND window is gone.
Fire up VB, make the form plenty big, put a command button in the top corner, paste the code below, start MSN, open a chat window, and run the project and click the button.
VB Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function MoveWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal x As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Private Declare Function RedrawWindow Lib "user32" (ByVal hwnd As Long, lprcUpdate As Any, ByVal hrgnUpdate As Long, ByVal fuRedraw As Long) As Long
Private Const RDW_ALLCHILDREN As Long = &H80
Private Const RDW_ERASE As Long = &H4
Private Const RDW_INVALIDATE As Long = &H1
Sub RefreshWindow()
RedrawWindow Me.hwnd, ByVal 0&, ByVal 0&, RDW_INVALIDATE Or RDW_ALLCHILDREN Or RDW_ERASE
End Sub
Private Sub Command1_Click()
Dim IMWindow As Long, dui As Long
IMWindow = FindWindow("IMWindowClass", vbNullString)
diu = FindWindowEx(IMWindow, 0&, "DirectUIHWND", vbNullString)
'Stop
SetParent diu, Me.hwnd
MoveWindow dui, 0, Command1.Height, Me.ScaleWidth, Me.ScaleHeight - Command1.Height, 1 'Doesn't work for some reason
RefreshWindow
End Sub
Private Sub Form_Resize()
RefreshWindow
End Sub
- Visual Basic 6.0
- Windows XP Home
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|