MFC clist 学习设计 - 杀死比特
2016-1-9 21:18:0 Author: www.cnblogs.com(查看原文) 阅读量:5 收藏

最近想设计一款WEBSHELL的综合破解工具。

然后设计到了日志输出那儿,因为MFC不熟悉,刚学。所以一直在想用edit控件好还是clist比较好。

今天设计了一下日志输出界面,然后记录一下学习笔记。

void CshellDlg::panted()
{
    m_list.SetExtendedStyle(LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT); //插入列表
    m_list.InsertColumn(0,L"Host",0,150);
    m_list.InsertColumn(1,L"Path",0,150);
    m_list.InsertColumn(2,L"Line",0,80);
    m_list.InsertColumn(3,L"Password",0,120);
    m_list.InsertColumn(4,L"Procotol",0,50);
}

void CshellDlg::OnNMRClickList1(NMHDR *pNMHDR, LRESULT *pResult) //右键弹出菜单
{
    LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
    // TODO: Add your control notification handler code here
    CMenu    popup;
    popup.LoadMenu(IDR_MENU1);
    CMenu*    pM = popup.GetSubMenu(0);
    CPoint    p;
    GetCursorPos(&p);
    int    count = pM->GetMenuItemCount();
//    if (m_list.GetSelectedCount() == 0)       //如果没有选中
//    { 
        for (int i = 0; i < count; i++)
        {
            pM->EnableMenuItem(i,   MF_DISABLED | MF_GRAYED);          //菜单全部变灰
        }

//    }
    pM->TrackPopupMenu(TPM_LEFTALIGN, p.x, p.y, this);

    *pResult = 0;
}


void CshellDlg::OnInsertInsert()
{
    // TODO: Add your command handler code here
    HANDLE m_hTrd;
    m_hTrd = CreateThread(NULL, 0, Thread1, this, 0, NULL);
    if (m_hTrd == NULL)
    {
        AfxMessageBox(L"create thread error");
    }

}

DWORD WINAPI CshellDlg::Thread1(LPVOID lpParam)
{
    CshellDlg* shell = (CshellDlg*)lpParam;
    TCHAR Filesize[11];
    for (int i =0;i<10000;i++)
    {
        //循环插入数据
        swprintf(Filesize,L"%d",i);
        int idx = shell->m_list.InsertItem(shell->m_list.GetItemCount(),L"Hello word");
        shell->m_list.SetItemText(idx,0,L"192.168.1.1");
        shell->m_list.SetItemText(idx,1,L"/owa.aspx");
        shell->m_list.SetItemText(idx,2,Filesize);
        shell->m_list.SetItemText(idx,3,L"123456");
        shell->m_list.SetItemText(idx,4,L"http");
        //    Sleep(100);
    }
    return 0;
}


void CshellDlg::OnInsertCleart()
{
    m_list.DeleteAllItems(); //删除所有条目
    // TODO: Add your command handler code here
}


void CshellDlg::OnInsertDeletethis()
{
    //wchar_t buffer[MAX_PATH] = {0};
    int iselect = m_list.GetSelectionMark(); //获取光标输在位置
//    m_list.GetItemText(iselect,0,buffer,MAX_PATH); //获取条目信息
    m_list.DeleteItem(iselect); //删除光标所在的行
}
public:
    void panted();
    CListCtrl m_list;
    afx_msg void OnNMRClickList1(NMHDR *pNMHDR, LRESULT *pResult);
    afx_msg void OnInsertInsert();
    afx_msg void OnInsertCleart();
    afx_msg void OnInsertDeletethis();


文章来源: https://www.cnblogs.com/killbit/p/5117308.html
如有侵权请联系:admin#unsafe.sh