469,890 Members | 1,425 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,890 developers. It's quick & easy.

Bringing second form to front when first gets focus (keeping both windows on top)

I have a VB.NET application that consists of a toolbar and a subwindow
that I want to function together and not independently. So when I
give focus to one, I want to make sure that the other is visible on
the screen (brought to front, right behind the one in focus).

I've played with the activated event of each form, but everything I've
tried so far fails, as it's a pretty cyclical process that gets
initiated. I'd love any help... here's what I have so far that
doesn't work... heh.

-----------------------
'PUBLIC
Dim bIgnoreActivation as Boolean = False
-----------------------
'SUB-WINDOW

Private Sub frmSubWindow_Activated(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Activated

'IF THIS WAS THE ORIGINAL WINDOW GIVEN FOCUS
If Not bIgnoreActivation Then
'SET OUR IGNORE FLAG SO THE OTHER WINDOW
'KNOWS IT WASN'T ORIGINALLY CALLED
bIgnoreActivation = True
frmToolbar.BringToFront()
End If

Me.BringToFront()

'SET THE FLAG BACK
bIgnoreActivation = False

End Sub

------------------------
'TOOLBAR

Private Sub frmToolbar_Activated(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Activated

'IF THIS WAS THE ORIGINAL WINDOW GIVEN FOCUS
If Not bIgnoreActivation Then
'SET OUR IGNORE FLAG SO THE OTHER WINDOW
'KNOWS IT WASN'T ORIGINALLY CALLED
bIgnoreActivation = True
frmSubWindow.BringToFront()
End If

Me.BringToFront()

'SET THE FLAG BACK
bIgnoreActivation = False
End Sub

Feb 5 '07 #1
3 2436
"papalarge" <kw****@gmail.comschrieb
I have a VB.NET application that consists of a toolbar and a
subwindow
I guess this means a toolbar /window/ and a sub window. Otherwise it sounds
like a free floating toolbar and a sub window of that toolbar.

Have you tried passing the toolbar window as the owner of the sub window?
In toolbar window:
dim t as new subwindow
t.show(me)

It does have influence on the focus, like the sub window automatically being
minimized whenever you minimize the toolbar window (IIRC), but I don't know
if it also has the effect you're looking for.
Armin

Feb 6 '07 #2
Yeah, toolbar + subwindow is right...

What's the inherited baseclass of subwindow? Can't find that in
VB.NET....


On Feb 6, 2:12 am, "Armin Zingler" <az.nos...@freenet.dewrote:
"papalarge" <kwy...@gmail.comschrieb
I have a VB.NET application that consists of a toolbar and a
subwindow

I guess this means a toolbar /window/ and a sub window. Otherwise it sounds
like a free floating toolbar and a sub window of that toolbar.

Have you tried passing the toolbar window as the owner of the sub window?
In toolbar window:
dim t as new subwindow
t.show(me)

It does have influence on the focus, like the sub window automatically being
minimized whenever you minimize the toolbar window (IIRC), but I don't know
if it also has the effect you're looking for.

Armin

Feb 28 '07 #3
Didn't understand you at first, but just got it working a second ago.
On form load, set the subwindows owner to the toolbar, which allowed
them coincide when they receive focus.

Thanks Armin!
On Feb 6, 2:12 am, "Armin Zingler" <az.nos...@freenet.dewrote:
"papalarge" <kwy...@gmail.comschrieb
I have a VB.NET application that consists of a toolbar and a
subwindow

I guess this means a toolbar /window/ and a sub window. Otherwise it sounds
like a free floating toolbar and a sub window of that toolbar.

Have you tried passing the toolbar window as the owner of the sub window?
In toolbar window:
dim t as new subwindow
t.show(me)

It does have influence on the focus, like the sub window automatically being
minimized whenever you minimize the toolbar window (IIRC), but I don't know
if it also has the effect you're looking for.

Armin

Feb 28 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Brett Romero | last post: by
1 post views Thread by John | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.