Solved

How to Handle ESC button in PropertySheet?

Posted on 2001-07-16
2
692 Views
Last Modified: 2013-11-20
In my application  I have a modless PropertySheet with 3 PropertPages added to it.
In the ProprtySheet (not Property Page), I have added my own Close button which closes the dialog on clicking on it.
In the event handling of this Close button, I am calling :  
CPropertysheet::OnClose() function, which closes the dialog. Also I am handling WM_CLOSE message.
In trying to solve the problem, I also tried handling WM_KEYDOWN, WM_SYSKEYDOWN and WM_DESTROY.

But when I press ESC from the keyboard, the PropertySheet
dialog does not close. Where as for ather dialogs it works fine even if WM_CLOSE is not handled.

How should the PropertySheet dialog automatically get closed when I press ESC button from the keyboard?
0
Comment
Question by:pratimag
2 Comments
 
LVL 3

Accepted Solution

by:
_mb_ earned 50 total points
ID: 6288640
You can try to override the PreTranslateMessage() member:

BOOL CYourPropSheet::PreTranslateMessage(MSG* pMsg)
{
    if( pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE )
    {
        CPropertysheet::OnClose()
        return TRUE;
    }
       
    return CPropertySheet::PreTranslateMessage(pMsg);
}
0
 

Author Comment

by:pratimag
ID: 6288675
Thanks, even i was trying out on the same lines. The comment was real good one.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Adapt this command to show who installed 29 111
Unix / Linux grid computing 5 163
while loop over for loop 7 115
Trying to run powershell  in a batch file. How do I do this? 8 106
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question