|
-
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
-
Apr 10th, 2004, 10:52 AM
#2
Thread Starter
Addicted Member
Also... when you use the above code... the window is slow and the buttons don't work... anyone know the reason ?
- Visual Basic 6.0
- Windows XP Home
-
Apr 10th, 2004, 04:19 PM
#3
Frenzied Member
I'd try to find another solution to your project. The whole SetParent API function is not very usable due to just what you're talking.
What're you trying to do?
-
Apr 10th, 2004, 05:56 PM
#4
Thread Starter
Addicted Member
I'm trying to make tabbed windows for MSN Messenger... The current way I'm doing it is at the following site, but the whole way the windows are handled is very annoying as you will see if you try it...
http://www.spadeapps.com/cameno/
So suggestions to better ways would rock
- Visual Basic 6.0
- Windows XP Home
-
Apr 11th, 2004, 06:25 PM
#5
Member
I tried to do the same thing for AIM, what i think you need to try is with set parent, use set owner as well. when i did that for aim windows everything worked fine, buttons and all, but sometime ill try to give MSN a go. goodluck
Good programming site:
*http://www.planet-source-code.com
Our CS Clan Page:
*http://h2p.inter-gamer.com/index.html
-
Apr 12th, 2004, 01:50 AM
#6
Frenzied Member
Just going along with what Allen said, try this link: http://www.devx.com/vb2themax/Tip/18318
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
|