Click here to get back home

Can’t override BACK key with Class Specified

 HomeNewsGroups | Search | About
 microsoft.public.smartphone.developer    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Can’t override BACK key with Class Specified Robert Scott 03-01-2006
Posted by Robert Scott on March 1, 2006, 7:32 pm
Please log in for more thread options
For normal dialog boxes, the BACK key automatically sends a WM_COMMAND, IDCANCEL
to the dialog proc, which I handle with an EndDialog, and control returns to the
window that called DialogBox. But for one dialog box, this is not working. In
order to get WM_CHAR and WM_KEYDOWN messages, I defined this dialog box with a
private class ("MyTableClass"). In the code, I registered the class, making
sure to use GetClassInfo(.."DIALOG"..) so that cbWndExtra is set appropriately.
This registration associates my own MyWindowProc with"MyTableClass".
MyWindowProc catches the WM_CHAR messages, etc., and then calls DefDlgProc, so
that hopefully the effect will be as if DIALOG was the class for this dialog box
all along. So I have both a Window Proc and a Dialog Proc for this dialog box.
The arrangement works fine in every respect except the BACK key. It does not
generate the WM_COMMAND, IDCANCEL as I had expected. So I explicitly added code
to override the BACK key, as if there was an edit control in my dialog box.
When I do that, I do get a WM_HOTKEY message which I then use to trigger an
EndDialog. When I run the code, I see that the parent window of the dialog box
does briefly appear. But then the screen changes to show the system Start menu.
If I return to my application, the parent window is in control and the dialog
box is gone. But why can’t I completely suppress the return to the Start menu?


Robert Scott
Ypsilanti, Michigan

Posted by Gernot Frisch on March 2, 2006, 3:24 am
Please log in for more thread options

> For normal dialog boxes, the BACK key automatically sends a
> WM_COMMAND, IDCANCEL
> to the dialog proc, which I handle with an EndDialog, and control
> returns to the
> window that called DialogBox. But for one dialog box, this is not
> working. In
> order to get WM_CHAR and WM_KEYDOWN messages, I defined this dialog
> box with a
> private class ("MyTableClass"). In the code, I registered the
> class, making
> sure to use GetClassInfo(.."DIALOG"..) so that cbWndExtra is set
> appropriately.
> This registration associates my own MyWindowProc with"MyTableClass".
> MyWindowProc catches the WM_CHAR messages, etc., and then calls
> DefDlgProc, so
> that hopefully the effect will be as if DIALOG was the class for
> this dialog box
> all along. So I have both a Window Proc and a Dialog Proc for this
> dialog box.
> The arrangement works fine in every respect except the BACK key. It
> does not
> generate the WM_COMMAND, IDCANCEL as I had expected. So I
> explicitly added code
> to override the BACK key, as if there was an edit control in my
> dialog box.
> When I do that, I do get a WM_HOTKEY message which I then use to
> trigger an
> EndDialog. When I run the code, I see that the parent window of the
> dialog box
> does briefly appear. But then the screen changes to show the system
> Start menu.
> If I return to my application, the parent window is in control and
> the dialog
> box is gone. But why can’t I completely suppress the return to the
> Start menu?

Try RegisterHotKey, then you get these as WM_KEYDOWN only.



Posted by Robert Scott on March 2, 2006, 7:34 am
Please log in for more thread options

>Try RegisterHotKey, then you get these as WM_KEYDOWN only.

Thanks. It worked great. I got rid of all that custom Class and Window Proc
nonsense. Now I have an ordinary dialog box. All the hot keys work, and the
BACK key behaves as it should by sending a IDCANCEL command.



Robert Scott
Ypsilanti, Michigan

Similar ThreadsPosted
Override back key April 20, 2006, 11:50 am
Override "Back"-Key on Smartphone (VB.NET) June 29, 2005, 12:39 am
Override Back Key WM5 Smartphone December 13, 2006, 2:26 pm
Override BACK key in non-dialog window March 2, 2006, 9:12 am
How to use or override the hardkeys (talk key, end key and so on)? December 19, 2006, 3:36 am
Class not registered May 14, 2008, 5:05 am
custom CBitmap class July 18, 2005, 3:50 am
FileSystemWatcher class for NetFramework2 August 11, 2005, 12:52 am
Can any application override default behaviour while making a call January 20, 2007, 4:31 am
Class: method or internal procedure ??? May 17, 2007, 11:43 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap