|
Sorry, I should be able to figure this out. Seems like .net should have made this easy, though.
How do I run an .exe file inside a panel or tab within my form?
thanks
|
|
|
|
|
cstrader232 wrote: Seems like .net should have made this easy, though.
Why? Why does every noobie think that the .NET Framework should be this be-all, end-all, embodiment that makes everything so much easier? What ever happened to writing code to do it yourself?
But, I digress...
cstrader232 wrote: How do I run an .exe file inside a panel or tab within my form?
It's not a good idea, because no application actually supports doing this, but it is possible to change the parent of a window to another window. You can get some strange things happening during painting, so don't say you weren't warned.
Private Declare Auto Function SetParent Lib "user32" ( _
ByVal hwndChild As IntPtr, _
ByVal hwndParent As IntPtr) _
As IntPtr
.
.
.
' Launch a new Notepad process, wait for it's window to be created
' then reset that window so it's parent is another window in our
' application. In this case, a Panel control.
Dim p As Process = Process.Start("Notepad.exe")
p.WaitForinputIdle()
SetParent(p.MainWindowHandle, Panel1.Handle)
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dave Kreskowiak wrote: What ever happened to writing code to do it yourself?
Amen.
|
|
|
|
|
Well yeah, that works. But in this case I found that someone had already done it for me!!! Here's the snippet I found to work from: Seems to be working OK for me.
Option Strict Off
Option Explicit On
Module MTestWindow
Private Const GW_HWNDNEXT As Short = 2
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal HWnd As Integer, ByRef lpdwProcessId As Integer) As Integer
Private Declare Function GetParent Lib "user32" (ByVal HWnd As Integer) As Integer
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"(ByVal lpClassName As Integer, ByVal lpWindowName As Integer) As Integer
Private Declare Function GetWindow Lib "user32" (ByVal HWnd As Integer, ByVal wCmd As Integer) As Integer
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA"(ByVal HWnd As Integer, ByVal lpString As String, ByVal cch As Integer) As Integer
Public Declare Function SetParent Lib "user32" (ByVal hWndChild As Integer, ByVal hWndNewParent As Integer) As Integer
Public old_parent As Integer
Public child_hwnd As Integer
'Show Window
'Brings back inside MDI but minimized if notepad was minimized
Private Declare Function SetForegroundWindow Lib "user32" (ByVal HWnd As Integer) As Integer
'Minimize Window
Private Declare Function CloseWindow Lib "user32" (ByVal HWnd As Integer) As Integer
'Maximize Window
Private Const SW_MAXIMIZE As Short = 3
'Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal HWnd As Integer, ByVal nCmdShow As Integer) As Integer
'Close (Terminate) Window
Const WM_CLOSE As Short = &H10s
'UPGRADE_ISSUE: Declaring a parameter 'As Any' is not supported. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="FAE78A8D-8978-4FD4-8208-5B7324A8F795"'
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal HWnd, ByVal wMsg, ByVal wParam, ByRef lParam) As Integer
Private Function InstanceToWnd(ByVal target_pid As Integer) As Integer
'Return the window handle for an instance handle.
'This came from VB-Helper, but See Q242308 appears to be original
Dim test_hwnd As Integer
Dim test_pid As Integer
Dim test_thread_id As Integer
' Get the first window handle.
test_hwnd = FindWindow(0, 0)
' Loop until we find the target or we run out
' of windows.
Do While test_hwnd <> 0
' See if this window has a parent. If not,
' it is a top-level window.
If GetParent(test_hwnd) = 0 Then
' This is a top-level window. See if
' it has the target instance handle.
test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid)
If test_pid = target_pid Then
' This is the target.
InstanceToWnd = test_hwnd
Exit Do
End If
End If
' Examine the next window.
test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT)
Loop
End Function
Public Function ShowMDIMinimized(ByRef lngHWnd As Integer) As Object
'This brings the Window as minimized within the MDI Form
'if it was originally hidden
Dim dl As Integer
dl = SetForegroundWindow(lngHWnd)
End Function
Public Function MinimizeWindow(ByRef lngHWnd As Integer) As Object
'Hide the Window
Dim dl As Integer
dl = CloseWindow(lngHWnd) '<<minimize
="" end="" function
="" public="" function="" maximizewindow(byref="" lnghwnd="" as="" integer)="" object
="" 'maximize="" the="" window
="" if="" <=""> 0 Then
ShowWindow(lngHWnd, SW_MAXIMIZE)
End If
End Function
Public Function FreeWindowFromMDI(ByRef hChild As Integer, ByRef hOldParent As Integer) As Object
SetParent(hChild, hOldParent)
End Function
Public Function TerminateWindow(ByRef lngHWnd As Object) As Object
'Post a message to the window to close itself
'UPGRADE_WARNING: Couldn't resolve default property of object lngHWnd. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
PostMessage(lngHWnd, WM_CLOSE, 0, 0)
End Function
Public Function RunWindow(ByRef strApp As String) As Object
Dim pid As Integer
' Dim buf As String
' Dim buf_len As Long
' Dim styles As Long
' Start the program.
pid = Shell(strApp, AppWinStyle.NormalFocus)
If pid = 0 Then
MsgBox("Error starting program")
Exit Function
End If
' Get the window handle.
child_hwnd = InstanceToWnd(pid)
MDIForm1.Text = Str(child_hwnd)
' Reparent the program so it lies inside
' the MDI form.
old_parent = SetParent(child_hwnd, MDIForm1.Handle.ToInt32)
End Function
End Module
|
|
|
|
|
hello friends
i m doing my pg in computer science can anyone suggest me a good topic for project.
|
|
|
|
|
hi,
r u talking about any dummy(sample)projects??
u can develop the sample applications like Student management system, Banking system, AddressBook, Personal Assistant,
Shopping cart,Webbased Address Book etc., if u r looking for sample applications,long back i saw one site where u can find the sample applications with source code. just check the urls for the sample applictions. but it's better to take the specification from that site and try to develop ur self by implementing ur own ideas.
u can find sample applications in microsoft site also.
check these links:
1. http://msdn2.microsoft.com/en-us/library/5ekc8at3(VS.80).aspx
2. http://support.businessobjects.com/communityCS/FilesAndUpdates/ce_vbnet_samples.exe.asp
3. a href=http://aspalliance.com/crystal/
4. http://www.binaryintellect.net/products/displayproductlist.aspx?categoryid=1
5. http://support.dtsearch.com/webhelp/dtengine/sample_applications.htm
thanks,
Rahithi Sharma
-- modified at 1:01 Saturday 20th January, 2007
-- modified at 1:08 Saturday 20th January, 2007
If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Can anyone suggest the method to include an applet(run it) in a VB 6 form
mmmm
|
|
|
|
|
u had to ask that thrice?
ik pair past mein,te dooja pair future mein.tabhi to aaj pe moot rahe hain.
|
|
|
|
|
Can anyone suggest the method to include an applet(run it) in a VB 6 form
|
|
|
|
|
how to delete records from database using vb.net & mysql
priya
|
|
|
|
|
|
hi,
Thank You for help.
will you help me in my Udate Query?
If editFlag Then ''---------------Update Logic---------------
' Create the UpdateCommand.
cmd = New MySqlCommand("UPDATE cust_mast SET Address=?addr where custname=?
name;", conn)
cmd.Parameters.Add("?addr", MySqlDbType.VarChar, 200, txtAddr.Text)
parm = cmd.Parameters.Add("?custname", MySqlDbType.VarChar, 15, txtCustName.Text)
da.UpdateCommand = cmd
da.Update(ds, "cust_mast")
da.Fill(ds, "cust_mast")
Above code i wrote on my Update button,it is not giving any error but not affecting database.
Will u tell me how shuld i update my receords?
priya
|
|
|
|
|
When you need to perform an SQL statement that doesn't retrieve any data, you can use the ExecuteNonQuery method. So you will not need a DataAdapter object. You just use the command object. So you will need a line that looks like this:
cmd.ExecuteNonQuery()
The da.Fill(ds, "cust_mast") line that you have in your code is really only to be used for an sql select statement.
Hope this helps.
|
|
|
|
|
hi gud morning
thnx for help
priya
|
|
|
|
|
I am using datagridview with 4 columns 10 rows
I want sum data in column 1 how can i do?
Thanks
................
|
|
|
|
|
I'd write a function to either a) sum that values in the dataset that the grid view is bound to or b) query the database directly.
|
|
|
|
|
I still don't understand can u give me through example?
Thanks
................
|
|
|
|
|
I have insert some record to datagrid, how can i save to file?
Thanks
................
|
|
|
|
|
|
Any files such as Excel, TExt file,.......
................
|
|
|
|
|
Hi
This is Parikshit...
I want to ask you question about encryption and decryption of a zip file.
I m trying to encrypt a zip file but it is not getting encrypted by using
Rijndael algorithm.
can anybody help me out by giving some sample examples.
using vb.net plz...
Thanx
|
|
|
|
|
Why don't you just password protect it ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi,
I am using cross-tabs report for reporting in crystal reports for .net 2005. When the width of the report exceeds the width of the page so it cuts off the rest of pages.
|
|
|
|
|
Have you tried resizing or restructuring the layout? I think that would be the first step.
|
|
|
|
|
hi all frends,
im using datagridview on my form (VB.net(winforns).
i am filling datagridview on formload.
i have clearAll button, so i want to clear all records of my datagridview whn user clicks on clear button.
Plz tell me how to code for it.
Thanks & Regards Priya.
priya
|
|
|
|