I have an application with several FixedToolWindow forms and one Sizable window form inside MDIParent form which runs maximized. If i run FixedToolWindows while Sizable window is unloaded, FixedToolWindows runs with correct sizes.
But if I try to run a FixedToolWindow while the Sizable window running in maximized mode, all the FixedToolWindows gets maximized too.
Following is the code, i use to load forms,
If Application.OpenForms().OfType(Of frmFrontEndLED).Any Then
MessageBox.Show("Already opened")
Else
Dim frmFendLED As New frmFrontEndLED()
'Set the Parent Form of the Child window.
frmFendLED.MdiParent = Me
'Display the New form.
frmFendLED.TopMost = True
frmFendLED.Show()
End If
What am i doing wrong?. How can i correct this?
Related
I have a WinForms application which uses webview2 to embed an Edge browser window in my application. It works great, but when the user clicks a link within it, it opens an extra "child" window. That's fine too, but if that child window is left open, it causes the web application to timeout, so I'd like to close them automatically after a time.
I tried the common solutions to close open forms, but they only get the top level forms, and never these child ones.
I've tried this code to close them all, but the dynamically opened forms are not closed:
Public Sub CloseAllForms()
Dim FormList As ArrayList = New ArrayList()
'Add all opened forms into a Collection.
For Each Frm As Form In Application.OpenForms
FormList.Add(Frm.Name)
Next
'Now Close the forms
For Each FormName As String In FormList
If FormName <> "frmMain" Then Application.OpenForms(FormName).Close()
Next
End Sub
How can I reference these windows so that I can close them on a schedule?
This is probably behavior by design, but I'll ask anyway -
I call a form from another project dll in my main project. It is NOT Modal (ShowDialog) or TopMost, and I set a variable for the form once it's created ("frm = New ..."), so that I can check when it's already been created (user clicks a toolbar button to create it initially.)
The form displays, fires events etc. all perfectly.
However, if I MINIMIZE the form and then call frm.Show through code to bring it back, nothing happens. The form remains minimized.
frm.Show has no affect and doesn't seem to fire any other events.
The only way to bring it back is to click on the taskbar icon for the MAIN form, which then displays the MAIN form AND the minimized forms (as icons), and then click on the icon for the minimized form.
I've tried various events (.Activate, .Show, .ShowDialog, .Focus) NOTHING will bring the other form out of its minimized state other than physically clicking on the Taskbar MAIN app icon and then selecting it.
Also, the main application is not MDI...
???
Thanks.
normally this should do it as suggested by #jimi
[TheForm].WindowState = FormWindowState.Normal
But sometimes this does not works for some dark reason, so you could use some other methods
form.Show();
form.BringToFront();
if (form.WindowState == FormWindowState.Minimized)
{
ShowWindowAsync(form.Handle, 9); // 9 = SW_RESTORE
}
I am sure there is one of these that will fix your problem
My goal is this: Program opens, small form initializes things, displaying text status updates as it does this, and when its done, it goes away and the actual main program form appears, allowing you to use it. Ive tried Me.Hide() and Me.Visible = False however both leave the initial small form open, with the actual program opened directly behind it. The small form is set as the main form to open to in VB config.
You can use a workaround. It will minimize the form and hide it from taskbar:
Me.WindowState = FormWindowState.Minimized
Me.ShowInTaskbar = False
Later, when you want to exit the application, do it in standard way: by closing this (hidden) form.
I am having this weird problem in Visual Basic (2013). I have a form in MDI container. Both of them, have property WindowState to Maximized. While executing, MDI container loads in maximized state (So far Ok!). But, when I open the child form, it Does NOT give the Actual Maximized state appearance (although Restore button on top right shows that it has loaded in maximized state, but it did not maximized).
I even tried with form1.WindowState = FormWindowState.Maximized both before and after form1.Show(), but no luck.
I have attached a screenshot too. Note the dead space of MDI container and Restore icon of child form (which means child form is in maximized state).
Few observations -
When I restore and then again maximize it, it DOES maximize correctly.
I also observed that this problem is occurs only for one time. I mean, if I have 2 forms both set to load in Maximized state. When I open the first form (no matter which), it loads like i showed in the screenshot, and after that when I open 2nd form, it loads in maximized state.
I could not figure out, what went wrong? How to correct this?
go to your form properties. Set windowsState = normal. then put this to code
Dim frmC As New frmChild
frmC.MdiParent = Me
frmC.WindowState = FormWindowState.Maximized
frmC.Show()
I found that setting the MDI child form to maximized within the New routine of the class works always OK.
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
Me.WindowState = FormWindowState.Minimized
End Sub
OK, the last line may be one you may code under a condition...
Check your icon. It must contain a 16x16 page. If the smallest is 32x32, the problem you illustrate will arise.
I'm working with a set of custom controls (including a custom form), I have repainted the custom form to give it a metro style look and basically recreated the title bar of the form. Setting this form to be an MDI container causes the whole form to be repainted grey regardless of anything dictated in the OnPaint handler for the form.
I want to create a multi form application where all of the forms that are not the main form, appear inside the main form (the idea of MDI windows). I have also seen a SetParent API that achieves a similar effect without modifying its visuals, however, I have used this before to tie a cmd window to a form and it is not always reliable.
Would it be more efficient to use the MDI feature inside Winforms (if so, how do i overcome the complete recolour issue) or dump MDI and use the SetParent API to modify the child windows' parent?
EDIT: I have decided to go for using the SetParent API, it works everytime as opposed to my previous experiences with the console window. However, I need to create the window before I can set the parent and sometimes the user can see the screen flash briefly before it gets 'hooked' inside my main form. Is there a way to 'hook' it without it being visible to the user?
With MDI Parent Form if your issue is the background, then this is all you have to do, Set the IsMDIContainer property of the form to true, and then loop through each control on MDI Form to let them know this is the MDI Background, you can put this code in the form loading event,
Private Sub FormMDI_Load(sender As Object, e As EventArgs) Handles MyBase.Load
For Each ctl As Control In Me.Controls
If TypeOf ctl Is MdiClient Then
ctl.BackColor = Me.BackColor
End If
Next ctl
End Sub
It might appear gray when program is not running, but it will show your desired background once the program runs