Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi!

I'm making like a taskbar. I have just one problem: I want the program to do:
ShowInTaskbar = False
when it gets focus.

This line of code works:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


And my question is: is it possible to write something like this? :
Private Sub Form1_OnFocus


I can't make it work.

Thanks for help.
Posted
Comments
Tarun.K.S 22-Oct-10 11:28am    
it is possible to get like this Private Sub Form1_GetFocus
but basically what do you want to do?

So, there are a couple of places that you could start. First, you could go here: Form Events (System.Windows.Forms)[^] and look through the events. Just do a find for Focus and you'll find an event called "GotFocus".

The other thing that you can do is go into your debugger and see what events are available. I'll assume you're using Visual Studio since that's the more common. Somewhere in VS you will find the Properties Window. It looks like this: http://yfrog.com/f3propertie[^].

You'll notice the lightning bold towards the top. If you click on that, it will show you all of the events that are available to hook in to. Now this will not show you all of the events but it shows you quite a few.

In this case, though, GotFocus is not one of them. So, to hook it, you can do it two ways. The VB version of Visual Studio is nice because it still provides you with drop-downs in the code editor with all of the events that you can hook. So, go into your code for the form and look at the top left drop-down. From it, select "(Form1 Events)" (or whatever your form name is). Then in the right drop-down, select the GotFocus event. This will set up the event handler and add the code.

For future work, though, I would look into Event programming more in depth and see the other ways you can do it. And, seriously, msdn is always the place to start if you want to know something about a control.
 
Share this answer
 
Comments
William Winner 22-Oct-10 12:59pm    
If you're going to vote me a one, you should have the courage to at least say why...
euhiemf 22-Oct-10 13:37pm    
Thank you, I will try that!, I'm using Visual Studios.
My suggestion is "try it, and see". You have all the tools you need to experiemnt with your code, including a debugger.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900