Good Day, I need create dll for execute inside it, a new form of the same project
Printable View
Good Day, I need create dll for execute inside it, a new form of the same project
HiQuote:
Originally Posted by yamivill
:confused: could you be more clearer on what is that you are looking for? You want a DLL to execute inside what and a New form in What ..... ?????
We need integrate some visual basic projects, and we think do it, using instructions from a dll Activex module. Can this do it?.
Thanks
Hello, community..
Answer to previous messages with an example.
I have 2 Business Applications, Inventory and Account, and we want integrate their executing from the same window.
For that, I created a New Exe Project VB, with an MDI Form inside and added it a New Exe Dll Activex Project. Finally I have the following VB Project Structure:
|Project1
| |____MDIForm1(Form1)
|Project2
| |____Class Module
| |_____Class1
Now, I change Project2 like initial Project. After, I designed inside MDIForm1(Form1) 2 buttons, BInven and BAcco. We want, the instructions of the class1 module, invoke for:
1.- Execute MDIForm(Form1) first.
2.- Execute 2 external systems. The first one Inventory.exe and the second one Account.exe for each MDIForm(Form1) button, BInven and BAcco.
3.- Convert them, in MDIChild of the our Principal MDIForm1(Form1).
That is our need, for now. How I Can do this (examples please) ?, Is possible, development this Idea?
:confused:
I resolved my need. I found in the google spanish group the answer. I annexed the original visual Basic routine for you, if you need it. It isn't exactly answer, but help us.
Bye
:)
'Begin routine for Excel Application
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias
"FindWindowA" (ByVal
lpClassName As Long, ByVal lpWindowName As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long)
As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As
Long,
ByVal hWndNewParent As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal
hwnd
As Long, lpdwProcessId As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long,
ByVal
wCmd As Long) As Long
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock
As
Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As
Long) As
Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal
hProcess As
Long, ByVal uExitCode As Long) As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function Putfocus Lib "user32" Alias "SetFocus" (ByVal
hwnd
As Long) As Long
Const GW_HWNDNEXT = 2
Dim mWnd As Long
Function InstanceToWnd(ByVal target_pid As Long) As Long
Dim test_hwnd As Long, test_pid As Long, test_thread_id As Long
'Find the first window
test_hwnd = FindWindow(ByVal 0&, ByVal 0&)
Do While test_hwnd <> 0
'Check if the window isn't a child
If GetParent(test_hwnd) = 0 Then
'Get the window's thread
test_thread_id = GetWindowThreadProcessId(test_hwnd,
test_pid)
If test_pid = target_pid Then
InstanceToWnd = test_hwnd
Exit Do
End If
End If
'retrieve the next window
test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT)
Loop
End Function
Private Sub MDIForm_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: [email protected]
Dim Pid As Long
'Lock the window update
LockWindowUpdate GetDesktopWindow
'Execute notepad.Exe
Pid = Shell("c:\winnt\notepad.EXE", vbNormalFocus)
If Pid = 0 Then MsgBox "Error starting the app"
'retrieve the handle of the window
mWnd = InstanceToWnd(Pid)
'Set the notepad's parent
SetParent mWnd, Me.hwnd
'Put the focus on notepad
Putfocus mWnd
'Unlock windowupdate
LockWindowUpdate False
End Sub
Private Sub MDIForm_Unload(Cancel As Integer)
'Unload notepad
DestroyWindow mWnd
'End this program
'Lo de abajo cierra hasta el VB
'TerminateProcess GetCurrentProcess, 0
End Sub