run program in your from ?!
Hi Guys
Is there any way to run windows program like c:\WINDOWS\system32\calc.exe inside my form
For example:
This is my form I want to run the calc inside my form !!? is it possible Pls help me with the code how to do it !?
http://hh7.net/Jul5/hh7.net_13113717191.jpg
Please advice :wave:
Re: run program in your from ?!
VB Code:
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Sub Form_Load()
Dim lngHandle As Long
Picture1.AutoRedraw = True
Shell "c:\WINDOWS\system32\calc.exe", vbNormalFocus
lngHandle = FindWindow(vbNullString, "Calculator")
SetParent lngHandle, Picture1.hwnd
End Sub
Re: run program in your from ?!
Or maybe better
VB Code:
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName 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" (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 GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Sub Form_Load()
Dim lngHandle As Long
Dim rec As RECT
Picture1.AutoRedraw = True
Form1.ScaleMode = vbPixels
Shell "c:\WINDOWS\system32\calc.exe", vbNormalFocus
lngHandle = FindWindow(vbNullString, "Calculator")
GetWindowRect lngHandle, rec
SetParent lngHandle, Picture1.hwnd
Picture1.Width = rec.Right - rec.Left
Picture1.Height = rec.Bottom - rec.Top
' The first 5 parameters are required but weonly care about the 1st three
MoveWindow lngHandle, 0, 0, Picture1.Width, Picture1.Height, 1
End Sub
Re: run program in your from ?!
Thanks a lot .. just I want to save that presented program which is running there in Picture1 as image in c:\running.jpg
Pls help me in this thing ..
Re: run program in your from ?!
Re: run program in your from ?!
ok I'm using that code to capture the picturec.1 .. but how to can I save it in as c:\running.jpg
http://www.vbforums.com/showthread.php?t=331889