|

Introduction
List control especially with the “report” style is one of the most commonly used controls in any UI.
At times as a developer, we would like to be able to
- Select from a list of items for the value of a cell
- Key in the value for any of the cells
- Entire read only column
Developing a list control with these features takes substantial amount of time. I have just tried to create reusable classes that would provide the developer to accommodate in place drop down combo box and edit control.
The columns of the list control can be assigned the above mentioned properties through the public interfaces. This sample is also an example of a control embedded within another control by making the embedded control an attribute of the parent control. By default all the cells support in place edit control.
The code for this article was written on Windows 2000 Professional with Microsoft Visual C++ 6. I have tested the and used the same in my work.
Features
The developer who needs to use a list control as described above just has to include the following files in the project
- ComboListCtrl.cpp
- ComboListCtrl.h
- InPlaceEdit.cpp
- InPlaceEdit.h
- InPlaceCombo.cpp
- InPlaceCombo.h
The developer will need to create a list control resource and associate a control member variable with the same. Then type “CListCtrl” will have to be modified to “CComboListCtrl”.
The columns that need to support in place combo box, edit control and read only property can be specified using the public interfaces available.
The list of items to be shown in the drop down of the combo box can be specified by the parent class. This allows different columns to have different set of items.
In case of the edit control, the valid characters can be specified. If nothing is specified then all characters are considered valid. In addition to the internal validations for characters being keyed in and pasted, the parent control is given a notification for further validations. This allows the parent class to handle any validation specific to the format.
The read only columns as the name suggests is beyond the end user manipulation.
The developer can also enable or disable the horizontal and vertical scroll bars for the in place combo box.
Public Methods
The columns which need to support the in place combo box can be set by passing the column index to SetComboColumns. By default this function will enable the support of combo box in the cells. The combo box support can be reset by passing the second default argument as false.
void SetComboColumns(int iColumnIndex, bool bSet = true);
The columns which need to act as read only can be set by passing the column index to SetReadOnlyColumns. By default this function will enable the read only property in the cells. The combo box support can be reset by passing the second default argument as false.
void SetReadOnlyColumns(int iColumnIndex, bool bSet = true);
The valid characters for the edit control can be set by SetValidEditCtrlCharacters. The in place edit control will allow only these characters to be keyed in or pasted to the control. On pasting either all invalid characters or a combination of valid and invalid characters, the paste operation will not succeed.
void SetValidEditCtrlCharacters(CString& rstrValidCharacters);
The combo box usually has the ability to support vertical and horizontal scroll bars. But in case of an embedded in place control the need for the same would depend on the usage. The scroll bars can be enabled or disabled by the following interfaces which function much similar to the EnableWindow().
void EnableVScroll(bool bEnable = true);
void EnableHScroll(bool bEnable = true);
User Defined Messages
The text entered in the edit control may need to be validated for its format as per the usage. For this the in place control will have to send a message to the parent of the list control indicating that end of edit operation. The user defined message WM_VALIDATE is used sent to the parent to indicate the end of editing. The parent class may handle this message to make the necessary validations for the format.
#define WM_VALIDATE WM_USER + 0x7FFD
The items in the combo box will have to be externally specified by the parent of the list control. The WM_SET_ITEMS message is posted using ::SendMessage() to the parent. The parent can handle this message and fill in the list of items to be shown in the combo box. The items can be different for each column. This can be achieved as shown in the example below.
#define WM_SET_ITEMS WM_USER + 0x7FFC
ExampleLRESULT CMyDialog::PopulateComboList(WPARAM wParam, LPARAM lParam)
{
CStringList* pComboList = reinterpret_cast<CSTRINGLIST*> (lParam);
pComboList->RemoveAll();
if (iColumnIndex == 1)
{ pComboList->AddTail("Name1");
pComboList->AddTail("Name2");pComboList->AddTail("Name3");
}
else if (iColumnIndex == 2)
{pComboList->AddTail("Age1");
pComboList->AddTail("Age2");pComboList->AddTail("Age3");
}
}
| You must Sign In to use this message board. |
|
| | Msgs 1 to 25 of 49 (Total in Forum: 49) (Refresh) | FirstPrevNext |
|
 |
|
|
Hi!
Is there a way to draw a Frame around editable entries in the ListBox, so it would look like a normal EditControl?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
listctrl\inplaceedit.cpp(47) : error C2440: 'static_cast' : cannot convert from 'void (__thiscall CInPlaceEdit::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)' 1> Cast from base to derived requires dynamic_cast or static_cast
I cannot get this to compile.
Chris
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
You have used CBS_DROPDOWNLIST type in the combo box. But if I want to make it a editable combo box then I have to set the style as CBS_DROPDOWN. But this is not working. Could you plz tell me how can I make it editable?
|
| Sign In·View Thread·PermaLink | 5.00/5 (3 votes) |
|
|
|
 |
|
|
Thanx The.Saint for the nice code. 1) Is there possibility to merge this code with 'Virtualizing List Views to Handle Large Amounts of Data' code that on 'CodeGuru' forum to get both advantages of them,It will be perfect control. 2) When i created ur list control on dialog box,It's ran good on Win98,but on Win XP the 'OnGetdispinfo' handler not worked and the items of list shows as transparent!! why?! Thanx a lot.
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
Nic article
Bt hw to resize combo box to fit into CListCtrl
or increase listctrl row width to fit the combo box
|
| Sign In·View Thread·PermaLink | 1.75/5 (3 votes) |
|
|
|
 |
|
|
Compiling the cource I get error Message because missing type specifier (using Vis. Studio 2005 )
operator = (CInPlaceEdit) {}
and
operator = (CInPlaceCombo) {}
wich type I have to choose ?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Sorry,
haven't got hold of Vis Studio 2005 yet. So am not sure what the problem is.
Life is short, enjoy it with a smile as long as it lasts. User error. Replace User and press any key when ready. - Anonymous
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I got it )
CInPlaceCombo operator = (CInPlaceCombo) {}
CInPlaceEdit operator = (CInPlaceEdit) {}
and
afx_msg LRESULT OnPaste(WPARAM wParam, LPARAM lParam);
now it works
|
| Sign In·View Thread·PermaLink | 2.67/5 (3 votes) |
|
|
|
 |
|
|
 |
|
|
i want the combo box to be editable, but when the combo box kill focus, it is the combo box's edit control who get focus, how to handle this?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I will try this and let you know.
Life is short, enjoy it with a smile as long as it lasts. User error. Replace User and press any key when ready. - Anonymous
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Thanks! I have downloaded your demo and set a in place combo box in a listctrl's column. but i want to set a initial selection when the control is shown. in your demo nothing is selected at the beginning,user have to click the column to populate the combox and pick one item. how to solve the problem?
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
Hi, I am not sure but I suppose that if you call SetCurSel with the Combobox class, it should work. I shall check this and try to help you.
Life is short, enjoy it with a smile as long as it lasts. User error. Replace User and press any key when ready. - Anonymous
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
I wonder - is it an easy way to get the focus jump to next field on enter (in an edit field)?
I have tried to implement this myself with no success. I get the focus to move (the blue field), but I can not get it in edit modus.
/Espen
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
Hello,
Thanks for this useful set of classes : my project needed a dynamic list of editable fields and this fits the bill exactly.
I have noticed that the display breaks up if you scroll the list (using mouse wheel or scroll bar) while a field is being edited. I worked round this in my project by setting a flag before creating the combo / edit and then ignoring Vertical Scroll or Mouse Wheel messages for the list while the flag was set.
As a minor aside, I also had to use FindStringExact()in the OnLButtonDown() function, as some of my combo strings are substrings of others.
Regards,
Graham
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Is there any way to add a Date Time Picker control to the list control?
-- Edward Livingston (aka ExtraLean) -- "I still maintain that seeing a nipple is far less disturbing than seeing someone get their brains blown out." -- Chris Maunder
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I am trying to resolve some of my other problems using Rational Purify to check what is happening. Purify complains about some items in the code (the bold line):
int CComboListCtrl::InsertColumn( int nCol, char * lpszColumnHeading,int nFormat,int nWidth,int nSubItem ) {
int li_rv = CListCtrl::InsertColumn(nCol,lpszColumnHeading,nFormat,nWidth,nSubItem ); CHeaderCtrl* pHeader ; HD_ITEM hdr_item;
pHeader = GetHeaderCtrl(); VERIFY( m_header_ctrl.SubclassWindow( pHeader->m_hWnd ) ); hdr_item.pszText = lpszColumnHeading ; hdr_item.mask = HDI_FORMAT | HDI_TEXT ; hdr_item.fmt = nFormat | HDF_OWNERDRAW;//HDF_CENTER |HDF_STRING | HDF_OWNERDRAW ; m_header_ctrl.SetItem(nCol,&hdr_item);
return li_rv ; }
The call stack: [I] Message: Assertion failed! Call location CrtDbgReport [dbgrpt.c:299] AfxAssertFailedLine(char const*,int) [afxasert.cpp:39] CWnd::SubclassWindow(HWND__ *) [wincore.cpp:3877] CComboListCtrl::InsertColumn(int,char *,int,int,int) [C:\vss\TCD\listcontrol\ComboListCtrl.cpp:440] HD_ITEM hdr_item; pHeader = GetHeaderCtrl(); => VERIFY( m_header_ctrl.SubclassWindow( pHeader->m_hWnd ) ); hdr_item.pszText = lpszColumnHeading ; hdr_item.mask = HDI_FORMAT | HDI_TEXT ; hdr_item.fmt = nFormat | HDF_OWNERDRAW;//HDF_CENTER |HDF_STRING | HDF_OWNERDRAW ; COperationalLimit::Setup_ListCtrl(void) [C:\vss\TCD\OperationalLimit.cpp:427] if(li_col == CP_OI_COMPANY) m_list.InsertColumn(li_col, (char *)(LPCTSTR)plcCols->m_header, LVCFMT_LEFT, li_width); else => m_list.InsertColumn(li_col, (char *)(LPCTSTR)plcCols->m_header, LVCFMT_RIGHT, li_width); li_col++ ; } m_list.SetExtendedStyle( LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES ) ; COperationalLimit::OnInitialUpdate(void) [C:\vss\TCD\OperationalLimit.cpp:183] CWnd::OnWndMsg(UINT,UINT,long,long *) [wincore.cpp:1835] CWnd::WindowProc(UINT,UINT,long) [wincore.cpp:1596] AfxCallWndProc(CWnd *,HWND__ *,UINT,UINT,long) [wincore.cpp:215] CWnd::SendMessageToDescendants(HWND__ *,UINT,UINT,long,int,int) [wincore.cpp:2317]
The function that is calling the "insertColumn":
void COperationalLimit::Setup_ListCtrl() { int li_col ; POSITION l_pos ; int li_width ; CResourceLCCols* plcCols ; CResMarketSmryDoc* pDoc =(CResMarketSmryDoc *) GetDocument();
li_col = 0 ; m_list.DeleteAllItems(); l_pos = pDoc->m_cl_cols_list.GetHeadPosition() ;
while ( l_pos != NULL ) {
plcCols = pDoc->m_cl_cols_list.GetNext( l_pos ) ;
switch ( li_col ) {
case CP_OL_COMPANY: li_width = 110; break;
default : li_width = 85 ; break ; } if(li_col == CP_OI_COMPANY) m_list.InsertColumn(li_col, (char *)(LPCTSTR)plcCols->m_header, LVCFMT_LEFT, li_width); else m_list.InsertColumn(li_col, (char *)(LPCTSTR)plcCols->m_header, LVCFMT_RIGHT, li_width); li_col++ ; } m_list.SetExtendedStyle( LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES ) ;
// Sets/Resets the column, which support the in place combo box
m_list.SetReadOnlyColumns(CP_OL_COMPANY, TRUE); m_list.SetReadOnlyColumns(CP_OL_ADJ_VALUE, TRUE); m_list.SetReadOnlyColumns(CP_OL_MEMBER_EXP, TRUE);
CString strValidChars = "0123456789."; m_list.SetValidEditCtrlCharacters(strValidChars);
m_list.m_header_ctrl.Set_HeaderLinesNo( 2 ) ;
}
Does anybody have a clue of what is happening? In "release" nothing seems wrong, but when running in "Debug" I got lots of assertions - seems to one for each coloumn.
/Espen
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I find the PopulateComboList message we define by ourself can't work, who know why? And I set Gridline for it, but can't see them. ListView_SetExtendedListViewStyleEx(m_ctlList.GetSafeHwnd(), LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT|LVS_SHOWSELALWAYS , LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT|LVS_SHOWSELALWAYS );
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I got it! It can works well in formview now. In the formview, I set the listctrl's style "Edit labels" to the state of selected, then it work!
The second problem still there, why can't see gridlines?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
dear sir
I have a been trying to implement your idea about a
combobox into a application that has CFormView instead of
Cdialog. It works exept that when I click on the combobox
I cannot select any of the items in the list but the
cursor imeddiately jumps to the first column. I believe
this is because your function
OnEndLabelEditVariableCriteria executes when I click to
expand the combobox and I don't know why this is
anyway the same code works with a cdialog instead
Please help me with this I really need the help
I can provide the source for anyone that might want to
help me.
thank you all in advance
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi, I have not tested this control extensively with CFormView. Please send me the code and I will see if I can help.
Life is short, enjoy it with a smile as long as it lasts.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I cannot attach files to my message when i use the codeproject interface So I would really need a mail address to communicate with you
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
Hi, I am using this controller in an application using CFormView, but I do not understand if we comply to you need.
Here is the source code for a simple screen that uses the control (the source code for 2 container classes is also added since they are in use in the grid, and they are from the same files):
H file ------------ #if !defined(AFX_CHECKRESULT_H__F9AB9BFA_E844_47DB_98DA_C26D6D09BCAD__INCLUDED_) #define AFX_CHECKRESULT_H__F9AB9BFA_E844_47DB_98DA_C26D6D09BCAD__INCLUDED_
#if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // CheckResult.h : header file //
///////////////////////////////////////////////////////////////////////////// // CCheckResult form view
#ifndef __AFXEXT_H__ #include #endif
/****************************************************************************/ /* Class CNGTS_CheckResult_Info */ /****************************************************************************/ class CNGTS_CheckResult_Info { protected: public: CNGTS_CheckResult_Info() ;
CNGTS_CheckResult_Info( NP_LIMIT_CHECK_INFO_REC * ) ;
public: NP_LIMIT_CHECK_INFO_REC m_rec ;
};
/****************************************************************************/ /* Class CNGTS_CheckResult_List */ /****************************************************************************/ class CNGTS_CheckResult_List { protected:
public: int m_total ; CArray m_list ;
public:
int Info_Add( NP_LIMIT_CHECK_INFO_REC *ptr_inrec) ; int Info_Delete( NP_LIMIT_CHECK_INFO_REC *ptr_inrec ) ; CNGTS_CheckResult_Info *Locate_CheckResult( NP_LIMIT_CHECK_INFO_REC *ptr_inrec ) ;
} ;
#define CP_CR_COLS 5 #define CP_COMPANY 0 #define CP_CR_ORDER_ID 1 #define CP_CR_PRICE 2 #define CP_CR_VOLUME 3 #define CP_CR_AMOUNT 4
class CCheckResult : public CFormView { protected: CCheckResult(); // protected constructor used by dynamic creation DECLARE_DYNCREATE(CCheckResult)
// Form Data public: //{{AFX_DATA(CCheckResult) enum { IDD = IDD_CHECKRESULT }; CButton m_close; /*CComboListCtrl*/CResourceListCtrl m_list; //}}AFX_DATA
// Attributes public:
// Operations public: void Save_Setting( CString ps_section ) ; void Restore_Setting(CString ps_section); void ItemAdd_ListCtrl( CNGTS_CheckResult_Info* ptr_rec ) ; void OnWithdrawOrder(); // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CCheckResult) public: virtual void OnInitialUpdate(); protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint); //}}AFX_VIRTUAL
// Implementation protected: virtual ~CCheckResult(); void Setup_ListCtrl() ; void Fill_ListCtrl() ; afx_msg void OnContextMenu(CWnd*, CPoint point); void Resize_Controls( int pi_x, int pi_y ) ; #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif
// Generated message map functions //{{AFX_MSG(CCheckResult) afx_msg void OnClose(); afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MSG DECLARE_MESSAGE_MAP() };
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_CHECKRESULT_H__F9AB9BFA_E844_47DB_98DA_C26D6D09BCAD__INCLUDED_)
CPP file -------------- // CheckResult.cpp : implementation file //
#include "stdafx.h" #include "ngxts.h" #include "CheckResult.h"
#ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif
/****************************************************************************/ /* Class CNGTS_CheckResult_Info */ /****************************************************************************/ CNGTS_CheckResult_Info::CNGTS_CheckResult_Info() { memset( &m_rec, 0, sizeof( NP_LIMIT_CHECK_INFO_REC )) ; }
CNGTS_CheckResult_Info::CNGTS_CheckResult_Info( NP_LIMIT_CHECK_INFO_REC *ptr_inrec ) {
memcpy( &m_rec, ptr_inrec, sizeof( NP_LIMIT_CHECK_INFO_REC )) ;
}
/****************************************************************************/ /* Class CNGTS_CheckResult_Info */ /****************************************************************************/ //------------------------CNGTS_CheckResult_List::Info_Add------------------ int CNGTS_CheckResult_List::Info_Add( NP_LIMIT_CHECK_INFO_REC *ptr_inrec) { Info_Delete(ptr_inrec);
m_list.Add( CNGTS_CheckResult_Info( ptr_inrec )) ; m_total++ ;
return(1); }
//------------------------CNGTS_CheckResult_List::Info_Delete------------------ int CNGTS_CheckResult_List::Info_Delete( NP_LIMIT_CHECK_INFO_REC *ptr_inrec ) {
CNGTS_CheckResult_Info *lptr ;
lptr = Locate_CheckResult( ptr_inrec ) ; if ( lptr ) {
int li_idx = lptr - &m_list[0] ; m_list.RemoveAt( li_idx ) ;
m_total-- ; return 1 ; } return 0 ;
}
//---------------------------CNGTS_CheckResult_List::Locate_CheckResult------------------- CNGTS_CheckResult_Info *CNGTS_CheckResult_List::Locate_CheckResult( NP_LIMIT_CHECK_INFO_REC *ptr_inrec ) {
NP_LIMIT_CHECK_INFO_REC* ptr;
for(int i=0;i {
ptr = (NP_LIMIT_CHECK_INFO_REC*) &m_list[i].m_rec;
if(strcmp(ptr->order_reference,ptr_inrec->order_reference)==0) return(&m_list[i]); }
return NULL ;
}
///////////////////////////////////////////////////////////////////////////// // CCheckResult
IMPLEMENT_DYNCREATE(CCheckResult, CFormView)
CCheckResult::CCheckResult() : CFormView(CCheckResult::IDD) { //{{AFX_DATA_INIT(CCheckResult) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT }
CCheckResult::~CCheckResult() { }
void CCheckResult::DoDataExchange(CDataExchange* pDX) { CFormView::DoDataExchange(pDX); //{{AFX_DATA_MAP(CCheckResult) DDX_Control(pDX, IDCLOSE, m_close); DDX_Control(pDX, IDC_ORDER_LIST, m_list); //}}AFX_DATA_MAP }
BEGIN_MESSAGE_MAP(CCheckResult, CFormView) //{{AFX_MSG_MAP(CCheckResult) ON_WM_CONTEXTMENU() ON_BN_CLICKED(IDCLOSE, OnClose) ON_WM_SIZE() //}}AFX_MSG_MAP ON_COMMAND(ID_WITHDRAWORDER, OnWithdrawOrder) END_MESSAGE_MAP()
///////////////////////////////////////////////////////////////////////////// // CCheckResult diagnostics
#ifdef _DEBUG void CCheckResult::AssertValid() const { CFormView::AssertValid(); }
void CCheckResult::Dump(CDumpContext& dc) const { CFormView::Dump(dc); } #endif //_DEBUG
///////////////////////////////////////////////////////////////////////////// // CCheckResult message handlers
void CCheckResult::OnClose() {
CResMarketSmryDoc* pDoc =(CResMarketSmryDoc *) GetDocument(); pDoc->OnCloseDocument() ; }
void CCheckResult::OnInitialUpdate() { CFormView::OnInitialUpdate();
CRect lt_rect ; CString lc_tempstr ; CResMarketSmryDoc *pDoc =(CResMarketSmryDoc *) GetDocument();
if ( pDoc->m_restore_section == "0" ) {
lc_tempstr.Format( "%s", pDoc->m_classname ) ; g_Res_Utils.LoadWindowXY((CWnd*) GetParentFrame(), (char *)(LPCTSTR)lc_tempstr, g_Res_PgmInfo.m_screen_file ) ; lc_tempstr.Format( "%s-bid", pDoc->m_classname ) ; g_Res_Utils.LoadListCtrlColWidth( &m_list, (char *)(LPCTSTR)lc_tempstr, pDoc->m_ctlList_cols, g_Res_PgmInfo.m_screen_file ) ; } else Restore_Setting( pDoc->m_restore_section ) ;
// determine the list ctrl height GetWindowRect( <_rect ) ; Resize_Controls( lt_rect.right - lt_rect.left - 20, lt_rect.bottom - lt_rect.top - 20 ) ;
Setup_ListCtrl() ;
m_list.DeleteAllItems(); Fill_ListCtrl();
// reading new data - delete of old list g_NGTS_CheckResult_List.m_list.RemoveAll(); g_NGTS_CheckResult_List.m_total = 0;
}
void CCheckResult::OnSize(UINT nType, int cx, int cy) {
CFormView::OnSize(nType, cx, cy); Resize_Controls(cx,cy); }
void CCheckResult::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) { m_list.DeleteAllItems(); Fill_ListCtrl(); }
void CCheckResult::Resize_Controls(int pi_x,int pi_y) {
CRect lrect; m_close.GetClientRect( &lrect ) ;
int width = lrect.right - lrect.left; int height = lrect.bottom - lrect.top;
m_list.MoveWindow(15,55,pi_x-30,pi_y-105,FALSE);
m_close.MoveWindow(pi_x-120,pi_y-35,width,height,FALSE);
this->Invalidate() ;
}
void CCheckResult::Setup_ListCtrl() { int li_col ; POSITION l_pos ; int li_width ; CResourceLCCols* plcCols ; CResMarketSmryDoc* pDoc =(CResMarketSmryDoc *) GetDocument();
li_col = 0 ; m_list.DeleteAllItems(); l_pos = pDoc->m_cl_cols_list.GetHeadPosition() ;
while ( l_pos != NULL ) {
plcCols = pDoc->m_cl_cols_list.GetNext( l_pos ) ;
switch ( li_col ) {
case CP_COMPANY: case CP_CR_ORDER_ID: case CP_CR_PRICE: case CP_CR_VOLUME: case CP_CR_AMOUNT: li_width = 70; break;
default : li_width = 85 ; break ; } m_list.InsertColumn(li_col, (char *)(LPCTSTR)plcCols->m_header, LVCFMT_RIGHT, li_width); li_col++ ; } m_list.SetExtendedStyle( LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES ) ;
// Sets/Resets the column, which support the in place combo box
/* m_list.SetReadOnlyColumns(CP_CR_ORDER_ID, TRUE); m_list.SetReadOnlyColumns(CP_CR_PRICE, TRUE); m_list.SetReadOnlyColumns(CP_CR_VOLUME, TRUE); m_list.SetReadOnlyColumns(CP_CR_AMOUNT, TRUE);*/
/* CString strValidChars = "0123456789."; m_list.SetValidEditCtrlCharacters(strValidChars);*/
m_list.m_header_ctrl.Set_HeaderLinesNo( 2 ) ;
}
//---------------CNGTSMarketMaint::Fill_ListCtrl---------- void CCheckResult::Fill_ListCtrl() { int li_i ; CString lc_tempstr;
CNGTS_CheckResult_Info* ptr = NULL; m_list.SetRedraw( FALSE ) ; m_list.DeleteAllItems();
for ( li_i = 0 ; li_i < g_NGTS_CheckResult_List.m_list.GetSize() ; li_i++ ) { ptr = &g_NGTS_CheckResult_List.m_list[li_i];
ItemAdd_ListCtrl(ptr);
if(li_i == 0) {
/* set static text telling the check type of the data */ /* m_vat.SetWindowText( lc_tempstr ) ;*/ } }
m_list.SetRedraw( TRUE ) ; }
void CCheckResult::ItemAdd_ListCtrl( CNGTS_CheckResult_Info *ptr_oi_attr ) { LV_ITEM lvitem ; CString lc_tempstr ; int li_current_item; CRes_Order_Info *lcs_order ; CNGTS_Instrument_Info *lptr_Instrument ;
lcs_order = g_Market_Summary.Locate_Order_By_OrderReference( ptr_oi_attr->m_rec.order_reference ) ;
// Locate the Market Pointer & Instrument if (( lptr_Instrument = lcs_order->Locate_Instrument()) == NULL ) return ;
lc_tempstr.Empty();
g_Market_Summary.Get_User_Company_Code( lcs_order->m_order_rec.company_id, &lc_tempstr ) ;
lvitem.pszText = (char *)(LPCTSTR)lc_tempstr ;
int iCount = m_list.GetItemCount();
li_current_item = m_list.InsertItem(LVIF_TEXT|LVIF_STATE, iCount, lc_tempstr,0,0, 0, 0);
lvitem.mask = LVIF_TEXT ; lvitem.iImage = 0 ; lvitem.iItem = li_current_item ;
lvitem.iSubItem = CP_CR_ORDER_ID ; lc_tempstr.Format("%d",lcs_order->m_order_rec.order_id); lvitem.pszText = (char *)(LPCTSTR)lc_tempstr ; m_list.SetItem( &lvitem ) ;
lvitem.iSubItem = CP_CR_PRICE ; lcs_order->Price_Format( lptr_Instrument, &lc_tempstr ) ; lvitem.pszText = (char *)(LPCTSTR)lc_tempstr ; m_list.SetItem( &lvitem ) ; lvitem.iSubItem = CP_CR_VOLUME ; lcs_order->Volume_Format( lptr_Instrument, &lc_tempstr ) ; lvitem.pszText = (char *)(LPCTSTR)lc_tempstr ; m_list.SetItem( &lvitem ) ;
lvitem.iSubItem = CP_CR_AMOUNT ; CString x,y; lc_tempstr.Format("%.2f",lcs_order->Volume_Format( lptr_Instrument, &x ) * lcs_order->Price_Format( lptr_Instrument, &y ));
lvitem.pszText = (char *)(LPCTSTR)lc_tempstr ; m_list.SetItem( &lvitem ) ;
m_list.SetItemData( li_current_item, (long)ptr_oi_attr ) ;
}
/*----------------CCheckResult::Save_Setting------------------*/ void CCheckResult::Save_Setting( CString pc_section ) { CString lc_tempstr ; CResMarketSmryDoc *pDoc =(CResMarketSmryDoc *) GetDocument(); lc_tempstr.Format( "%s", pDoc->m_classname ) ;
g_Res_Utils.WriteUserProfileString( pc_section, "name", (char *)(LPCTSTR)pDoc->m_classname, g_Res_PgmInfo.m_screen_file ) ; g_Res_Utils.SaveWindowXY((CWnd*) GetParentFrame(), pc_section, (char*)(LPCTSTR)lc_tempstr, g_Res_PgmInfo.m_screen_file ) ; g_Res_Utils.SaveListCtrlColWidth( &m_list, pc_section, (char *)(LPCTSTR)lc_tempstr, pDoc->m_ctlList_cols, g_Res_PgmInfo.m_screen_file ) ;
}
//-----------------------CCheckResult::Restore_Setting--------------- void CCheckResult::Restore_Setting( CString pc_section ) {
CString lc_tempstr; CResMarketSmryDoc* pDoc =(CResMarketSmryDoc *) GetDocument(); lc_tempstr.Format( "%s", pDoc->m_classname ) ;
g_Res_Utils.LoadWindowXY((CWnd*) GetParentFrame(),pc_section, (char *)(LPCTSTR)lc_tempstr, g_Res_PgmInfo.m_screen_file ) ; g_Res_Utils.LoadListCtrlColWidth( &m_list, pc_section, (char *)(LPCTSTR)lc_tempstr, pDoc->m_ctlList_cols, g_Res_PgmInfo.m_screen_file ) ;
}
//---------------CResTransactionLog::OnContextMenu--------------- void CCheckResult::OnContextMenu(CWnd*, CPoint point) {
if (point.x == -1 && point.y == -1) { //keystroke invocation CRect rect; GetClientRect(rect); ClientToScreen(rect); point = rect.TopLeft(); point.Offset(5, 5); }
CMenu menu; VERIFY(menu.LoadMenu(IDR_POPUP_CHECKRESULT));
CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); CWnd* pWndPopupOwner = this;
CNgxtsApp *thisapp = ( CNgxtsApp* )AfxGetApp() ;< | | | | | |