Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8054405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:08:30+00:00 2026-06-05T08:08:30+00:00

I have a list control and a number of CDialog-derived forms without border. When

  • 0

I have a list control and a number of CDialog-derived forms without border. When user clicks on a particular list item – a particular form is displayed. I used CDialog class as a base class for these forms. Everything works well but when I press Escape key in the main window where list and these controls are situated – current form hides. How to block escape key? Should I define OnCancel method in forms’ classes and prevent a dialog from closing or there are some flags that could be set to solve my problem? I’ve chosen mainly CDialog class as a base class in order to have DoDataExchange within form classes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T08:08:32+00:00Added an answer on June 5, 2026 at 8:08 am

    I am not sure what you are referring to as form.
    I just assume that you are working with dialogs.

    When you press Esc dialog does not hide; it is dismissed with IDCANCEL exit code. The same happens when RETURN is pressed. The difference is that exit code is set to IDOK.

    Do not change Cancel handler behavior. You need it to know that user actually terminated dialog with Cancel button.

    Instead, create accelerator table in the resource editor and add Esc (VK_ESCAPE) key to it.
    Add HACCEL type member variable to your app.
    In InitInstance call:

    m_hAccel = LoadAccelerators(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_ACCELERATOR1));
    

    Add virtual PreTranslateMessage to yur application. Place following code in the override:

    BOOL CYourApp::PreTranslateMessage(MSG* pMsg)
    {
        if(TranslateAccelerator(pMsg->hwnd, m_hAccel, pMsg))
        {
            return TRUE;
        }
    
        return CWinAppEx::PreTranslateMessage(pMsg);
    }
    

    That is it. You even do not have to insert a handler for this accelerator, unless you want to do something else beside preventing dialog from closing when Esc is pressed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello i have a list view control, While the form is being loaded i
I have a drop-down list hardcoded in an MVC View User Control page and
I have a GridView inside of a User Control populated from a List of
I have a user control with a number of methods. I also have a
I have a list box control that contains enough items to list them with
I have the list box control (ASP.NET Control On aspx page, language C# ).
I have an owner-drawn list control in my Windows program. I use CListCtrl::GetBkColor to
I have a radio button list control on my ascx page and have a
I have created a project in Dashcode, inserted a List control, enabled a dynamic
I have the following class: public class LooklessControl : Control { public List<int> IntList

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.