Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Must forms reside in the .exe or can I place then in .dll? 2

Status
Not open for further replies.

Nicholas

IS-IT--Management
Feb 2, 2000
15
0
0
US
I have been working on a programme in which the main .exe now contains 21 forms! Without creating a 50-form executable, can forms be designed within a .dll and called from the main .exe through code.<br>

<br>

If so, how would the form be called?<br>

<br>

Thank you!<br>

Nick
 
Some very large programs i.e. Accounting packages Use one main .EXE to call other .EXE's<br>
Maybe that would be a workaround for you.<br>

 
Possibly; however it would be necessary to prevent users from launching each .exe as a standalone. Folks are naturally curious and will do just that - by encapsulating the form/code in a .dll this is more easily prevented.<br>
<br>
Calling the .dll and sharing info between forms would be problematic for me at this point in my experience. <p>Nicholas, Bank of America NetO<br><a href=mailto: > </a><br><a href= > </a><br>
 
Well in that case put a &quot;Command&quot; statement in each child .EXE that looks at how it was executed.<br>
If it was launched from the main app pass an argument to the child. <br>
Like so in the main <br>
Private Sub cmdPayroll_Click()<br>
Retval = Shell(App.Path & Payroll.exe & &quot; /RunMe&quot;, 1)<br>
End Sub<br>
<br>
' In the child's (Payroll in our example) load event have<br>
If Command &lt;&gt; &quot;/RunMe&quot; Then End<br>
<br>
<br>
If it is run by itself then the &quot;Command&quot; will be blank. and the program will load and end without even showing up on the screen.<br>
<br>

 
You can place forms in a DLL, but you have to have a Public createable class in the same DLL with some code to show the form.<br>
<br>
For example:<br>
<br>
Public Sub ShowAccountingForm()<br>
frmAccounting.Show<br>
End Sub<br>
<br>
You need to create a public method for each form that you have in the DLL. This does not always lend itself well, since most of the time forms are used for data collection. The problem is that all the data is on the form and now you have no way of getting it off of there, unless you create more public properties or methods for the form.<br>
<br>
If the above example was in a Class called CForms, then to call it from the main program you would do this:<br>
<br>
Dim objForms as CForms<br>
<br>
Set objForms = New CForms<br>
objForms.ShowAccountingForm<br>
set objForms = Nothing<br>
<br>
This would show the form. While it is do-able, it's probablly more trouble than it's worth. If you're really bent on doing it this way, I would create a public createable class for each from. Then I would declare all my public properites to match any of the input on the form. The problem comes in when you have a Combo box or List box where you have several things that need to go in it. At this point you're just wrapping the functionality of existing controls. This brings be back to the statement that it's probablly more trouble than it's worth.<br>
<br>
-Steve
 
VB Project: ActiveX DLL<br>
<br>
The Form: frmMyClass<br>
<br>
Option Explicit<br>
Public FMyClass as CMyClass<br>
<br>
Private Sub Form_Load()<br>
With FMyClass<br>
txtName = .Name<br>
txtDescription = .Description<br>
......<br>
End With<br>
End Sub<br>
<br>
Private Sub Form_Unload()<br>
With FMyClass<br>
.Name = txtName<br>
.Description = txtDescription<br>
......<br>
End With<br>
end sub<br>
<br>
<br>
The Class Module: CMyClass<br>
<br>
Public Sub Show()<br>
Dim F as new frmMyClass<br>
Set F.FMyClass = Me<br>
F.Show VbModal<br>
End Sub <p>Roy Lofquist<br><a href=mailto:roylofquist@msn.com>roylofquist@msn.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top