473,388 Members | 1,342 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,388 software developers and data experts.

Execute on Focus

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

Nov 21 '05 #1
6 1498
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
Nov 21 '05 #2
"Cor Ligthert" <no************@planet.nl> schrieb
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

Nov 21 '05 #3
"Bernie Hunt" <bh***@optonline.net> schrieb
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

Nov 21 '05 #4
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

Nov 21 '05 #5
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

"Cor Ligthert" <no************@planet.nl> wrote in message
news:uH**************@TK2MSFTNGP15.phx.gbl...
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

Nov 21 '05 #6
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

"Armin Zingler" <az*******@freenet.de> wrote in message
news:OR*************@TK2MSFTNGP10.phx.gbl...
Sub classing is not needed anymore. You can overwrite the Form's WndProc
procedure and check for m.message for WM_ACTIVATEAPP.

Armin

Nov 21 '05 #7

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

Similar topics

4
by: Nitin | last post by:
Hi I have created function to check date and time. at the time of execution, if date is left empty the function returns the error message but then the focus goes to next field. Next filed is for...
17
by: Neil Ginsberg | last post by:
OK, this is a stupid thing, but I can't seem to get this to work. I have a form with a subform (in continuous form view). A combo box on the main form has code in the AfterUpdate event which adds a...
1
by: avnrao | last post by:
Hi, I am facing a problem with control.focus (javascript). Here is the description of the issue. 1. I have 2 aspx files. on Aspx1 I have button named NewRow. Clicking on this, will redirect...
1
by: Mark | last post by:
I'd like to execute some code on the cleint when the user hits Enter key in a dropdown box. Another words, the user selects an item from the combo and then hits Enter key. I want to attach code to...
11
by: Alex.Svetos | last post by:
Hello, I'm trying to get a popup to keep focus when it is re-clicked. The script below is supposed to produce this exact behaviour, however it doesn't work, at least on firefox 1.0.7 and moz...
7
by: Dave Booker | last post by:
I am using a WebBrowser object in my .NET 2.0 application, but it is not shown to the user. Every time a timer event triggers it to perform a m_WebBrowser.Navigate() I get that classic IE 'click'...
4
by: Roger | last post by:
Hi, I am confused about the differences between this.window.focus(), window.focus(), and this.focus(). I want to use the calls in a <body onload="..."tag. What are the differences between...
8
by: M.L. | last post by:
Hello. I created a form using JS validation with the form tag as follows: <form name="form1" action="dynaform.php" method="post" onsubmit="return pvg_sub();"> The js validation script sends...
1
by: RyanT | last post by:
Access 2000 Windows XP I have a small form with two text boxes: - User ID - Password The form also has two command buttons: - Login - Cancel
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.