Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. GDI Text Input Control Required Urgently..

GDI Text Input Control Required Urgently..

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++csscomgraphics
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zeemalik
    wrote on last edited by
    #1

    I am very much stuck in an urgent assignment and in need of help as i have committed a Excel like Grid to a client. My requirement is to have a Grid just like Excel and to take input from user using only Win API and GDI etc (No MFC allowed). I have already created the Grid but the problem is how to show the cursor in the rectangular boxes in grid and to take input form user? One option is to use 'Text Box' control already provided in WinAPI but the problem is that its width would be fixed and only a part of text written in it is viewable to user depending on its width. What i want is the input functionality just like MS Excel in which the input text is automatically extended to next cell when it exceeds the limit of a cell. I would really appreciate if any one can provide me with the source code of such a control or could help me out in this difficult task? Thanks and Regards, Zeeshan Malik zeemalik78@yahoo.com

    To do what can be done is Intelligence and To do what should be done is Genious

    M 1 Reply Last reply
    0
    • Z zeemalik

      I am very much stuck in an urgent assignment and in need of help as i have committed a Excel like Grid to a client. My requirement is to have a Grid just like Excel and to take input from user using only Win API and GDI etc (No MFC allowed). I have already created the Grid but the problem is how to show the cursor in the rectangular boxes in grid and to take input form user? One option is to use 'Text Box' control already provided in WinAPI but the problem is that its width would be fixed and only a part of text written in it is viewable to user depending on its width. What i want is the input functionality just like MS Excel in which the input text is automatically extended to next cell when it exceeds the limit of a cell. I would really appreciate if any one can provide me with the source code of such a control or could help me out in this difficult task? Thanks and Regards, Zeeshan Malik zeemalik78@yahoo.com

      To do what can be done is Intelligence and To do what should be done is Genious

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      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)
           e
      
      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups