473,394 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Help with forms class.

I have a VB application with one main form. I also have a second form
that has the ShowInTaskbar property set to False.

If i click another application in the taskbar (for example:- Outlook)
then that application now has focus and covers up my application. If
I then click my application within the taskbar the main form is active
and is displayed above all other windows. The problem i have is that
the second form is still hidden behind all the other forms.

I thought that if i use the BringToFront() method within the
frmMain_GotFocus event it would also bring the second form to the
front but it doesn't. It seems that the GotFocus event is not fired
if i click my application within the taskbar.

Does anybody know what event I need?

Sep 13 '07 #1
4 1427
<te******@gmail.comschrieb
I have a VB application with one main form. I also have a second
form that has the ShowInTaskbar property set to False.

If i click another application in the taskbar (for example:-
Outlook) then that application now has focus and covers up my
application. If I then click my application within the taskbar the
main form is active and is displayed above all other windows. The
problem i have is that the second form is still hidden behind all
the other forms.

I thought that if i use the BringToFront() method within the
frmMain_GotFocus event it would also bring the second form to the
front but it doesn't. It seems that the GotFocus event is not fired
if i click my application within the taskbar.

Does anybody know what event I need?

The Activated event. But, if you handle it in Form1 and call Form2's
Activate method, you will never be able to activate Form1: Each time you try
to activate it, Form2 is activated. Even if the application has not lost the
focus.

Therefore I would handle the case when the application is activated:

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)

Const WM_ACTIVATEAPP As Integer = &H1C

MyBase.WndProc(m)

If m.Msg = WM_ACTIVATEAPP AndAlso m.WParam <IntPtr.Zero Then
Debug.WriteLine("application activated")
'--insert code here <--
End If

End Sub

Though, what I don't understand: If you activate Form1 in the taskbar, why
do you want to activate Form2? You clicked on Form1. What you are trying is:
Always activate Form2 if the application gets the focus. If Form2 is that
important, why isn't it shown in the taskbar?

That's why I solely write MDI applications: All application windows in one
big frame. Don't know if it's possible with your application.
Armin

Sep 13 '07 #2
On 13 Sep, 16:16, "Armin Zingler" <az.nos...@freenet.dewrote:
<teeja...@gmail.comschrieb


I have a VB application with one main form. I also have a second
form that has the ShowInTaskbar property set to False.
If i click another application in the taskbar (for example:-
Outlook) then that application now has focus and covers up my
application. If I then click my application within the taskbar the
main form is active and is displayed above all other windows. The
problem i have is that the second form is still hidden behind all
the other forms.
I thought that if i use the BringToFront() method within the
frmMain_GotFocus event it would also bring the second form to the
front but it doesn't. It seems that the GotFocus event is not fired
if i click my application within the taskbar.
Does anybody know what event I need?

The Activated event. But, if you handle it in Form1 and call Form2's
Activate method, you will never be able to activate Form1: Each time you try
to activate it, Form2 is activated. Even if the application has not lost the
focus.

Therefore I would handle the case when the application is activated:

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)

Const WM_ACTIVATEAPP As Integer = &H1C

MyBase.WndProc(m)

If m.Msg = WM_ACTIVATEAPP AndAlso m.WParam <IntPtr.Zero Then
Debug.WriteLine("application activated")
'--insert code here <--
End If

End Sub

Though, what I don't understand: If you activate Form1 in the taskbar, why
do you want to activate Form2? You clicked on Form1. What you are trying is:
Always activate Form2 if the application gets the focus. If Form2 is that
important, why isn't it shown in the taskbar?

That's why I solely write MDI applications: All application windows in one
big frame. Don't know if it's possible with your application.

Armin- Hide quoted text -

- Show quoted text -
Thanks mate.

I did try using the BringToFront() method within the frmMain_Activated
event procedure and I did come accross that problem!! how annoying!!

Thanks for the code mate, works brilliantly.

Sep 14 '07 #3
If I program an application with multiple forms and not within an MDI, I
always use a main form and other forms are shown as modal which should avoid
your problem.
--
Dennis in Houston
"te******@gmail.com" wrote:
On 13 Sep, 16:16, "Armin Zingler" <az.nos...@freenet.dewrote:
<teeja...@gmail.comschrieb


I have a VB application with one main form. I also have a second
form that has the ShowInTaskbar property set to False.
If i click another application in the taskbar (for example:-
Outlook) then that application now has focus and covers up my
application. If I then click my application within the taskbar the
main form is active and is displayed above all other windows. The
problem i have is that the second form is still hidden behind all
the other forms.
I thought that if i use the BringToFront() method within the
frmMain_GotFocus event it would also bring the second form to the
front but it doesn't. It seems that the GotFocus event is not fired
if i click my application within the taskbar.
Does anybody know what event I need?
The Activated event. But, if you handle it in Form1 and call Form2's
Activate method, you will never be able to activate Form1: Each time you try
to activate it, Form2 is activated. Even if the application has not lost the
focus.

Therefore I would handle the case when the application is activated:

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)

Const WM_ACTIVATEAPP As Integer = &H1C

MyBase.WndProc(m)

If m.Msg = WM_ACTIVATEAPP AndAlso m.WParam <IntPtr.Zero Then
Debug.WriteLine("application activated")
'--insert code here <--
End If

End Sub

Though, what I don't understand: If you activate Form1 in the taskbar, why
do you want to activate Form2? You clicked on Form1. What you are trying is:
Always activate Form2 if the application gets the focus. If Form2 is that
important, why isn't it shown in the taskbar?

That's why I solely write MDI applications: All application windows in one
big frame. Don't know if it's possible with your application.

Armin- Hide quoted text -

- Show quoted text -

Thanks mate.

I did try using the BringToFront() method within the frmMain_Activated
event procedure and I did come accross that problem!! how annoying!!

Thanks for the code mate, works brilliantly.

Sep 16 '07 #4
"Dennis" <De****@discussions.microsoft.comschrieb
If I program an application with multiple forms and not within an
MDI, I always use a main form and other forms are shown as modal
which should avoid your problem.
It should avoid the problem but maybe he wants to show them modeless.

Another way is making Form1 the owner of Form2, but then Form2 is always in
front of Form1 - which might also be someting he does not want.
Armin

Sep 16 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sudheer Kareem | last post by:
Dear All Please tell me how to assosiate help files with my Vb.net Project. Regards Sudheer
4
by: Mike | last post by:
Please help this is driving me nuts. I have 2 forms, 1 user class and I am trying to implement a singleton class. Form 1 should create a user object and populate some properties in user. Form2...
5
by: MFC | last post by:
Ok, after three C# books, (C# How to Program, Programming in the Key of C#, and C# Weekend Crash Course) and three weeks, I believe I have tried everything to make a certain form function...
2
by: Brian | last post by:
I am very new to VB.NET and I just need some help in a listbox matter. I don't need suggestions on how to make the overall code better. I will get there. I want to move an item from one list box...
5
by: Edwinah63 | last post by:
Hi everyone, i was wondering if anyone else had observed this and if there is any workaround or patch. i have some screens (an mdi child forms) with the buttons &Add, &Edit, &Save and E&xit,...
1
by: Michael D. Reed | last post by:
I am using the help class to display a simple help file. I generated the help file using Word and saving it as a single page Web page (.mht extension). I show the help file with the following...
6
by: cj | last post by:
Lets just take this example I'm looking at now. I'm looking at the help screen titled .NET Framework Class Library FolderBrowserDialog Class . It gives an example at the bottom that begins with:...
0
by: Brian Henry | last post by:
Ok I've never implemented a snap location before so I dont really know what im doing wrong here... anyways, I am making a custom slider control that takes dates as its values instead of integers......
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
1
by: Troy Bull | last post by:
Greetings I am trying to use a singleton to hold a group of forms. I have a MDIMaster form. I have a class called Forms; Forms is a singleton. I want to do something like the following. In...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.