﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WinForms (How do I?)  » How to show a form that needs to be hidden immediately.</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Sat, 06 Jun 2026 17:47:23 GMT</lastBuildDate><ttl>20</ttl><item><title>How to show a form that needs to be hidden immediately.</title><link>http://forum.strataframe.net/FindPost19032.aspx</link><description>I have a form that I'd like to load, but have it hidden immediately. I'm currently just setting visible to False after it's done loading, but there is flicker. Is there a suggested way to do this.</description><pubDate>Wed, 17 Dec 2008 11:43:41 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: How to show a form that needs to be hidden immediately.</title><link>http://forum.strataframe.net/FindPost21254.aspx</link><description>Just noticed that I never let y'all know what I actually did. I ended up adding a method to the form to show the browse dialog, then if the dialog returns OK, show the form. Sort of a combo between what I was trying and what Trent suggested:&lt;br&gt;
&lt;br&gt;
[codesnippet]' In the form that I wanted hidden...&lt;br&gt;
Public Sub Search()&lt;br&gt;
&amp;nbsp;&amp;nbsp;' Open search form, test for OK&lt;br&gt;
&amp;nbsp;&amp;nbsp;Using myBrw As New MyBrowseDialog()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If myBrw.ShowDialog() = DialogResult.OK Then&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Me.Show()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Else&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Me.Close&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End If&lt;br&gt;
&amp;nbsp;&amp;nbsp;End Using&lt;br&gt;
End Sub[/codesnippet]&lt;br&gt;
&lt;br&gt;
And it is called like this&lt;br&gt;
[codesnippet]'  To run a search...&lt;br&gt;
Dim frm As New MyForm()&lt;br&gt;
frm.Search()[/codesnippet]</description><pubDate>Wed, 17 Dec 2008 11:43:41 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: How to show a form that needs to be hidden immediately.</title><link>http://forum.strataframe.net/FindPost19202.aspx</link><description>When I have the need for this, I take a different approach.&amp;nbsp; First, show the BrowseDialog THEN show the form.&amp;nbsp; It would look something like this:&lt;/P&gt;&lt;P&gt;[codesnippet]Dim myBrw As New MyBrowseDialog()&lt;BR&gt;Dim myBO As New MyBO()&lt;BR&gt;Dim myForm as MyForm&lt;/P&gt;&lt;P&gt;'-- Set the BO to populate (otherwise an error will occur)&lt;BR&gt;myBrw.BusinessObjectToPopulate = myBO&lt;/P&gt;&lt;P&gt;'-- Show the Browse&lt;BR&gt;If myBrw.ShowDialog() = OK Then&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; '-- Create and show the form.&amp;nbsp; Pass over the populated BO and then just do a CopyDataFrom in the Constructor&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; '-- of the form.&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myForm = New MyForm(myBO)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; '-- Now show the dialog or show it in your MDI (whatever your need is)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myForm.ShowDialog()&lt;BR&gt;End If[/codesnippet]</description><pubDate>Tue, 09 Sep 2008 10:03:07 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: How to show a form that needs to be hidden immediately.</title><link>http://forum.strataframe.net/FindPost19071.aspx</link><description>Nope, that won't work as this is being called in a class that isn't a form at all. :pinch:&lt;br&gt;
&lt;br&gt;
I've also tried:&lt;br&gt;
&lt;br&gt;
- setting the location off the screen (-3200,-3200)&lt;br&gt;
- setting the size to zero&lt;br&gt;
- locking the MDI parent form using ScreenLock&lt;br&gt;
- minimizing the form&lt;br&gt;
- calling visible before show&lt;br&gt;
- Hiding the form in the VisibleChanged event&lt;br&gt;
&lt;br&gt;
Nothing worked. In every case, there is a brief moment when the form is shown before going away.&lt;br&gt;
&lt;br&gt;
I'm still curious if this can be done, so if anyone has any thoughts I'd love to hear them!&lt;br&gt;
&lt;br&gt;
However, my understanding of garbage collection wasn't complete. I assumed that the parent form would stick around after the search form was closed. Then I got the brilliant idea to actually test this and put a breakpoint in the dispose method (hey what can I say...apparently both brain cells are active today).  Turns out that when the search form is closed, before the main form has been shown, it is disposed of immediately! There was no problem to solve!  DOH! :pinch:&lt;br&gt;
&lt;br&gt;
Thanks for your help though, Edhy.  It did get me thinking, which lead to some google searches that lead to the other brain cell firing. :w00t:</description><pubDate>Thu, 04 Sep 2008 13:47:39 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: How to show a form that needs to be hidden immediately.</title><link>http://forum.strataframe.net/FindPost19067.aspx</link><description>What about something like this:&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;FONT color=#0000ff size=2&gt;&lt;/P&gt;&lt;P&gt;Public&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Shared&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; OpenMyForm(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ByVal&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; projectID &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Integer&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MicroFour.StrataFrame.Tools.LockScreen.Lock(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#1f5080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; frm &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;FONT size=2&gt; MyForm(projectID)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; frm.MDIParent = MainForm&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; frm.Visible = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;False&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MicroFour.StrataFrame.Tools.LockScreen.Unlock()&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#1f5080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;' This method on the form calls the search form&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; frm.Search()&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;[/codesnippet]</description><pubDate>Thu, 04 Sep 2008 12:50:14 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: How to show a form that needs to be hidden immediately.</title><link>http://forum.strataframe.net/FindPost19064.aspx</link><description>Well, I'm probably even more confused. Here's what I'm trying to do:&lt;br&gt;
&lt;br&gt;
I've written my own "browse" dialog (long story) and want to be able to open a form, show that dialog, not the form.  The user then does a search, selects one or more records and clicks a "view" button.  At this point my form loads those records into its BO and is shown.&lt;br&gt;
&lt;br&gt;
However, I needed to handle the case were the user closes the search form before selecting any records to open. My concern was that if I didn't show the form, it wouldn't get garbage collected. I'm using code like this to open the form:&lt;br&gt;
&lt;br&gt;
[codesnippet]Public Shared Sub OpenMyForm(projectID as integer)&lt;br&gt;
Dim frm As New MyForm(projectID)&lt;br&gt;
frm.MDIParent = MainForm&lt;br&gt;
' This method on the form calls the search form&lt;br&gt;
frm.Search()&lt;br&gt;
End Sub[/codesnippet]&lt;br&gt;
&lt;br&gt;
I was originally just showing my search dialog before I'd loaded the form (before the Show() method had been called).  Maybe this is OK? &lt;br&gt;
&lt;br&gt;</description><pubDate>Thu, 04 Sep 2008 12:35:56 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: How to show a form that needs to be hidden immediately.</title><link>http://forum.strataframe.net/FindPost19062.aspx</link><description>Greg,&lt;/P&gt;&lt;P&gt;I am a bit confused here, when you create the instance of the form, it is not visible, so you should have access to it before you set it form.Visible = True.&lt;/P&gt;&lt;P&gt;Also the lock method are to be work not in the form itself, but in the calling class where you are creating your form, so it will lock that view, your form will be created, then will unlock the previous locked view.&lt;/P&gt;&lt;P&gt;How are you calling your form?</description><pubDate>Thu, 04 Sep 2008 12:20:57 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: How to show a form that needs to be hidden immediately.</title><link>http://forum.strataframe.net/FindPost19061.aspx</link><description>Thanks Edhy. I didn't know that one existed (or forgot about it).&lt;br&gt;
&lt;br&gt;
It's not working though. Here is the code that I tried. It still shows the form, at least the outline of it before it is hidden.&lt;br&gt;
&lt;br&gt;
[codesnippet]MicroFour.StrataFrame.Tools.LockScreen.Lock(Me)&lt;br&gt;
Me.Show()&lt;br&gt;
Me.Visible = False&lt;br&gt;
MicroFour.StrataFrame.Tools.LockScreen.UnLock()[/codesnippet]&lt;br&gt;
&lt;br&gt;
Any other ideas?</description><pubDate>Thu, 04 Sep 2008 12:15:51 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: How to show a form that needs to be hidden immediately.</title><link>http://forum.strataframe.net/FindPost19034.aspx</link><description>Hi Greg,&lt;P&gt;How about&amp;nbsp;wrapping your code with a LockScreen:&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;/P&gt;&lt;FONT size=2&gt;&lt;P&gt;MicroFour.StrataFrame.Tools.LockScreen.Lock(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/P&gt;&lt;/FONT&gt;&lt;P&gt;... Your code&lt;/P&gt;&lt;FONT size=2&gt;&lt;P&gt;MicroFour.StrataFrame.Tools.LockScreen.UnLock()&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;P&gt;[/codesnippet]</description><pubDate>Wed, 03 Sep 2008 20:31:58 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item></channel></rss>