Any criteria on selecting the startup form? - vb.net

Question:
In .NET do you have any criteria that qualifies a certain form to be the startup form?
Example:
For example, if I have a basic calculator program and it has 3 forms
namely frmConfig, frmCalculator and frmProfile.
frmConfig - The settings page, includes whether I should automatically round off or out put the whole decimals, etc.
frmCalculator - The main page, the calculator itself where you can do all the calculations that you want.
frmProfile - The login page, you can see the history of your calculations here.
Notes:
From that 3 different kinds of forms how do I properly choose the
startup form?
Does it mean that the startup form should always be the first form to see
when the application is running?
Because for example I can make the frmConfig as the startup form then on OnLoad event of it it will hide itself then open the frmCalculator because frmCalculator depends on frmConfig's default setting.
To make this question not broad I am looking for the most common way of setting up the startup form, maybe there is a standard way?

You can set your startup form by accessing the My Project from the Solution Explorer, then going to the Application page
Image: Choosing startup form

Related

Global FormClosing/Load events in .NET

I'm using VB.NET 4.7.2
I have a multi-form application and I'm coding the "Window" menu on top to show open forms so the user can easily switch (now that Win11 has forced combining applications on the taskbar).
I need each open form to be able to handle the FormOpening and Load events generated by other forms. My current solution is to handle those events locally in each form, which then triggers a custom global event that any other form can handle.
But that's a little tedious - is it possible for one form to handle another form's closing or opening without this workaround?
You could subclass a standard form to do all the scut work of registering with the shared global and hooking other forms events. You then just need to change the forms header to point at the subclasses type and off you go.

Make a VBA form appear in windows task bar

I am programming a little application (an overgrown macro really) in Visual Basic for Applications in Office 365. What it does is:
Displays one window that has a few input fields.
Once I fill out those fields with data I can press a button on the form and a summary in a nice graphical form is displayed in a second window (a second form is displayed using UserForm2.show).
The second user form can be updated with new data by typing in updated text in first form and updating the second form by pressing a button on the first form (in the form of UserForm2.TextField1.Text = UserForm1.Label1.Text.
Both forms are modeless so the user can work in Outlook whilst the forms are running.
All works fine except one caveat:
Both forms are not visible on the Windows Taskbar, in the Task Manager, but most importantly they are not visible as separate windows to teleconferencing software we are using. And this is the macro's sole purpose.
Question: Is it possible to make the entire macro (or just UserForm2) run as if it was a separate application, so it appears in the Task Bar as a separate window, and not an internal form running inside Outlook?
The idea is not to run it independently of Outlook (or Excel), but to make them visible to external programs.
I tried a few options available on the Internet, but none of them work, and honestly I do not know where to begin, or how to circumvent it if it is not possible to do directly within the available API. Can you advise?

VB.NET - Export hidden form as application.

It is possible to export one hidden form as a fully application including icon?
Form example I have two forms, the main one with one button and the hidden one with a message box on loading event. What I want is after the button from first form is pressed the hidden from (form2) to be built as a standalone application in a path selected by me with an icon from a selected path or from resources.
If this is impossible I heard about one method where you first create an application, then you combine the code from something1.vb and something2.vb, then you can use them to compile in another application.
Sorry for this bad explained request. Thank you so much!
No. It´s not possible to compile code at runtime - if I understood what you need.
You can at maximum:
1 - Create an EXE application and ZIP it.
2 - In your 1st form, unzip the application into a folder.
But certainly you will have troubles with antivirus and, in the best situation, in your unziped application since it wasn´t correctly installed.

Making multiple forms appear as one in VB.NET

I am writing a Windows Forms application in VB.NET. I have three forms: the main form, which shows a list of accounts, the account form which allows the user to view/edit the information for a specific account, and the policy form which allows the user to view/edit the information on a specific policy for that account. I want the forms to appear as if they are all the same window. Example: when the application starts, the user clicks an account name in the list box on the main form and clicks "edit". What I want to happen is that the window stays in the exact same place and stays the same exact size, only the content of the main form appears to be replaced with the content of the account form. Same thing if the user then chooses to edit a policy from the account form. When the user finishes and clicks "save", the main form comes back up. Through this entire use case, it would appear to the user as if they were viewing the same window the entire time, with the content of that window changing.
How can I do this? I have tried something like:
Dim newForm as New AcctForm
newForm.Location = Me.Location
newForm.Show()
Me.Close()
The problem is that if the user moves the original window, the new window appears where the parent form originally appeared, not where it ended up.
I see this is already in the comments, but what I have done in this case in the past is build each "form" in the application as a custom control. Then I have one actual form, and navigation works by changing which custom control is currently loaded on the parent form. To move from one screen/view to another, you remove the current custom control from the form's controls collection and add the new custom control.
I believe this is superior to manually setting the startup position and size, because you can use the form's .SuspendLayout()/.ResumeLayout() methods to hide the interim state, where there is no control loaded, from the user. This is harder to do when you want one form to be completely replaced by another.
This also makes it easy to set certain form properties in one place and have them be consistent for the application. You can even have an area on the form with controls that will now show in every view.
When using this pattern, I typically have each of my custom controls inherit from a common base. You may not have anything specific you will do with that base at the outset, but it almost always comes in handy later.
Finally, switching to use this scheme is easier than you think. Just go to the code for the each of your current forms, and you will find that each class currently inherits from System.Windows.Forms.Form. Most of the time, all you really need to do is change them to inherit from System.Windows.Forms.Panel and you're most of the way there.
As others have said, it may be better to redesign your application using custom controls or panels etc.
However, to answer your question regarding the seemingly random location of your forms, the first thing to check is that each form has it's StartPosition property set to Manual.
If your main form is resizable, then I would also add code to adjust newForm to the same size too.
I hope that helps with your immediate issues; so that you can move on to redesigning the application!
good morning there is another way . set property for second form to (top most) and use also
from2.show();
that make you switch between forms and keep form2 top other
Thanks
try using ShowDialog()
Dim newForm as New AcctForm
newForm.Location = Me.Location
newForm.ShowDialog()
Me.Close() <-- removed this

Modify Outlook Form Code programmatically

How to programmatically get at outlook form code?
To clarify from one of the comments - Outlook form code is the VBA code that sits behind the form - it can be customised in the form design mode to do pretty much what the user needs to do.
Our product relies heavily on form code, but certain bits of it need to be customised per installation. We are looking for some way to automate this process, as we have upwards of 30 custom forms it is a tedious process to do it manually...:-)
Use a configuration file (use ReadFile etc)
Or put the configuration information in a "special" item in a public shared folder
You can also use the "Office Profile Wizard" to package it up with a custom vba module iwht the configuration information in that
You should never write out customised code, that is a big can of worms