?
Solved

VC++ CGridCtrl, CEditBox, & Enter Key

Posted on 1997-07-09
3
Medium Priority
?
580 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 400 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
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 tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

765 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