Re: [RESOLVED] UserControl
If I use the get handle by PID that wont happen
Code:
Private Sub ShellMSPaint()
PID = Shell("C:\windows\system32\mspaint.exe", vbHide)
End Sub
Private Sub EmbedMSPaint()
'
' Embed MSPaint
'
If PID > 0 Then
Do
MSPaintHwnd = GetHwnd(PID)
If MSPaintHwnd > 0 Then Exit Do
Loop
SetParent MSPaintHwnd, UserControl.hWnd
Else
MsgBox "Unable To Embed MSPaint"
End If
End Sub
Private Function GetHwnd(ByVal ProcessID As Long) As Long
'
' Get Hwnd from Process ID
'
Dim lHwnd As Long, RetHwnd As Long, RetPID As Long
lHwnd = GetDesktopWindow()
RetHwnd = GetWindow(lHwnd, GW_CHILD)
Do While RetHwnd
If IsWindowVisible(RetHwnd) Then
GetWindowThreadProcessId RetHwnd, RetPID
If RetPID = ProcessID Then
Exit Do
End If
End If
RetHwnd = GetWindow(RetHwnd, GW_HWNDNEXT)
Loop
GetHwnd = RetHwnd
End Function
Re: [RESOLVED] UserControl
Ok, another suggestion: do not shell mspaint.exe with the full path, not every Windows is in C:\Windows (mine is not)
mspaint.exe is in the system path, so you can shell it with just the filename (or get the Windows\system32 path with some API call).
Re: [RESOLVED] UserControl
Good suggestion. I changed it to use name only
Re: [RESOLVED] UserControl
the only reason for to add an exe into a resource is to deploy there, it will be a smaller file size and also load that much slower, because it has to inflate the file size of each of the exe files
Re: [RESOLVED] UserControl
Quote:
Originally Posted by
Eduardo-
Ok, another suggestion: do not shell mspaint.exe with the full path, not every Windows is in C:\Windows (mine is not)
mspaint.exe is in the system path, so you can shell it with just the filename (or get the Windows\system32 path with some API call).
Code:
Shell (App.Path & "\Paint.exe"), vbNormal
Re: [RESOLVED] UserControl
Post to the OP: How can this thread be resolved, because we haven't covered any ground work here on in the thread, here right about now, even. please post your results so that we can be able to figure out if the thread can be resolved properly, even :(+<
Re: [RESOLVED] UserControl
Resolved at post #17
Code:
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
If Ambient.UserMode Then
Shell "mspaint.exe", vbHide
End If
End Sub
Re: [RESOLVED] UserControl
-- That was what the OP was looking for, gee sorry!!