Solved

VC++ CGridCtrl, CEditBox, & Enter Key

Posted on 1997-07-09
3
537 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
  • 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now