Click here to Skip to main content
15,926,596 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: DirectX and Circles Pin
Reagan Conservative24-Jan-07 6:07
Reagan Conservative24-Jan-07 6:07 
GeneralRe: DirectX and Circles Pin
Waldermort24-Jan-07 6:22
Waldermort24-Jan-07 6:22 
QuestionTrouble with Vista, MAPI, and Outlook 2000 Pin
gageller24-Jan-07 4:01
gageller24-Jan-07 4:01 
QuestionProblem in Creating Activex in AtlComponent Pin
narayanagvs24-Jan-07 3:13
narayanagvs24-Jan-07 3:13 
QuestionDetect ethernet interface STATUS?! Pin
djmarki24-Jan-07 2:57
djmarki24-Jan-07 2:57 
QuestionRe: Detect ethernet interface STATUS?! Pin
David Crow24-Jan-07 5:01
David Crow24-Jan-07 5:01 
QuestionGDI Text Input Control Required Urgently.. Pin
zeemalik24-Jan-07 2:50
zeemalik24-Jan-07 2:50 
AnswerRe: GDI Text Input Control Required Urgently.. Pin
Mark Salsbery24-Jan-07 5:39
Mark Salsbery24-Jan-07 5:39 
It's relatively simple to use the caret APIs and catch keystroke messages for simple text
input. Maybe you have some of the code already to use arrow keys to navigate the grid.

Here's an example of a modal text edit loop (with probably more keys checked than you need for
single-line editing). The CaretUp()/CaretDown()/CaretLeft()/CaretRight()/MoveCaret() set the
caret position based on a row/column and the font size (fixed pitch fonts make this easy):
MSG LoopMsg;
bool fRedraw = false;
bool fEditing = true;

while (fEditing)
{
   if (::PeekMessage(&LoopMsg,0,0,0,PM_REMOVE))
   {
      ::TranslateMessage(&LoopMsg);
      ::DispatchMessage(&LoopMsg);

      if (LoopMsg.message == WM_LBUTTONDOWN)
      {
         // Check if user clicked somewhere else
         //  and maybe stop editing
      }

      if (WM_KEYDOWN == LoopMsg.message)
      {
         switch (LoopMsg.wParam)
         {
            case VK_RETURN:       // Enter
               fEditing = false;
               break;
            case VK_HOME:       // Home
               MoveCaret(view, 0, nCurRow);
               break;
            case VK_END:        // End
               MoveCaret(view, nCharColumns, nCurRow);
               break;
            case VK_PRIOR:      // Page Up
               MoveCaret(view, nCurColumn, 0);
               break;
            case VK_NEXT:       // Page Down
               MoveCaret(view, nCurColumn, nCharRows - 1);
               break;
            case VK_LEFT:       // Left arrow
               CaretLeft(view);
               break;
            case VK_RIGHT:      // Right arrow
               CaretRight(view);
               break;
            case VK_UP:         // Up arrow
               CaretUp(view);
               break;
            case VK_DOWN:       // Down arrow
               CaretDown(view);
               break;
            case VK_DELETE:     // Delete
               DeleteChar();
               fRedraw = true;
               break;
            case VK_BACK:     // Backspace
               if (nInsertOffset > 0)
               {
                  CaretLeft(view);
                  DeleteChar();
                  fRedraw = true;
               }
               break;
         }
      }  //if (WM_KEYDOWN == LoopMsg.message)
      else if (WM_CHAR == LoopMsg.message)
      {
         switch (LoopMsg.wParam)
         {
            case 0x08:          // Backspace
               break;
            case 0x09:          // Tab
               // Move to another cell?
               break;
            case 0x0D:          // Carriage return
               break;
            case 0x0A:        // Linefeed
               break;
            case 0x1B:        // Escape
               fEditing = false;
               break;
            default:
               InsertChar((TCHAR)LoopMsg.wParam);
               fRedraw = true;
               break;
         }  //switch (wParam)

      }  //if (WM_CHAR == LoopMsg.message)
      else if (WM_SETFOCUS == LoopMsg.message)
      {
         ::MessageBeep(-1);
      }
      else if (WM_KILLFOCUS == LoopMsg.message)
      {
         fEditing = false;
      }


      if (fRedraw)
      {
         fRedraw = false;

         HideCaret(view);
         // redraw text
         ShowCaret(view);
      }
   }
}

Questionbased pointer crashed my app Pin
Alex Cutovoi24-Jan-07 2:09
Alex Cutovoi24-Jan-07 2:09 
AnswerRe: based pointer crashed my app Pin
KarstenK24-Jan-07 2:27
mveKarstenK24-Jan-07 2:27 
GeneralRe: based pointer crashed my app Pin
toxcct24-Jan-07 2:30
toxcct24-Jan-07 2:30 
GeneralRe: based pointer crashed my app Pin
KarstenK24-Jan-07 4:35
mveKarstenK24-Jan-07 4:35 
GeneralRe: based pointer crashed my app Pin
toxcct24-Jan-07 4:39
toxcct24-Jan-07 4:39 
GeneralRe: based pointer crashed my app Pin
Alex Cutovoi24-Jan-07 2:38
Alex Cutovoi24-Jan-07 2:38 
GeneralRe: based pointer crashed my app Pin
KarstenK24-Jan-07 4:37
mveKarstenK24-Jan-07 4:37 
GeneralRe: based pointer crashed my app Pin
Mark Salsbery24-Jan-07 5:54
Mark Salsbery24-Jan-07 5:54 
QuestionRe: based pointer crashed my app Pin
David Crow24-Jan-07 4:17
David Crow24-Jan-07 4:17 
AnswerRe: based pointer crashed my app Pin
Alex Cutovoi24-Jan-07 6:00
Alex Cutovoi24-Jan-07 6:00 
QuestionRe: based pointer crashed my app Pin
David Crow24-Jan-07 7:01
David Crow24-Jan-07 7:01 
AnswerRe: based pointer crashed my app Pin
Alex Cutovoi24-Jan-07 8:10
Alex Cutovoi24-Jan-07 8:10 
GeneralRe: based pointer crashed my app Pin
David Crow24-Jan-07 8:37
David Crow24-Jan-07 8:37 
AnswerRe: based pointer crashed my app Pin
Michael Dunn24-Jan-07 9:34
sitebuilderMichael Dunn24-Jan-07 9:34 
GeneralRe: based pointer crashed my app Pin
Alex Cutovoi24-Jan-07 11:40
Alex Cutovoi24-Jan-07 11:40 
GeneralRe: based pointer crashed my app Pin
Michael Dunn24-Jan-07 12:37
sitebuilderMichael Dunn24-Jan-07 12:37 
GeneralRe: based pointer crashed my app Pin
Alex Cutovoi25-Jan-07 16:34
Alex Cutovoi25-Jan-07 16:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.