Solved

how to add CDialogTemplate to a CListview?

Posted on 2008-10-27
16
401 Views
Last Modified: 2013-11-20
Hi,

how to add a CDilaogTempalte to a CListview.which contains buttons on top of CListctrl header.
that button action should perform some actioh in Clistctrl.
0
Comment
Question by:srikadi
  • 9
  • 7
16 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 22810849
You could use a CFormView instead.
Put the buttons where you want and a list control onto the dialog in the resource editor
0
 

Author Comment

by:srikadi
ID: 22810864
thanx for ur reply..
i did same thing but its not working properly..the listctrl is taking values but not showing to user..i don't know what could be the problem..
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 22810877
How do you add values to the list control?  (Check it is in report mode - I assume you want columns of information).
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:srikadi
ID: 22810891
ya..its in report mode..when i scan the node the values comes to the CListctrl..before it has worked fine..but when i placed on formview its not working..i know its taking values adding to the database but not showing in Clistctrl..
that y i asked some other alternate solution......
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 22810936
Please show your code for adding the info to the list control.
0
 

Author Comment

by:srikadi
ID: 22810964


BeginWaitCursor();
 CDatabase * commonDatabase = CTresManApp::GetDatabaseObject();
 ErrorRepository errorRep(commonDatabase);
 
 //get the filter (if any) from the network tree. If no filter is available, then
 //the whole NodeList table is considered when generating the task list table contents
// CString taskFilter = m_nwSplitter.GetNwTreeFilter();
 CString taskFilter = m_nwSplitter2.GetNwTreeFilter();
 //fill database with scan tasks
 TaskListDbHandler::Instance()->FillTaskListTable(taskFilter);
 CTresManApp * pApp = (CTresManApp *)AfxGetApp();
 ASSERT(pApp);
 
/**/CTaskFormView * pNwVList1 = (CTaskFormView *)m_nwSplitter2.GetPane(2,0);
 CTaskListView * pNwVList=(CTaskListView *)pNwVList1->GetTaskListView();
 ASSERT(pNwVList);

/* CDbView * tskvw = (CDbView *) pApp->GetView(CTresManStates::Views::TASKFORMVIEW);
 ASSERT(tskvw);
 //set the dirty flag for the recordset. Recordset will be requeryd. This one is for the TaskList view
 if (tskvw)
 {
  tskvw->SetRecordsetDirty();
 }*/
 if (pNwVList)
 {
  pNwVList->SetRecordsetDirty();
 }
 EndWaitCursor();
before the code was with CListview..now i changed to CFormview..
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 22810991
Where is the list control?
0
 

Author Comment

by:srikadi
ID: 22811008
CTaskListView is the Clistctrl  so..presently i am getting data to this CTaskListView .so i am calling this in CTaskFormView  which is CFormview class.
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 22811032
Is pNwVList non NULL ?
Are you getting any records back from the database ?


What is the code in SetRecordsetDirty ?
0
 

Author Comment

by:srikadi
ID: 22811048
yes..iam getting records..
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 22811420
You have still not posted the code that is for adding the items to the list control.

Please confirm that CTaskListView is based on the CListCtrl class.
0
 

Author Comment

by:srikadi
ID: 22811501
yes,CTaskListView is based on the CListCtrl class.
0
 

Author Comment

by:srikadi
ID: 22811510
sorry,CTaskListView is based on the CListView  class
0
 

Author Comment

by:srikadi
ID: 22811617

 if (!m_dSource.IsOpen())
  {
   return;
  }
  //if the recordset is empty, we display a notification label for the user
  if (pItem->iItem == 0 && m_dSource.GetRecordCount() == 0)
  {
   if (pItem->iSubItem == m_firstVisibleColumn )
   {
    RemoveSelection();
    pItem->pszText = (LPTSTR)(LPCTSTR)m_emptyString;
   }
   return;
  }
  // called when the listview needs to display data
  if(pItem->mask & LVIF_TEXT)
  {
   // first, move to the appropriate row in the database
   CString itemText, itemTextTrunc;
   if( m_dSource.PositionCursor(pItem->iItem) &&
    (m_dSource.GetValueByColName(m_columnHeaders.GetViewFieldName((short)pItem->iSubItem), itemText) ))
   {
    //if there is an index column, it is used for indexing the displayed items
    //this is used only for the first column item because there's no reason to duplicate
    //the information
    //Truncate string if necessary.
    if (itemText.GetLength() > pItem->cchTextMax)
    {
     CString itemTextTrunc;
     itemTextTrunc.LoadString(IDS_STRING_TO_LONG);
     int nTrunc = itemTextTrunc.GetLength() + 1;
     itemText = itemText.Left(pItem->cchTextMax - nTrunc) + itemTextTrunc;
    }
 
    lstrcpy(pItem->pszText, (LPCTSTR)itemText );
   }
   else
   {
    m_isRecordSetDirty = TRUE;
   }
   if (m_isRecordSetDirty)
   {
    SetRecordsetDirty();
    m_isRecordSetDirty = FALSE;
   }
  }
0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 22811741
Well, you add controls to a resource dialog - so you need to link the control on the dialog to a member variable.
Select the control in resource editor, select add variable and add a CONTROL variable of type CListCtrl.

Now give your code another try.
0
 

Author Comment

by:srikadi
ID: 22811781
sorry,i didn't get u..i don't have any resource dialog for Clistctrl..
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
repeatSeparator  java  challenge 13 58
CRON statement to run every 3 minutes except on Monday morning 12am to 2am 7 101
WinWaitActive parameters 12 31
has22 challenge 11 104
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question