z7142637
z7142637
2019-04-01 16:26

关于MFC 基于对话框分割,左边显示CLISTVIEW,右边显示CVIEW的问题。

10
  • c++

使用静态分割以后,左边显示CLISTVIEW,结果LISTVIEW 表头没了,显示不出来。

图片说明

int CMFCAppDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CDialogEx::OnCreate(lpCreateStruct) == -1)
        return -1;
    CString CFrameText = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW,
        ::LoadCursor(NULL, IDC_ARROW), (HBRUSH) ::GetStockObject(WHITE_BRUSH),
        ::LoadIcon(NULL, IDI_APPLICATION));
    m_pFrameWnd = new CFrameWnd;
    CRect rc;
    GetClientRect(&rc);
    m_pFrameWnd->Create(CFrameText, _T(""),WS_CHILD,CRect(0,0,300,300),this);
    m_pFrameWnd->ShowWindow(SW_SHOW);

    if(!m_Splitter.CreateStatic(m_pFrameWnd, 1, 2))
        return FALSE;
    if (!m_Splitter.CreateView(0, 0, RUNTIME_CLASS(CMyListView), CSize(rc.Width()/4, rc.Height()), NULL))
        return FALSE;
    if (!m_Splitter.CreateView(0, 1, RUNTIME_CLASS(CMyView), CSize(rc.Width() / 4 * 3, rc.Height()), NULL))
        return FALSE;

    //m_pFrameWnd->Create();
    // TODO:  Add your specialized creation code here

    return 0;
}
//CLISTVIEW设置
void CMyListView::OnInitialUpdate()
{
    CListView::OnInitialUpdate();

    CListCtrl  &m_list = GetListCtrl();

    LONG lStyle;

    lStyle = GetWindowLong(m_list.m_hWnd, GWL_STYLE);

    lStyle &= ~LVS_TYPEMASK;

    lStyle |= LVS_REPORT;

    SetWindowLong(m_list.m_hWnd, GWL_STYLE, lStyle);

    DWORD dwStyle = m_list.GetExtendedStyle();

    dwStyle |= LVS_EX_FULLROWSELECT;

    dwStyle |= LVS_EX_GRIDLINES;

    m_list.SetExtendedStyle(dwStyle);

    m_list.SetBkColor(RGB(189, 189, 189));

    m_list.SetTextBkColor(RGB(189, 189, 189));

    m_list.SetTextColor(RGB(128, 0, 255));
    CRect rc;

    GetClientRect(&rc);

    m_list.InsertColumn(1, _T("BitMap"), LVCFMT_CENTER, rc.Width());
    for(int i=0;i<10;i++)
    m_list.InsertItem(i, _T("DDD"));

问题出在哪???

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答