Re: Subclassed edit control paint problem

"Yarp" <lac-3QW3q7+2X3hWk0Htik3J/[email protected]>
Newsgroups gmane.comp.windows.wtl
Message-ID <[email protected]>
Hi,
In the same situation I'm creating the Edit control with the proper size from the beginning. So there's no need to subclass the 2 messages you mentionned.

I get the dimensions as follows:

GetSubItemRect(iItem, iSubItem, LVIR_BOUNDS, pRect);
pRect.right--;
pRect.bottom--;

My Edit Create is borrowed from Bjarne Viksoe's Property Grid control:

http://www.viksoe.dk/code/propertygrid.htm

Have a look at CreateInplaceControl in PropertyItemImpl.h, this is what you call once you have the cell's rectangle.

Here's my code for the cell editing:

void FEditCell()
{
  CGridCell* pCell = GetColumnTrait(m_nSelectedCol);
  if ((!pCell) || (pCell->GetKind()<CELLKIND_EDIT) ||
      (!m_data->IsEditable(m_nSelectedRow,m_nSelectedCol)))
    return;

  // Send Notification to parent of ListView ctrl
  LV_DISPINFO dispinfo = {0};
  dispinfo.hdr.hwndFrom = m_hWnd;
  dispinfo.hdr.idFrom = GetDlgCtrlID();
  dispinfo.hdr.code = LVN_BEGINLABELEDIT;
  dispinfo.item.mask = LVIF_PARAM;
  dispinfo.item.iItem = m_nSelectedRow;
  dispinfo.item.iSubItem = m_nSelectedCol;
  dispinfo.item.lParam = 0;

  if (::SendMessage(GetParent(), WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&dispinfo)==TRUE)
    return;	 // Parent didn't want to start edit

  // Create a new editor window
  RECT rcValue;
  FGetSubItemRect(m_nSelectedRow, m_nSelectedCol, &rcValue);
  rcValue.right--;   // Let the borders
  rcValue.bottom--;  // display (right/bottom)
  char szText[MAX_PATH];
  ZeroMemory(szText, MAX_PATH);
  GetItemText(m_nSelectedRow, m_nSelectedCol, szText, MAX_PATH);
  HWND hwndInplace = m_arrColumnTrait[m_nSelectedCol]->CreateInplaceControl(m_hWnd, rcValue, m_nSelectedRow, m_nSelectedCol, szText);

  if (hwndInplace) {
    // Activate the new editor window
    ATLASSERT(::IsWindow(m_hwndInplace));
    ::SetWindowPos(hwndInplace, HWND_TOP, 0,0,0,0, SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE);
    ::SetFocus(hwndInplace);

    m_arrColumnTrait[m_nSelectedCol]->Activate(PACT_SPACE, 0);
  }
}

Working fine so far.

Yarp

--- In [email protected], "wdillman" <sdillman@...> wrote:
>
> I've subclassed a listview control and I'm trying to enable subitem
> editing so I've also subclassed an edit control and catching
> WM_WINDOWPOSCHANGING and WM_WINDOWPOSCHANGED in the edit control to move
> it into position. This all works great but the editcontrol box is not
> painted correctly and looks like the text area extends through the right
> hand side of the box.
> 




------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/wtl/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/wtl/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[email protected] 
    mailto:[email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.