Solved

VC++ CGridCtrl, CEditBox, & Enter Key

Posted on 1997-07-09
3
555 Views
Last Modified: 2013-12-03
ENVIRIONMENT: MFC MDI program in VC++4.2

WHAT NOW WORKS: A CGridCtrl in a form view shows a set of numbers.  When a grid cell is double-clicked, the cell is overlain with a properly-sized CEditBox containing the number, and the number can be edited.  When the edit box loses the focus, the edited number is verified, the edit box disappears, and the number is replaced in the grid cell.  I am using OnDoubleClick to get into the edit mode and OnKillFocus to get back out just because they were the only ways I could think of to do it.

THE PROBLEM: How can I get into the edit mode by pressing Enter or a number key (instead of a double-click), and get back out of the edit mode by pressing Enter (instead of clicking the mouse somewhere else)?  [I'm pretty fuzzy about the details of message routing and trapping keystrokes.]  TIA.
0
Comment
Question by:bivey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:bivey
ID: 1400480
Edited text of question
0
 

Author Comment

by:bivey
ID: 1400481
Adjusted points to 200
0
 
LVL 1

Accepted Solution

by:
pcs071997 earned 200 total points
ID: 1400482
(1) Use ClassWizard to derive a class from CEdit.
(2) Add the function, GetSuperWndProcAddr(), to myEdit class.
(3) subclass the window.

 include your header...->      public:
          WNDPROC* GetSuperWndProcAddr();
And add the following function to the .CPP file:

      WNDPROC* myEdit::GetSuperWndProcAddr() {
          static WNDPROC NEAR pfnSuper = NULL;
          return &pfnSuper;
      }


      int myEdit::OnCreate(LPCREATESTRUCT lpCreateStruct)
      {
          if (myEdit::OnCreate(lpCreateStruct) == -1)
          return -1;


          if (!SubclassWindow (myEdit)) { // Add
              return (-1);                                        
          }                                                       // Add
      ...
      }

After completing these three steps, you can use ClassWizard to add message handlers
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
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…

730 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