TCook said:
I actually need the window to stay open so closing the form wouldn't
work. I tried sending WM_CLOSE but to the PictureBox and it closed
the form and closed my application with it ;-)
Don't send it to the picture box! Send it to the *child* of the picture
box. You'll need to use EnumChildWindows to find this. Or, probably just
as easily, GetWindow -- *assuming* you're not dealing with a VB-authored
screensaver. It's certainly possible that multiple windows may be parented
to your picturebox, although this is unlikely unless you're totally not
paying attention. (Not sure why I felt the need to say that. <g>) At any
rate, this works here:
Option Explicit
Private Declare Function GetWindow Lib "user32" (ByVal hWnd As Long,
ByVal wCmd As Long) As Long
Private Const GW_CHILD As Long = 5
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As
Any) As Long
Private Const WM_CLOSE As Long = &H10
Private Sub cmdStart_Click()
Shell "sspipes.scr /p " & CStr(Picture1.hWnd)
End Sub
Private Sub cmdStop_Click()
Dim hWndPreview As Long
hWndPreview = GetWindow(Picture1.hWnd, GW_CHILD)
SendMessage hWndPreview, WM_CLOSE, 0&, ByVal 0&
End Sub
What I was hoping to do was simply end the process similar to ending
the process from the task manager but APIs I tried didn't stop it.
Any ideas there?
DON'T DO THAT! Huge Hammer; Petty Problem.
Later... Karl