L
Quam schrieb:
Dann poste doch mal die Info auf Codeproject.
Hab ich gemacht.
Jetzt stehe ich aber vor dem Problem :
Wie funktioniert das denn in meinem Projekt ???
Die Dateien habe ich eingefügt .
CListCtrl in CComboListCtrl geändert
ON_MESSAGE.. per Hand (?) eingefügt
mein source sieht jetzt so aus:
// Dlg_Rights.cpp: Implementierungsdatei
//
#include "stdafx.h"
#include "HSVerein.h"
#include "Dlg_Rights.h"
// CDlg_Rights-Dialogfeld
IMPLEMENT_DYNAMIC(CDlg_Rights, CDialog)
CDlg_Rights::CDlg_Rights(CWnd* pParent /*=NULL*/)
: CDialog(CDlg_Rights::IDD, pParent)
, m_iItemCount(0)
{
}
CDlg_Rights::~CDlg_Rights()
{
}
void CDlg_Rights::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST1, m_ctrl_combolist);
}
BEGIN_MESSAGE_MAP(CDlg_Rights, CDialog)
ON_MESSAGE(WM_VALIDATE, OnEndLabelEditVariableCriteria)
ON_MESSAGE(WM_SET_ITEMS, PopulateComboList)
END_MESSAGE_MAP()
// CDlg_Rights-Meldungshandler
BOOL CDlg_Rights::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: hier zusätzliche Initialisierung hinzufügen.
m_ctrl_combolist.InsertColumn(0, "User", LVCFMT_LEFT, 150);
m_ctrl_combolist.InsertColumn(1, "Titel1", LVCFMT_LEFT, 50);
m_ctrl_combolist.InsertColumn(2, "Titel2", LVCFMT_LEFT, 50);
m_ctrl_combolist.InsertColumn(3, "Titel3", LVCFMT_LEFT, 50);
m_ctrl_combolist.InsertColumn(4, "Titel4", LVCFMT_LEFT, 50);
m_ctrl_combolist.InsertColumn(5, "Titel5", LVCFMT_LEFT, 50);
m_ctrl_combolist.SetReadOnlyColumns(0);
m_ctrl_combolist.SetComboColumns(1);
m_ctrl_combolist.SetComboColumns(2);
m_ctrl_combolist.SetComboColumns(3);
m_ctrl_combolist.SetComboColumns(4);
m_ctrl_combolist.SetComboColumns(4);
m_ctrl_combolist.EnableVScroll();
m_ctrl_combolist.SetExtendedStyle(LVS_EX_FULLROWSELECT);
// SendMessage(WM_SET_ITEMS) ?????
return TRUE; // return TRUE unless you set the focus to a control
// AUSNAHME: OCX-Eigenschaftenseite muss FALSE zurückgeben.
}
LRESULT CDlg_Rights::OnEndLabelEditVariableCriteria(WPARAM wParam, LPARAM lParam)
{
LV_DISPINFO* pDispInfo = (LV_DISPINFO*)lParam;
// TODO: Add your control notification handler code here
if (wParam == IDC_LIST1)
{
// Update the item text with the new text
CString strUpdatedTxt = pDispInfo->item.pszText;
// Validate the format of the new string for the edit columns
// If invalid then
// Set pResult to 1
switch(pDispInfo->item.iSubItem)
{
case 0:
case 1:
break;
default:
{
if (!strUpdatedTxt.IsEmpty())
{
// Get the left most non numeral characters
// Get the remaining numerals
// If the left most part does not contain the mandatory conditions
// Or the rest contains the mandatory conditions
// Display an error and set focus back onto the control
int iFirstNumeralOccurrance = strUpdatedTxt.FindOneOf("0123456789.");
CString strNonNumerals = strUpdatedTxt.Left(iFirstNumeralOccurrance);
CString strNumerals = strUpdatedTxt.Mid(iFirstNumeralOccurrance);
strNonNumerals.TrimLeft();
strNonNumerals.TrimRight();
strNumerals.TrimLeft();
strNumerals.TrimRight();
int iDecimalIndex = strNumerals.Find(".");
if ((-1 != iDecimalIndex) && (iDecimalIndex != (strNumerals.GetLength() - 1)))
{
iDecimalIndex = strNumerals.Find(".", iDecimalIndex + 1);
}
// Check that the condition is either
// Not empty or "=" or "!=" or "<" or ">" or "<=" or ">="
// The Numerals do not contain
// Space or more than 1 "." or any of the conditions
if (
(!strNonNumerals.IsEmpty()) ||
(-1 != strNumerals.Find(" ")) ||
(-1 != iDecimalIndex)
)
{
AfxMessageBox("Invalid text entered. The text will be reset");
m_ctrl_combolist.SetItemText(pDispInfo->item.iItem, pDispInfo->item.iSubItem, "");
}
return 0;
}
}
break;
}
}
return 1;
}
LRESULT CDlg_Rights::PopulateComboList(WPARAM wParam, LPARAM lParam)
{
// Get the Combobox window pointer
CComboBox* pInPlaceCombo = static_cast<CComboBox*> (GetFocus());
// Get the inplace combbox top left
CRect obWindowRect;
pInPlaceCombo->GetWindowRect(&obWindowRect);
CPoint obInPlaceComboTopLeft(obWindowRect.TopLeft());
// Get the active list
// Get the control window rect
// If the inplace combobox top left is in the rect then
// The control is the active control
m_ctrl_combolist.GetWindowRect(&obWindowRect);
int iColIndex = wParam;
CStringList* pComboList = reinterpret_cast<CStringList*>(lParam);
pComboList->RemoveAll();
if (obWindowRect.PtInRect(obInPlaceComboTopLeft))
{
if (1 == iColIndex)
{
pComboList->AddTail("Item 1");
pComboList->AddTail("Item 2");
pComboList->AddTail("Item 3");
}
if (2 == iColIndex)
{
pComboList->AddTail("gut");
pComboList->AddTail("voll");
pComboList->AddTail("none");
}
}
return true;
}
Nun heisst es :
The WM_SET_ITEMS message is posted using ::SendMessage() to the parent.
Do wo und mit welchen Parametern sende ich diese Nachricht ??
Vielleicht hat das ja mal jemand eingesetzt und kann mir helfen ?
Gruß Linus