PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Little nudge in the right direction-VBForums
Results 1 to 6 of 6

Thread: Little nudge in the right direction

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    At my computer
    Posts
    187

    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:
    1. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    2. 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
    3. Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    4. 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
    5.  
    6. Private Declare Function RedrawWindow Lib "user32" (ByVal hwnd As Long, lprcUpdate As Any, ByVal hrgnUpdate As Long, ByVal fuRedraw As Long) As Long
    7.  
    8. Private Const RDW_ALLCHILDREN As Long = &H80
    9. Private Const RDW_ERASE As Long = &H4
    10. Private Const RDW_INVALIDATE As Long = &H1
    11.  
    12.  
    13. Sub RefreshWindow()
    14.     RedrawWindow Me.hwnd, ByVal 0&, ByVal 0&, RDW_INVALIDATE Or RDW_ALLCHILDREN Or RDW_ERASE
    15. End Sub
    16.  
    17.  
    18. Private Sub Command1_Click()
    19.     Dim IMWindow As Long, dui As Long
    20.  
    21.     IMWindow = FindWindow("IMWindowClass", vbNullString)
    22.     diu = FindWindowEx(IMWindow, 0&, "DirectUIHWND", vbNullString)
    23.     'Stop
    24.     SetParent diu, Me.hwnd
    25.     MoveWindow dui, 0, Command1.Height, Me.ScaleWidth, Me.ScaleHeight - Command1.Height, 1  'Doesn't work for some reason
    26.     RefreshWindow
    27. End Sub
    28.  
    29. Private Sub Form_Resize()
    30.     RefreshWindow
    31. End Sub
    - Visual Basic 6.0
    - Windows XP Home

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    At my computer
    Posts
    187
    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

  3. #3
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,630
    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?
    Please rate my post.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    At my computer
    Posts
    187
    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

  5. #5
    Member
    Join Date
    Mar 2004
    Location
    Texas
    Posts
    53
    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

  6. #6
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,630
    Just going along with what Allen said, try this link: http://www.devx.com/vb2themax/Tip/18318
    Please rate my post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width