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

  • 相关阅读:
    MySQL锁之一:锁详解
    eclipse maven plugin 插件 安装 和 配置
    火星坐标系统
    使用Spring MVC统一异常处理实战
    websocket之二:WebSocket编程入门
    spring mvc 异常统一处理方式
    Android面向HTTP协议发送post请求
    用JAX-WS在Tomcat中公布WebService
    css3 -> 多栏布局
    NSLayoutConstraint-代码实现自己主动布局的函数使用方法说明
  • 原文地址:https://www.cnblogs.com/wangyuanf/p/3030013.html
Copyright © 2011-2022 走看看