473,770 Members | 3,912 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Detecting Alt-Tab

kh
My app filters windows messages because of some custom window functionality I
have implemented. Does my window receive a message when the user selects
Alt-Tab? If so which message?

Many thanks

kh
May 4 '06 #1
5 6510
Hi,

Dont know if it does, it's very easy to check though, just expand the
winproc and see what messages you get when you press alt+tab , for sure you
will lose focus and will be no longer the foremost window
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"kh" <kh@newsgroups. nospam> wrote in message
news:11******** *************** ***********@mic rosoft.com...
My app filters windows messages because of some custom window
functionality I
have implemented. Does my window receive a message when the user selects
Alt-Tab? If so which message?

Many thanks

kh

May 4 '06 #2
kh
thanks. on a related issue, if i subclass UserControl, can this control
listen to messages which were meant for it's parent form?
"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

Dont know if it does, it's very easy to check though, just expand the
winproc and see what messages you get when you press alt+tab , for sure you
will lose focus and will be no longer the foremost window
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"kh" <kh@newsgroups. nospam> wrote in message
news:11******** *************** ***********@mic rosoft.com...
My app filters windows messages because of some custom window
functionality I
have implemented. Does my window receive a message when the user selects
Alt-Tab? If so which message?

Many thanks

kh


May 4 '06 #3
>My app filters windows messages because of some custom window functionality I
have implemented. Does my window receive a message when the user selects
Alt-Tab? If so which message?


Do you mean during the Alt-Tab'ing (while cycling through the
different windows) or after the keys have been released and the active
application actually changes?
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
May 4 '06 #4
Hi kh,

Thanks for your post!

I have seen that you posted a question in
microsoft.publi c.win32.program mer.ui newsgroup. Let's continue our
discussion here, since you are using C#.

To detect Alt+Tab key, we can use SPY++ tool to monitor the window to see
what messages are posted/sent for Alt+Tab key combination. I know you must
have seen WM_CANCELMODE message and you thought WM_CANCELMODE is the
correct message for the indication. The answer is no.

In Win32 world, every UI thread will have an message queue, and all the
windows messages to this thread will be queued in it. Then, every message
structure will have an hwnd field(please refer to "MSG Structure" in MSDN)
to indicate which window in that thread will receive the message.

Let's take notepad for example, notepad main thread has 3 windows: notepad
main window, Edit window, status bar hidden window. The latter 2 windows
are child windows of the first one. When we are pressing Alt+Tab key,
because they are system key, there will be WM_SYSKEY*(up or down) messages
be sent to the currently focused window.(In notepad, it will almost always
be Edit window, because the other 2 windows can not have focus). So, if we
use spy++ to monitor main window messages, we will not see any keyboard
messages. The keyboard messages have been sent to edit window. If you use
spy++ to monitor edit window, you will see the keyboard messages we want.

Then, what is the reliable way to monitor the keyboard messages in the main
GUI thread without knowing which is the focused control? The answer is
local windows hook. Below is a sample VB article regarding how to use
low-level Keyboard hook WH_KEYBOARD_LL to do this:
"Managing Low-Level Keyboard Hooks with the Windows API"
http://www.codeguru.com/vb/gen/vb_sy...cle.php/c4829/

Note: although this article did not use WH_GETMESSAGE hook to monitor the
messages, I think we can use WH_GETMESSAGE hook to monitor all the messages
in the hooked GUI thread, and check for the Alt+key messages, but I did not
find a sample regarding using message hook.

To use windows hook in .Net, please refer to the KB below:
"How to set a Windows hook in Visual C# .NET"
http://support.microsoft.com/kb/318804/EN-US/

Regarding your last question, the correct way to hook parent form message
in usercontrol is also using local windows message hook.

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

May 5 '06 #5
"kh" wrote:
My app filters windows messages because of some custom window functionality I
have implemented. Does my window receive a message when the user selects
Alt-Tab? If so which message?


When the user presses Alt+Tab while your application is focused, the
operating system intercepts that key sequence and focuses another window
before your window receives the entire key sequence. Therefore, the best way
to detect Alt+Tab reliably is to create a WH_KEYBOARD_LL global keyboard hook
that can see keyboard events across all applications.

--
Timm Martin
Mini-Tools
..NET Components and Windows Software
http://www.mini-tools.com
May 8 '06 #6

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

Similar topics

5
3481
by: Steve | last post by:
Hi everyone, I'm trying to make an openGL app (in visual c++) that allows the use of two mice simultaneously. Does anyone know if this is possible, how I might go about doing it or how I could find out how to do it? Much thanks in advance, Steve
1
10154
by: Rod Early | last post by:
I need to know when the select element's dropdown list is opened (as when the user clicks on the arrow or does ALT-downarrow from the keyboard). Similarly, I need to known when the dropdown list closes. The closing of the dropdown list can happen without changing the dropdown, hence the onchange event is not a sure way to determine that the dropdown list closed. Is this possible in Internet Explorer?
1
1598
by: jasper | last post by:
hi, i am trying to make a very simple program that will just detect and output your currently connected IDE devices. It will look something like this: IDE PRIMARY MASTER: IDE PRIMARY SLAVE: IDE SECONDARY MASTER:
12
4780
by: Wladimir Borsov | last post by:
On one of my web pages there is an java applets which works fine on my computer. However I noticed on some other computer that the run of java applets are disabled. I got an error message "Classnotfound" Is there a way to detect (with cgi resp. javascript) if java applets are allowed? I would like to show a simple picture instead of the applet pane if applets are not allowed. Wladimir
13
1800
by: ima | last post by:
I've been studying a great book on css and now that I've put together a few pages using it, I'm finding out that my book needed one more very important chapter. Introducing css in the real world. Obviously, there are a LOT of older browsers still out there that don't support css and some newer one's that still don't support it very well. Knowing that, I have prepared a second set of pages using table layouts for those browsers. It...
2
5058
by: MackS | last post by:
Hello I am writing a small app to learn how to use the curses module. I would like to know how I can get "composite" key presses, eg, Control+Q. Currently I am looking at the following code snippet: import curses.wrapper def main(stdscr):
79
3794
by: VK | last post by:
I wandering about the common proctice of some UA's producers to spoof the UA string to pretend to be another browser (most often IE). Shouldn't it be considered as a trademark violation of the relevant name owner? If I make a whisky and call it "Jack Daniels", I most probably will have some serious legal problems. "Mozilla" partially appeared because NCSA stopped them from using "Mosaic" in the UA string. Is it some different...
9
1466
by: aljamala | last post by:
Hi, I am looking for different ways this can be accomplished, I can think of a way, but I'm not too happy with it... The Problem: Users with multiple accounts can switch between them; however, the selected account is highligted by adding an invalid "udb_id" attribute to the <trtag and replacing that tag with the color that we want
4
1276
imarkdesigns
by: imarkdesigns | last post by:
hello again guys... im in trouble here in my coding which i cannot open a link for the end user of the page in the site where there is a portal thru the folder... anyway, here is my code... //-- for the table linkage with icon <table> <tr> <td class="rowsavedisk"> <a href="<? echo $dirPath.$rows; ?>" target="_blank" title="Poster"> <img src="imgs/icons/save.gif" alt="" border="0" /> </a> </td> </tr>
9
8446
by: raknin | last post by:
Hi, I want to detect when the user close a window through the X button or ALT-F4 or when the user go to another page and leave my page. I try to use the onuload and on unloadbeore but it works on ie 6 and Firefox 2 and it doesn't work on Safari 3.03 and Opera 9.2, it is also doesn't solve the problem when the user navigate to another page through the same windows, Any Ideas? Thanks ...
0
9602
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9439
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10017
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9882
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7431
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5326
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2832
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.