Click here to Skip to main content
15,913,854 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: DllUnregisterServer Pin
George_George31-Oct-07 21:58
George_George31-Oct-07 21:58 
AnswerRe: DllUnregisterServer Pin
Paresh Chitte29-Oct-07 21:00
Paresh Chitte29-Oct-07 21:00 
GeneralRe: DllUnregisterServer Pin
George_George29-Oct-07 21:31
George_George29-Oct-07 21:31 
QuestionData entry when unicode character set is enabled [modified] Pin
Jarrah_1229-Oct-07 20:34
Jarrah_1229-Oct-07 20:34 
AnswerRe: Data entry when unicode character set is enabled Pin
John R. Shaw30-Oct-07 20:34
John R. Shaw30-Oct-07 20:34 
GeneralRe: Data entry when unicode character set is enabled Pin
Jarrah_1231-Oct-07 8:20
Jarrah_1231-Oct-07 8:20 
QuestionHow to auto-size the header control? [modified] Pin
neil478129-Oct-07 20:20
neil478129-Oct-07 20:20 
AnswerRe: How to auto-size the header control? [modified] Pin
Nelek30-Oct-07 1:12
protectorNelek30-Oct-07 1:12 
First of all... Sorry for the extension of the message, I hope it helps you.

EDIT: if my answer has nothing to do with what you asked for... please tell me and I will delete it.


I am not as good as other users but I try to explain my point of view.

I have used a CListCtrl in my project with a variable number of columns, the width of some columns are fixed the other are variable depending on the length of the subitems.

To do this, I have made a bypass (maybe there are better ways to do it, but it works for me).

I explain a bit to let you understand my way of thinking. My project is to do Fuzzy control, that means some inputs go through a regler to give a concrete value to an output. The CListCtrl is used in the regler to stablish the different combinations that rule the output's value. So it needs to know how many inputs are connected to the regler (output is only one) to set the number of columns. Every input has attributes that are used to stablish a rule (like "when I11 and I21 and I35 then O21 with X=0,75", Input1 parameter1 and Input2 parameter1 and input3 parameter5 should trigger output2 parameter1 with a value in 75%)

I hope you get the idea. It is important to my structure.

I have coded the initialization of the CListCtrl and the Upgrade of values in different functions that are called when necessary by the OnDraw (). This is because if the name of any attribute changes, or an input connection is deleted or something like this, I close the form because the complete structure of the ListCtrl should change as well.

I do it more or less like that:
void CParamRegTabView::InitializeView()
{	// Declaration of what is needed
	LV_COLUMN lvCol;
	int nCol = 0;

	DWORD dwStyle;
	dwStyle = LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES;
	m_clcRuleList.SetExtendedStyle (dwStyle);         //m_clcRuleList is a member variable associated with the ListCtrl

	// All column's common configuration
	lvCol.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
	lvCol.fmt = LVCFMT_CENTER;

	// First column's special configuration and insertion
	lvCol.cx = TABCOLWIDTH - 35;
	lvCol.iSubItem = 0;
	lvCol.pszText = "RegelNr.";
	m_clcRuleList.DeleteColumn (nCol);
	m_clcRuleList.InsertColumn (nCol, &lvCol);

	// Create Input's Table columns 
	for (nCol = 1; nCol <= m_pRegPar->m_cmlInConSet.GetCount (); nCol++)
	{	//Here I check the attribute with the longest name and save the number of chars in nMaxLength

		// Configuration's change and column insertion
		lvCol.cx = nMaxLength * 8; //8 pixels for letter * number of letters in longest name
		lvCol.iSubItem = nCol;
		lvCol.pszText = TransformTextFormat(m_pRegPar->m_cmlInConSet[nCol-1]);  //Here i adapt the CString to the LPTSTR in a function, just casting didn't work for me
		m_clcRuleList.DeleteColumn (nCol);
		m_clcRuleList.InsertColumn (nCol, &lvCol);
	}

	// Create Operator's and "Gewichtungsfaktor"'s column
	lvCol.cx = TABCOLWIDTH - 40;  // Fixed width
	lvCol.iSubItem = nCol;
	lvCol.pszText = "Oper.";
	m_clcRuleList.DeleteColumn (nCol);
	m_clcRuleList.InsertColumn (nCol, &lvCol);
	lvCol.iSubItem = nCol+1;
	lvCol.pszText = "GWF";
	m_clcRuleList.DeleteColumn (nCol+1);
	m_clcRuleList.InsertColumn (nCol+1, &lvCol);

	// Create OutAttributes' column
	// Another time check for longest name
	lvCol.cx = nMaxLength * 8;
	lvCol.iSubItem = nCol+2;		
	lvCol.pszText = TransformTextFormat(m_pOutCon->m_szOutName); // Another time changing format
	m_clcRuleList.DeleteColumn (nCol+2);
	m_clcRuleList.InsertColumn (nCol+2, &lvCol);

	// Create column for Attributes' Rule's value
	lvCol.cx = TABCOLWIDTH - 38;  // Fixed length for the % of rule value
	lvCol.iSubItem = nCol+3;
	lvCol.pszText = "AttValue";
	m_clcRuleList.DeleteColumn (nCol+3);
	m_clcRuleList.InsertColumn (nCol+3, &lvCol);

	// First time is ready, so reset flag
	m_bJustOpened = FALSE;  //This is to avoid intereferences
	return;
}


code above stablish the ListCtrl formats, columns headers, width...

the insertion of the values, attribute names and so on... (contents of every cell) are made in DrawViewElements (), but this has nothing to do with your question.

and I call them by...
void CParamRegTabView::OnDraw(CDC* pDC) 
{	// TODO: Speziellen Code hier einfügen und/oder Basisklasse aufrufen

	if (m_bJustOpened)
		InitializeView ();
	if (m_bListRedraw)
		DrawViewElements ();
	return;	
}


So... with this code. When a critical change happens (attribute deleted, input disconnection or something like that) I close the frame and by new opening the table is new configured thanks the m_bJustOpened (set to TRUE in the constructor). When a working point of any input changes its value, I set the m_bListRedraw to true and send a pDoc->UpdateAllViews (NULL) from the origin of the value change.


The only problem I could not avoid yet is that, when a double clik in the separator between two columns headers is made, then the column is resized to the header content size, cutting the contents of the subitems in that column.
If anyone knows how to avoid it, the answer will be wellcome, but atm is not important for me.

I mean:
Header =___________________________|____Input1____|
anywhere in the column a subitem with = |VeryFastChange|

after double click in the right "|"

Header =___________________________|_Input1_|
anywhere in the column a subitem with = |VeryFa..|

(The underscores are empty spaces, but if not used, the perspective is lost, multiple empty spaces are not considered)



Sorry for the length, I hope it helps you.

Any other tips from people that reads it are wellcome


-- modified at 7:28 Tuesday 30th October, 2007

Greetings.

--------
M.D.V.

If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?

Help me to understand what I'm saying, and I'll explain it better to you

Wink | ;)

AnswerRe: How to auto-size the header control? Pin
David Crow30-Oct-07 3:30
David Crow30-Oct-07 3:30 
QuestionGetting current logged in user Pin
Anand Todkar29-Oct-07 20:05
Anand Todkar29-Oct-07 20:05 
QuestionRe: Getting current logged in user Pin
David Crow30-Oct-07 3:31
David Crow30-Oct-07 3:31 
AnswerRe: Getting current logged in user Pin
Blake Miller20-Nov-07 6:34
Blake Miller20-Nov-07 6:34 
Questionshowing dialog box and progress bar... Pin
neha.agarwal2729-Oct-07 20:03
neha.agarwal2729-Oct-07 20:03 
AnswerRe: showing dialog box and progress bar... Pin
Hamid_RT29-Oct-07 20:08
Hamid_RT29-Oct-07 20:08 
GeneralRe: showing dialog box and progress bar... Pin
neha.agarwal2729-Oct-07 20:22
neha.agarwal2729-Oct-07 20:22 
GeneralRe: showing dialog box and progress bar... Pin
Hamid_RT29-Oct-07 20:36
Hamid_RT29-Oct-07 20:36 
AnswerRe: showing dialog box and progress bar... Pin
JudyL_MD30-Oct-07 2:45
JudyL_MD30-Oct-07 2:45 
AnswerRe: showing dialog box and progress bar... Pin
David Crow30-Oct-07 3:33
David Crow30-Oct-07 3:33 
QuestionDoModal() problem, completed confused! Pin
fantasy121529-Oct-07 19:56
fantasy121529-Oct-07 19:56 
QuestionRe: DoModal() problem, completed confused! Pin
Hamid_RT29-Oct-07 20:06
Hamid_RT29-Oct-07 20:06 
GeneralRe: DoModal() problem, completed confused! Pin
fantasy121529-Oct-07 20:17
fantasy121529-Oct-07 20:17 
GeneralRe: DoModal() problem, completed confused! Pin
Hamid_RT29-Oct-07 20:42
Hamid_RT29-Oct-07 20:42 
AnswerRe: DoModal() problem, completed confused! Pin
Neo Andreson29-Oct-07 20:28
Neo Andreson29-Oct-07 20:28 
GeneralRe: DoModal() problem, completed confused! Pin
fantasy121529-Oct-07 20:40
fantasy121529-Oct-07 20:40 
GeneralRe: DoModal() problem, completed confused! Pin
Neo Andreson29-Oct-07 21:24
Neo Andreson29-Oct-07 21:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.