|
楼主 |
发表于 2020-6-14 14:00:02
|
显示全部楼层
这个list control一直会有问题,不知道是不是初始化函数的问题,麻烦看看,谢谢!
BOOL CSetODBCDlg::OnInitDialog()
{
LOAD_DYNSTRINGS(theApp.GetDico());
m_popmenu.LoadMenu(IDR_DIR_PMENU_ODBC_CFG);
theApp.GetDico()->TranslateMenu(&m_popmenu);
CListCtrl *listCtrl = (CListCtrl*)GetDlgItem(IDC_ODBC_BASE_LIST);
// Draw and load control
DrawControl();
listCtrl->SetItemState(0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
//Get defined base in registry
if (DIR_IsODBCDirectoryExist())
{
int nbODBCdir = DIR_GetODBCDirectoryNb();
ODBCBaseDef odbcBaseDef;
for (int i=0;i<nbODBCdir;i++)
{
DIR_GetODBCDirectoryInfo(i, &odbcBaseDef);
AddItem(&odbcBaseDef);
}
}
listCtrl->SendMessage( LVM_SETEXTENDEDLISTVIEWSTYLE,LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);
return FALSE;
}
void CSetODBCDlg::DrawControl()
{
CListCtrl *listCtrl = (CListCtrl*)GetDlgItem(IDC_ODBC_BASE_LIST);
CRect rect;
listCtrl->GetClientRect(&rect);
rect.right -= CXVSCROLL + 1;
// create column
LV_COLUMN lvC;
lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
lvC.fmt = LVCFMT_LEFT;
// Create only one column
lvC.iSubItem = 0;
lvC.pszText = (TCHAR*)_TRANSLATE("SC_ODBC_DIRECTORY_NAME");
lvC.cx = rect.Width()*3/10; // column 1
listCtrl->InsertColumn(0, &lvC);
lvC.iSubItem = 1;
lvC.pszText = (TCHAR*)_TRANSLATE("SC_ODBC_FILE_NAME");
lvC.cx = rect.Width()*11/20; // column 2
listCtrl->InsertColumn(1, &lvC);
lvC.iSubItem = 2;
lvC.pszText = (TCHAR*)_TRANSLATE("SC_ODBC_TABLE_NAME");
lvC.cx = rect.Width()*1/5; // column 3
listCtrl->InsertColumn(2, &lvC);
} |
|