|
-
Apr 18th, 2003, 12:09 AM
#1
Thread Starter
Member
Showing Forms In A Specific Way Dilemma [RESOLVED]
I have searched first and not found anything that matches what I'm after.
I'm doing the usual:
Click button on Form1 and show Form2
Click button on Form2 and back to Form1
That's all OK, trouble is, the controls and pictures and infact all the form does a quick sort of flicker when changing forms, yuk, now I have found away around it, which I have to do, but it's causing me some grief.
So initially what's happening is this:
Button clicked/form1 hide/form2 shown (showdialog)
Button clicked/form2 hide(disposed)/form1 shown
It's this gap from hide to show that's causing the flicker.
What I need is this:
Button (form1) clicked/form2 shown/form1 then hidden
Button (form2) clicked/form1 shown/form2 then hidden/disposed
Now I've done this and it looks much much better, just what I want, trouble is, lol, I get an extra form1 on the taskbar evertime I do it.
Does anyone know how to do what I'm after, remember it needs to do this:
Form1: Button Clicked - Form2 Shown - Form1 Hidden
Form2: Button Clicked - Form1 Shown - Form2 Hidden/Disposed
Thanks for anyones help.
Last edited by JustAProg; Apr 18th, 2003 at 12:28 PM.
-
Apr 18th, 2003, 12:18 AM
#2
Fanatic Member
Forms expose a .ShowInTaskbar property that you can modify at runtime.
ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfsystemwindowsformsformclassshowintaskbartopic.htm
so you could set form 2 to not show in taskbar, show the second form, then hide the first form, then set form 2 to show in taskbar.
-
Apr 18th, 2003, 12:29 AM
#3
Frenzied Member
Trying this (in form1) I noticed no flicker.
VB Code:
Dim frm as New From2
Me.Hide
frm.Showdialog
Me.Show
You may also try this to hide form1 when form2 is loaded.
So you put this in form2
VB Code:
Dim frm As Form
#Region " Windows Form Designer generated code "
Public Sub New(ByVal frm) 'ByVal frm As Form)
MyBase.New()
Me.frm = frm
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
frm.Hide()
End Sub
and this in form1
VB Code:
Dim frm as New From2(Me)
frm.Showdialog
Me.Show
so you could set form 2 to not show in taskbar, show the second form, then hide the first form, then set form 2 to show in taskbar.
the problem is not showing in taks bar. The problem is he is producing a new form1 in his code.
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Apr 18th, 2003, 12:47 AM
#4
Fanatic Member
-
Apr 18th, 2003, 01:01 AM
#5
Thread Starter
Member
The first one is what I usually use, I just tried again, it has horrendous flicker, only when going to form 2 though, not back.
The last one gave me errors:
Dim frm As New Form2(me)
It wouldn't except the 'me'
I changed it to Dim frm As New Form2, ran it, then gave me a 'object/instance' error at the frm.hide in form2
-
Apr 18th, 2003, 01:28 AM
#6
Thread Starter
Member
For instance, this is the closest I've come:
In Form1 Button:
Code:
Dim Form2 As New Form2
Form2.Show()
Me.Hide()
In Form2 Button:
Code:
Dim Form1 As New Form1
Form1.Show()
Me.Close()
Now this actually works perfect, you dont see one form dissapear briefly before the other gets displayed, it's all smooth, as you would expect because a form is shown before the other hides.
Trouble is, even though I can't see them I must be making multiple form 1's everytime I display it as the prog wont then shut down and I have to use the 'STOP' in the IDE.
-
Apr 18th, 2003, 01:42 AM
#7
Frenzied Member
The last one gave me errors:
Dim frm As New Form2(me)
It wouldn't except the 'me'
it means that you have not made the required changes in form2.
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Apr 18th, 2003, 02:10 AM
#8
Thread Starter
Member
Yes you're right, I'd forgot the '(ByVal frm)'. Unfortunetly though it still didn't work, just done the same as the original method. I can still see the half a second or so of 'nothing' whilst one form dissapears before the other is drawn.
-
Apr 18th, 2003, 02:42 AM
#9
Frenzied Member
You may also try this:
Instead of hiding the form1 in load event of form2
try to hide it in activated event:
VB Code:
Private Sub Form2_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
Static isactive As Boolean
If Not isactive Then
frm.Hide()
isactive = True
End If
End Sub
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Apr 18th, 2003, 06:34 AM
#10
Thread Starter
Member
Hi again.
That is sort of actually working. I now get a nice transistion to form2, but form2 only, still get the problem going back to form1.
-
Apr 18th, 2003, 06:57 AM
#11
Frenzied Member
Actually i dont know if it makes any difference or not(i dont guess so), however try showing form1 in close event of form2.
VB Code:
Private Sub Form2_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
frm.Show()
End Sub
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Apr 18th, 2003, 08:26 AM
#12
Thread Starter
Member
You genius, now that seems to work, can't mess too much at the moment, will later, I'll let ya know.
-
Apr 18th, 2003, 12:27 PM
#13
Thread Starter
Member
Yep, that does it, cool.
Cheers mate, it was really getting to me that one.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|