[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VC++ CGridCtrl, CEditBox, & Enter Key

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
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…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

873 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