Solved

VC++ CGridCtrl, CEditBox, & Enter Key

Posted on 1997-07-09
3
563 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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 shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

705 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