<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[CListCtrl -&amp;gt; Felder Editieren und Übernhmen]]></title><description><![CDATA[<p>Hi</p>
<p>ich hab lange gesucht jedoch nicht darüber gefunden wie ich die einzelnen Felder einer CListCtrl editieren kann.</p>
<p>Ich hab eine List welche in einer CListCtrl angezeigt wird. Jedoch hätte ich gerne das ich die einzelnen Felder editieren kann und das alle die geändert wurden auch übernehme und speicher kann.</p>
<p>Weiss das zufällig jemand wie das geht ??</p>
<p>Danke,<br />
Indian</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/77449/clistctrl-gt-felder-editieren-und-übernhmen</link><generator>RSS for Node</generator><lastBuildDate>Tue, 14 Apr 2026 23:24:33 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/77449.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 21 Jun 2004 13:55:05 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CListCtrl -&amp;gt; Felder Editieren und Übernhmen on Mon, 21 Jun 2004 13:55:05 GMT]]></title><description><![CDATA[<p>Hi</p>
<p>ich hab lange gesucht jedoch nicht darüber gefunden wie ich die einzelnen Felder einer CListCtrl editieren kann.</p>
<p>Ich hab eine List welche in einer CListCtrl angezeigt wird. Jedoch hätte ich gerne das ich die einzelnen Felder editieren kann und das alle die geändert wurden auch übernehme und speicher kann.</p>
<p>Weiss das zufällig jemand wie das geht ??</p>
<p>Danke,<br />
Indian</p>
]]></description><link>https://www.c-plusplus.net/forum/post/544955</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/544955</guid><dc:creator><![CDATA[Indian]]></dc:creator><pubDate>Mon, 21 Jun 2004 13:55:05 GMT</pubDate></item><item><title><![CDATA[Reply to CListCtrl -&amp;gt; Felder Editieren und Übernhmen on Mon, 21 Jun 2004 15:58:40 GMT]]></title><description><![CDATA[<p>Mal ein kurzer Beitrag dazu:</p>
<p>1. Mach dir ne Basisklasse für das ListCtrl, welche von CListCtrl erbt,<br />
damit ersparst du dir, es bei jeder anderen ListCtrl immer wieder vollständig<br />
implementieren zu müssen...</p>
<p>Header:</p>
<pre><code class="language-cpp">class LBasisListCtrl : public CListCtrl
{
// Konstruktion
public:
	LBasisListCtrl();
public:
	CEdit* EditSubLabel(int nItem, int nCol);
	virtual ~LBasisListCtrl();
	virtual void SetSubItemText(int item, int subitem, CString text) =0;
	// Generierte Nachrichtenzuordnungsfunktionen
protected:
	//{{AFX_MSG(LBasisListCtrl)
	afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};
</code></pre>
<p>cpp:</p>
<pre><code class="language-cpp">CEdit* LBasisListCtrl::EditSubLabel(int nItem, int nCol)
{
	// The returned pointer should not be saved

	// Make sure that the item is visible
	if( !EnsureVisible( nItem, TRUE ) ) return NULL;

	// Make sure that nCol is valid
	CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
	int nColumnCount = pHeader-&gt;GetItemCount();
	if( nCol &gt;= nColumnCount || GetColumnWidth(nCol) &lt; 5 )
		return NULL;

	// Get the column offset
	int offset = 0;
	for( int i = 0; i &lt; nCol; i++ )
		offset += GetColumnWidth( i );

	CRect rect;
	GetItemRect( nItem, &amp;rect, LVIR_BOUNDS );

	// Now scroll if we need to expose the column
	CRect rcClient;
	GetClientRect( &amp;rcClient );
	if( offset + rect.left &lt; 0 || offset + rect.left &gt; rcClient.right )
	{
		CSize size;
		size.cx = offset + rect.left;
		size.cy = 0;
		Scroll( size );
		rect.left -= size.cx;
	}

	// Get Column alignment
	LV_COLUMN lvcol;
	lvcol.mask = LVCF_FMT;
	GetColumn( nCol, &amp;lvcol );
	DWORD dwStyle ;
	if((lvcol.fmt&amp;LVCFMT_JUSTIFYMASK) == LVCFMT_LEFT)
		dwStyle = ES_LEFT;
	else if((lvcol.fmt&amp;LVCFMT_JUSTIFYMASK) == LVCFMT_RIGHT)
		dwStyle = ES_RIGHT;
	else dwStyle = ES_CENTER;

	rect.left += offset+4;
	rect.right = rect.left + GetColumnWidth( nCol ) - 3 ;
	if( rect.right &gt; rcClient.right) rect.right = rcClient.right;

	dwStyle |= WS_BORDER|WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL;
	CEdit *pEdit = new CInPlaceEdit(nItem, nCol, GetItemText( nItem, nCol ));
	pEdit-&gt;Create( dwStyle, rect, this, IDC_EDIT );

	return pEdit;
}

void LBasisListCtrl::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	if( GetFocus() != this ) SetFocus();
	CListCtrl::OnHScroll(nSBCode, nPos, pScrollBar);
}

void LBasisListCtrl::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	if( GetFocus() != this ) SetFocus();
	CListCtrl::OnVScroll(nSBCode, nPos, pScrollBar);
}
</code></pre>
<p>Hier dann die konkrete Implementierung, die SetSubItemText wird hier ausformuliert:</p>
<p>Header:</p>
<pre><code class="language-cpp">class LInc : public LBasisListCtrl
{
// Konstruktion
public:
	LInc();
	virtual void SetSubItemText(int item, int subitem, CString text);
// Attribute
public:

// Operationen
public:

// Überschreibungen
	// Vom Klassen-Assistenten generierte virtuelle Funktionsüberschreibungen
	//{{AFX_VIRTUAL(LInc)
	//}}AFX_VIRTUAL

// Implementierung
public:
	void Init();
	virtual ~LInc();

	// Generierte Nachrichtenzuordnungsfunktionen
protected:
	//{{AFX_MSG(LInc)
	afx_msg void OnClick(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult);
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
};
</code></pre>
<p>cpp:</p>
<pre><code class="language-cpp">void LInc::OnClick(NMHDR* pNMHDR, LRESULT* pResult) 
{
	LPNMITEMACTIVATE    lpItem = (LPNMITEMACTIVATE) pNMHDR;
	if(lpItem-&gt;iItem &gt; -1 &amp;&amp; lpItem-&gt;iSubItem &gt;-1)
	{
		EditSubLabel( lpItem-&gt;iItem, lpItem-&gt;iSubItem );
	}
	*pResult = 0;
}

void LInc::SetSubItemText(int item, int subitem, CString text)
{
	*/Text speichern*/
  	SetItemText(item,subitem,text);
}

void LInc::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult) 
{
 	LV_DISPINFO *plvDispInfo = (LV_DISPINFO *)pNMHDR;
 	LV_ITEM	*plvItem = &amp;plvDispInfo-&gt;item;
 	if (plvItem-&gt;pszText != NULL)
 	{
		SetSubItemText(plvItem-&gt;iItem, plvItem-&gt;iSubItem, plvItem-&gt;pszText);
 	}
 	*pResult = FALSE;
}
</code></pre>
<p>Jetzt brauchen wir noch eine Klasse von CEdit abzuleiten, die weiss wo sie gerade<br />
editiert etc.</p>
<p>Header:</p>
<pre><code class="language-cpp">class CInPlaceEdit : public CEdit
{
// Konstruktion
public:
	CInPlaceEdit(int iItem, int iSubItem, CString sInitText);
// Attributes
public:
// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CInPlaceEdit)
	public:
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	//}}AFX_VIRTUAL
// Implementation
public:
	virtual ~CInPlaceEdit();

	// Generated message map functions
protected:
	//{{AFX_MSG(CInPlaceEdit)
	afx_msg void OnKillFocus(CWnd* pNewWnd);
	afx_msg void OnNcDestroy();
	afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
private:
	int m_iItem;
	int m_iSubItem;
	CString m_sInitText;
	BOOL    m_bESC;	 	// To indicate whether ESC key was pressed
};
</code></pre>
<p>cpp:</p>
<pre><code class="language-cpp">CInPlaceEdit::CInPlaceEdit(int iItem, int iSubItem, CString sInitText)
:m_sInitText( sInitText )
{
	m_iItem = iItem;
	m_iSubItem = iSubItem;
	m_bESC = FALSE;
}

CInPlaceEdit::~CInPlaceEdit()
{
}

BEGIN_MESSAGE_MAP(CInPlaceEdit, CEdit)
	//{{AFX_MSG_MAP(CInPlaceEdit)
	ON_WM_KILLFOCUS()
	ON_WM_NCDESTROY()
	ON_WM_CHAR()
	ON_WM_CREATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CInPlaceEdit message handlers

BOOL CInPlaceEdit::PreTranslateMessage(MSG* pMsg)
{
	if( pMsg-&gt;message == WM_KEYDOWN )
	{
		if(pMsg-&gt;wParam == VK_RETURN
				|| pMsg-&gt;wParam == VK_DELETE
				|| pMsg-&gt;wParam == VK_ESCAPE
				|| GetKeyState( VK_CONTROL)
				)
		{
			::TranslateMessage(pMsg);
			::DispatchMessage(pMsg);
			return TRUE;		    	// DO NOT process further
		}
	}

	return CEdit::PreTranslateMessage(pMsg);
}

void CInPlaceEdit::OnKillFocus(CWnd* pNewWnd)
{
	CEdit::OnKillFocus(pNewWnd);

	CString str;
	GetWindowText(str);

	// Send Notification to parent of ListView ctrl
	LV_DISPINFO dispinfo;
	dispinfo.hdr.hwndFrom = GetParent()-&gt;m_hWnd;
	dispinfo.hdr.idFrom = GetDlgCtrlID();
	dispinfo.hdr.code = LVN_ENDLABELEDIT;

	dispinfo.item.mask = LVIF_TEXT;
	dispinfo.item.iItem = m_iItem;
	dispinfo.item.iSubItem = m_iSubItem;
	dispinfo.item.pszText = m_bESC ? NULL : LPTSTR((LPCTSTR)str);
	dispinfo.item.cchTextMax = str.GetLength();

	GetParent()-&gt;GetParent()-&gt;SendMessage( WM_NOTIFY, GetParent()-&gt;GetDlgCtrlID(), 
					(LPARAM)&amp;dispinfo );

	DestroyWindow();
}

void CInPlaceEdit::OnNcDestroy()
{
	CEdit::OnNcDestroy();

	delete this;
}

void CInPlaceEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
	if( nChar == VK_ESCAPE || nChar == VK_RETURN)
	{
		if( nChar == VK_ESCAPE )
			m_bESC = TRUE;
		GetParent()-&gt;SetFocus();
		return;
	}

	CEdit::OnChar(nChar, nRepCnt, nFlags);

	// Resize edit control if needed

	// Get text extent
	CString str;

	GetWindowText( str );
	CWindowDC dc(this);
	CFont *pFont = GetParent()-&gt;GetFont();
	CFont *pFontDC = dc.SelectObject( pFont );
	CSize size = dc.GetTextExtent( str );
	dc.SelectObject( pFontDC );
	size.cx += 5;			   	// add some extra buffer

	// Get client rect
	CRect rect, parentrect;
	GetClientRect( &amp;rect );
	GetParent()-&gt;GetClientRect( &amp;parentrect );

	// Transform rect to parent coordinates
	ClientToScreen( &amp;rect );
	GetParent()-&gt;ScreenToClient( &amp;rect );

	// Check whether control needs to be resized
	// and whether there is space to grow
	if( size.cx &gt; rect.Width() )
	{
		if( size.cx + rect.left &lt; parentrect.right )
			rect.right = rect.left + size.cx;
		else
			rect.right = parentrect.right;
		MoveWindow( &amp;rect );
	}
}

int CInPlaceEdit::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CEdit::OnCreate(lpCreateStruct) == -1)
		return -1;

	// Set the proper font
	CFont* font = GetParent()-&gt;GetFont();
	SetFont(font);

	SetWindowText( m_sInitText );
	SetFocus();
	SetSel( 0, -1 );
	return 0;
}
</code></pre>
<p>Fertig <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>Devil</p>
]]></description><link>https://www.c-plusplus.net/forum/post/545066</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/545066</guid><dc:creator><![CDATA[phlox81]]></dc:creator><pubDate>Mon, 21 Jun 2004 15:58:40 GMT</pubDate></item><item><title><![CDATA[Reply to CListCtrl -&amp;gt; Felder Editieren und Übernhmen on Wed, 23 Jun 2004 11:38:52 GMT]]></title><description><![CDATA[<p>ich bekommne Fehlermeldung das</p>
<p>IDC_EDIT nicht deklariert ist</p>
<p>c:\Dokumente und Einstellungen\Mother\Eigene Dateien\Visual Studio-Projekte\Kasse\Kasse\SortListCtrl.cpp(467): error C2065: 'IDC_EDIT' : nichtdeklarierter Bezeichner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/546435</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/546435</guid><dc:creator><![CDATA[IndianX]]></dc:creator><pubDate>Wed, 23 Jun 2004 11:38:52 GMT</pubDate></item><item><title><![CDATA[Reply to CListCtrl -&amp;gt; Felder Editieren und Übernhmen on Thu, 24 Jun 2004 22:25:10 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich weis zwar nicht viel, aber IDC_EDIT ist ein Steuerelement <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>Auch als Eingabefeld getarnt. Baue ein Eingabefeld mit dem Namen IDC_EDIT<br />
ein, und schaue was passiert.</p>
<p>asmodia</p>
]]></description><link>https://www.c-plusplus.net/forum/post/547526</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/547526</guid><dc:creator><![CDATA[asmodia]]></dc:creator><pubDate>Thu, 24 Jun 2004 22:25:10 GMT</pubDate></item><item><title><![CDATA[Reply to CListCtrl -&amp;gt; Felder Editieren und Übernhmen on Fri, 25 Jun 2004 14:30:47 GMT]]></title><description><![CDATA[<p>asmodia schrieb:</p>
<blockquote>
<p>Hi,</p>
<p>ich weis zwar nicht viel, aber IDC_EDIT ist ein Steuerelement <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>Auch als Eingabefeld getarnt. Baue ein Eingabefeld mit dem Namen IDC_EDIT<br />
ein, und schaue was passiert.</p>
<p>asmodia</p>
</blockquote>
<p>Stimmt, habe vergessen, das man in den Dialog auch ein Editfeld einbauen<br />
muss, welches dann auf randlos gestellt wird, und der Haken bei Sichtbar sollte raus.</p>
<p>Devil</p>
]]></description><link>https://www.c-plusplus.net/forum/post/547960</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/547960</guid><dc:creator><![CDATA[phlox81]]></dc:creator><pubDate>Fri, 25 Jun 2004 14:30:47 GMT</pubDate></item><item><title><![CDATA[Reply to CListCtrl -&amp;gt; Felder Editieren und Übernhmen on Fri, 25 Jun 2004 19:10:45 GMT]]></title><description><![CDATA[<p>hi</p>
<p>also mir ist war das mit ner eigenen klasse für clistctrl zu arg.<br />
ich habe mir nen schönen dialog gebaut - dort alle items/subitems rein<br />
dann kann man dort schön ändern und bei ok werden alle member des dlgs wieder<br />
in die liste geschrieben.</p>
<p>sentinel</p>
]]></description><link>https://www.c-plusplus.net/forum/post/548132</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/548132</guid><dc:creator><![CDATA[sentinel]]></dc:creator><pubDate>Fri, 25 Jun 2004 19:10:45 GMT</pubDate></item><item><title><![CDATA[Reply to CListCtrl -&amp;gt; Felder Editieren und Übernhmen on Mon, 28 Jun 2004 13:30:31 GMT]]></title><description><![CDATA[<p>Ich hab ein neues EditFeld (Steuerelement) erzeugt mit dem Namen IDC_EDIT. Wird leider trotzdem nicht erkannt. Das Kompilieren hat funktioniert als ich die Klasse vom Dialog eingebundenn habe jedoch funktioniert das editieren immer noch nicht. Nur die erste Spalte wie sonst auch immer.</p>
<p>Kann mir jemand erklären wie ich Funktionen nutze. Ist bischen schwer für mich hier einzuarbeiten</p>
]]></description><link>https://www.c-plusplus.net/forum/post/549293</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/549293</guid><dc:creator><![CDATA[IndianX]]></dc:creator><pubDate>Mon, 28 Jun 2004 13:30:31 GMT</pubDate></item><item><title><![CDATA[Reply to CListCtrl -&amp;gt; Felder Editieren und Übernhmen on Tue, 29 Jun 2004 07:26:05 GMT]]></title><description><![CDATA[<p>an devil81</p>
<p>fehlt bei der Implementierung nicht eine Implementierung welches die notwendige Funktion aufruft, damit man die Felder editieren kann ?? Eine MessageMap Einbindung ? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>ich kann immer nur noch die erste spalte default mässig editieren, alle anderen sind immer noch nicht editierbar. Ausserdem kann ich denn wert in der ersten Spalten nach dem editieren ja nicht übernehmen. Nachdem ich editierthabe und &quot;ENTER&quot; drücke müsste doch der neue wert übernommen werden oder ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/549689</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/549689</guid><dc:creator><![CDATA[IndianX]]></dc:creator><pubDate>Tue, 29 Jun 2004 07:26:05 GMT</pubDate></item><item><title><![CDATA[Reply to CListCtrl -&amp;gt; Felder Editieren und Übernhmen on Thu, 01 Jul 2004 11:50:27 GMT]]></title><description><![CDATA[<p>hi</p>
<p>leider wird das editierte Feld mit dem editiertem Wert nicht übernommen. Handler fehlten noch</p>
<p>ON_WM_LBUTTONDBLCLK()<br />
ON_NOTIFY_REFLECT(LVN_ENDLABELEDIT, OnEndLabelEdit)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/550836</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/550836</guid><dc:creator><![CDATA[IndianX]]></dc:creator><pubDate>Thu, 01 Jul 2004 11:50:27 GMT</pubDate></item><item><title><![CDATA[Reply to CListCtrl -&amp;gt; Felder Editieren und Übernhmen on Wed, 11 Aug 2004 11:23:08 GMT]]></title><description><![CDATA[<p>hi devil81</p>
<p>noch ne frage. wie kann ich festlegen welche spalte editiert werden kann und welche nicht ???</p>
]]></description><link>https://www.c-plusplus.net/forum/post/579842</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/579842</guid><dc:creator><![CDATA[IndianX]]></dc:creator><pubDate>Wed, 11 Aug 2004 11:23:08 GMT</pubDate></item></channel></rss>