本文整理汇总了C++中CHeaderCtrl::SetImageList方法的典型用法代码示例。如果您正苦于以下问题:C++ CHeaderCtrl::SetImageList方法的具体用法?C++ CHeaderCtrl::SetImageList怎么用?C++ CHeaderCtrl::SetImageList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHeaderCtrl
的用法示例。
在下文中一共展示了CHeaderCtrl::SetImageList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnInitDialog
// CFileOpenDlg::OnInitDialog
//
// Initialize the dialog
//
BOOL CFileOpenDlg::OnInitDialog()
{
CWinApp* pApp = AfxGetApp();
HTREEITEM hItemRoot;
HIMAGELIST hImlSys;
SHFILEINFO ssfi;
CWaitCursor wait;
TCHAR szRoot[] = _T("\\");
CExDialog::OnInitDialog();
//
// Create the toolbar
//
if(!m_wndCommandBar.Create(this) ||
!m_wndCommandBar.InsertMenuBar(IDR_MAINFRAME) ||
!m_wndCommandBar.AddAdornments() ||
!m_wndCommandBar.LoadToolBar(IDR_FILEOPEN))
{
TRACE0("Failed to create CommandBar\n");
return -1; // fail to create
}
//m_pCmdBar = (CCommandBar*)m_pWndEmptyCB;
//m_pCmdBar->LoadToolBar(IDR_FILEOPEN);
//
// Position the tree.
//
GetClientRect(&m_rcTree);
m_rcTree.top = GetHeaderHeight() + 1;
m_rcTree.bottom = m_ySplit;
m_treeFolder.MoveWindow(&m_rcTree);
//
// Position the list
//
GetClientRect(&m_rcList);
m_rcList.top = m_ySplit + nTrackHeight + 1;
m_listFile.MoveWindow(&m_rcList);
//
// Hide the OK button
//
ModifyStyle(0, WS_NONAVDONEBUTTON, SWP_NOSIZE);
//::SHDoneButton(m_hWnd, SHDB_HIDE);
//
// Retrieve the small system image list
//
hImlSys = (HIMAGELIST)SHGetFileInfo(_T("dummy.txt"), 0, &ssfi,
sizeof(SHFILEINFO),
SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
m_imlSystem.Attach(hImlSys);
m_listFile.SetImageList(&m_imlSystem, LVSIL_SMALL);
m_treeFolder.SetImageList(&m_imlSystem, TVSIL_NORMAL);
m_imlSystem.Detach();
//
// Initialize the tree
//
hItemRoot = TVI_ROOT;//m_treeFolder.InsertItem(GetSystemName(), 0, 1);
if(hItemRoot)
{
TVINSERTSTRUCT tvi;
int iIcon = GetIconIndex(szRoot);
tvi.hParent = TVI_ROOT;
tvi.hInsertAfter = TVI_LAST;
tvi.item.mask = TVIF_CHILDREN | TVIF_IMAGE | TVIF_SELECTEDIMAGE |
TVIF_TEXT | TVIF_PARAM;
tvi.item.pszText = szRoot;
tvi.item.iImage = iIcon;
tvi.item.iSelectedImage = iIcon;
tvi.item.cChildren = I_CHILDRENCALLBACK;
tvi.item.lParam = -1;
m_treeFolder.InsertItem(&tvi);
//m_treeFolder.SetItemData(hItemRoot, 0);
//EnumDirs(_T("\\"), _T("*"), hItemRoot);
//m_treeFolder.Expand(hItemRoot, TVE_EXPAND);
}
//
// Initialize the list
//
m_listFile.InsertColumn(0, _T("Name"), LVCFMT_LEFT, 80, -1);
m_listFile.InsertColumn(1, _T("Size"), LVCFMT_RIGHT, 60, 1);
m_listFile.InsertColumn(2, _T("Date"), LVCFMT_LEFT, 60, 2);
EnumFiles(szRoot, m_strFilter);
//.........这里部分代码省略.........
示例2: OnInitialUpdate
void CTxMsgListView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
// Initialise window pointer in the Tx child window
CTxMsgChildFrame* pomChildFrame =
(CTxMsgChildFrame* )pomGetParentWindow();
// Update View Pointer
if( pomChildFrame != nullptr )
{
pomChildFrame->vSetTxMsgViewPointers( eTxMsgMessageListView, this );
}
// set Init flag to TRUE
m_bInitDlg = TRUE;
// Init Message List Control
CRect rListCtrlRect;
CHAR caColumnName[defMESSAGE_FRAME_COLUMN][defSTRING_SIZE] =
{
defMESSAGE_ID,
defSTR_CHANNEL_NAME,
defMESSAGE_TYPE,
defMESSSAGE_DLC,
defMESSAGE_DATA_BYTES
};
//Calculate the total size of all column header
m_omLctrMsgList.GetWindowRect( &rListCtrlRect);
int nTotalColunmSize = rListCtrlRect.right - rListCtrlRect.left;
int nTotalStrLengthPixel = 0;
int i; //i declared outside the for loop
for( i=0; i<defMESSAGE_FRAME_COLUMN; i++)
{
nTotalStrLengthPixel +=
m_omLctrMsgList.GetStringWidth(caColumnName[i]) ;
}
//Insert each column name after calculating the size for the same.
INT nFormat = 0;
for(i=0; i<defMESSAGE_FRAME_COLUMN; i++)
{
int nColumnSize = m_omLctrMsgList.GetStringWidth(_(caColumnName[i])) ;
nColumnSize +=
(nTotalColunmSize-nTotalStrLengthPixel)/defMESSAGE_FRAME_COLUMN;
nFormat = LVCFMT_CENTER;
// Switch Column Index
switch( i )
{
case defMESSAGE_FRAME_COLUMN - 1 : // Data Bytes Column
nColumnSize += static_cast <INT>(4.25*defDATA_BYTES_EXTRA);
nFormat = LVCFMT_LEFT;
break;
case 0: // Message ID / Name Column. Don't alter this column
break;
case 1: // Channels Column
nColumnSize -= static_cast <INT>(2.2*defDATA_BYTES_EXTRA);
break;
default: // Others
nColumnSize -= static_cast <INT>(1.1*defDATA_BYTES_EXTRA );
}
// Insert the column in to the list
m_omLctrMsgList.InsertColumn(i,_(caColumnName[i]),
nFormat, nColumnSize);
}
// Set extended property
// Enable Check box
m_omLctrMsgList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES );
// Associate image list to the list item
// Create only onece
if( m_omImageList.m_hImageList == nullptr )
{
m_omImageList.Create( IDR_BMP_MSGSGDB,
defSIGNAL_ICON_SIZE,
1,
WHITE_COLOR );
}
// Set the Image List
// Only if it is sucessfully created
if( m_omImageList.m_hImageList != nullptr )
{
m_omLctrMsgList.SetImageList( &m_omImageList, LVSIL_SMALL);
}
// Associate Header control Image List
if( m_omHeaderImageList.m_hImageList == nullptr )
{
m_omHeaderImageList.Create( IDR_BMP_CHECKBOX,
defSIGNAL_ICON_SIZE,
1,
BLUE_COLOR );
}
// Set the Image List
// Only if it is sucessfully created
if( m_omHeaderImageList.m_hImageList != nullptr )
{
CHeaderCtrl* pHeader = m_omLctrMsgList.GetHeaderCtrl();
if( pHeader != nullptr )
{
pHeader->SetImageList( &m_omHeaderImageList );
HDITEM hditem;
hditem.mask = HDI_IMAGE | HDI_FORMAT;
if( pHeader->GetItem(0, &hditem ) == TRUE )
//.........这里部分代码省略.........