Execute on Focus

  • Thread starter Thread starter Bernie Hunt
  • Start date Start date
B

Bernie Hunt

I started this off in the wrong group, so I'm moving to here. I need to tell
when my application has received focus. I'd like to hook the Windows
subclass and look for WM_ACTIVATEAPP. There is a VB6 demonstration of how to
do this at;
http://vbnet.mvps.org/code/subclass/activation.htm

Unfortunately I'm still struggling up the learning curve of VB.net. Has
anyone seen or have a chunk of code that does this in VB.net? I'd like an
example to at least get me started in the right direction.

Thanks,
Bernie
 
Bernie,

Did you know that this is a VBNet newsgroup for some of us VB6 is more than
three years behind. Can you tell what you want to achieve instead that we
have to examine some VB6 code?

What do you want to say with received focus (probably is therefore a simple
activated event in VBNet) and what do you than want to do?


Cor
 
Cor Ligthert said:
Bernie,

Did you know that this is a VBNet newsgroup for some of us VB6 is
more than three years behind. Can you tell what you want to achieve
instead that we have to examine some VB6 code?

Umm.. I think he is looking for a VB.Net equivalent of the VB6 code, not a
VB6 solution. This is possible in this group. :-)
What do you want to say with received focus (probably is therefore a
simple activated event in VBNet) and what do you than want to do?


WM_ACTIVATEAPP is send to an application if the application got or lost the
focus (from a different application). The activated event also fires when
the active window within your own applicaton changes.

Armin
 
Bernie Hunt said:
I started this off in the wrong group, so I'm moving to here. I need
to tell when my application has received focus. I'd like to hook the
Windows subclass and look for WM_ACTIVATEAPP. There is a VB6
demonstration of how to do this at;
http://vbnet.mvps.org/code/subclass/activation.htm

Unfortunately I'm still struggling up the learning curve of VB.net.
Has anyone seen or have a chunk of code that does this in VB.net?
I'd like an example to at least get me started in the right
direction.

Sub classing is not needed anymore. You can overwrite the Form's WndProc
procedure and check for m.message for WM_ACTIVATEAPP.

Armin
 
Armin,

You are right, however luckily more and more less people are giving us some
VB6 code and say than how do I need to do that in VBNet.

The way you wrote it (the problem) is much easier to help in my opinion.

It tells direct what is wanted (If you are right).

:-)

Cor
 
I'm lumping together a bunch of responses all together here.

I haven't written the code yet. I know that hooking the subclass is
dangerous territory, so I was hoping to get some roadmap to follow.

The application needs to know when it has been selected and this the
foreground application. Normally it will live in the task bar minimized.
When clicked in the task bar, I want to run some routines. The application
is glueing some other apps together for interfacing. It will be used in a
touch screen environment and makes up for some very small icons compared to
some peoples finger sizes, but that's not relivant to my current issue. The
overall application is simple. All is does is lock the workstation using an
API call. Currently it does the locking, but it's a two step process, select
the app, then click the lock button. If I watch for the application
activation state, then I can run the lock routine and save the user an
additional click.

The best example I have of code already is here;
http://vbnet.mvps.org/code/subclass/activation.htm
but it's VB6 code and I'd rather write my app in newer VB.net code.

Bernie
 
Can anyone point me to a resource that shows how this is done? I know it's a
sensitive area and I don't want to mess it up.

Bernie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top