GDI Text Input Control Required Urgently..
-
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
-
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
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