zoukankan      html  css  js  c++  java
  • c++用CreateWindow画listview

        RECT rcl;  //画listview位置

        CWindow myWindow;

        HWND hWndParent = m_hWnd;//本窗口句柄

        HINSTANCE  HInstance = GetModuleHandle(0);//当前exe实例

        myWindow.Attach(hWndParent);

        myWindow.GetClientRect(&rcl);可以将下面的数字变成rcl对应的x,y,宽,高   

        hWndListViewB =CreateWindow(WC_LISTVIEW,"",WS_CHILD|LVS_REPORT|LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP| LVS_SHOWSELALWAYS|WS_VISIBLE,

                          30,100,180,150,       

    //listview的位置及宽、高。可以替换为RECT rcl对应的x,y,宽,高                

           hWndParent,//listview所在窗口句柄

           NULL,HInstance,NULL); 

     

        if(hWndListViewB == NULL) 

        { 

           //return NULL; 

        }      

      //ShowWindow(SW_SHOWNORMAL);//hWndListView,这个用了LISTVEIW不显示,改成上面加WS_VISIBLE就好了

        //UpdateWindow();   // hWndListView

       //以下为设置listview显示方式

        CListCtrl* pListCtrlB= (CListCtrl*)FromHandle(hWndListViewB); //由句柄得到对话框的对象指针

        CListView* pCListView= (CListView*)FromHandle(hWndListViewB);

        CListCtrl& BeginList = pCListView->GetListCtrl();

        long lStyle;

        lStyle=GetWindowLong(BeginList.m_hWnd,GWL_STYLE);

        lStyle &=~LVS_TYPEMASK;

        lStyle |=LVS_REPORT;

        SetWindowLong(BeginList.m_hWnd,GWL_STYLE,lStyle);

     

        DWORD  styleex =pListCtrlB->GetExtendedStyle();

        styleex |= LVS_EX_FULLROWSELECT; //选中某行使整行高亮(只适用于报表风格的listctrl)

        styleex |= LVS_EX_GRIDLINES; //网格线(只适用与报表风格的listctrl)

        styleex |=LVS_SORTASCENDING;

        pListCtrlB->SetExtendedStyle(styleex); //设置扩展风格

        pListCtrlB->SetBkColor(RGB(200, 200, 200));

        pListCtrlB->SetTextBkColor(RGB(200, 200, 200));

        pListCtrlB->SetTextColor(RGB(10, 10, 80));

     

        // listview插入列

        TRY

        {

           pListCtrlB->InsertColumn(0, _T("管理员ID"), LVCFMT_LEFT, 90);

           pListCtrlB->InsertColumn(1, _T("管理员名称"), LVCFMT_LEFT, 90);

     

          

        }

        CATCH (CMemoryException, e)

        {

          

        }

        END_CATCH

  • 相关阅读:
    【网络流24题----15】汽车加油行驶问题
    【网络流24题】最小路径覆盖问题
    网络流二·最大流最小割定理
    贪吃蛇
    【SCOI2008】着色方案
    DARK的锁链
    【NOIP2014】飞扬的小鸟
    [NOIP2012] 借教室
    [NOIP2012] 开车旅行
    [NOIP2012] 国王游戏
  • 原文地址:https://www.cnblogs.com/wangyuanf/p/3030013.html
Copyright © 2011-2022 走看看