zoukankan      html  css  js  c++  java
  • Combo Box的简单使用(Win32)

    1 SendMessage函数向窗口发送消息

    LRESULT SendMessage(

      HWND hWnd,     // handle to destination window

      UINT Msg,      // message

      WPARAM wParam, // first message parameter

      LPARAM lParam   // second message parameter

    );

    Combo Box添加数据

    HWND hWndComboBox = GetDlgItem(hWnd, IDC_COMBO1);

    TCHAR szMessage[20] = "Hello";

    SendMessage(hWndComboBox , CB_ADDRSTRING, 0, (LPARAM)szMessage);

    Combo Box插入数据

    HWND hWndComboBox = GetDlgItem(hWnd, IDC_COMBO1);

    TCHAR szMessage[20] = "World";

    SendMessage(hWndComboBox , CB_INSERTRSTRING, 0, (LPARAM)szMessage);

    Combo Box删除数据

    SendMessage(hWndComboBox, CB_DELETESTRING, 1, 0);    //删除第二项数据

    清除Combo Box所有数据

    SendMessage(hWndComboBox, CB_RESETCONTENT, 0, 0);

    获取Combo Box数据项目的数量

    UINT uCount;

    uCount = SendMessage(hWndComboBox, CB_GETCOUNT, 0, 0):

    获取Combo Box某项的值

    TCHAR szMessage[200];

    ZeroMessage(szMessage, sizeof(szMessage)):

    SendMessage(hWndComboBox, CB_GETLBTEXT, 1, (LPARAM)szMessage);    //获取第二项的数据

    MessageBox(NULL, szMessage, " ", MB_OK);

    -----------------

    SendMessage(hWndcombo,CB_ADDSTRING,0,(LPARAM)"网通一区");//先用这个添加一条,然后再用下面的指定位置插入
    SendMessage(hWndcombo,CB_INSERTSTRING,1,(LPARAM)"电信一区");
    SendMessage(hWndcombo,CB_INSERTSTRING,2,(LPARAM)"电信二区");
    SendMessage(hWndcombo,CB_SETCURSEL, 0, 0);//设置默认值

  • 相关阅读:
    IfcFurnishingElementType
    IfcRelAssociatesClassification
    IfcRelAssociatesDocument
    IfcContext
    IfcRelAssociatesMaterial
    我是高敏感的人,你呢?
    介绍一本红色的书
    矫枉必须过正
    大家都在说的民法典,与我有何关系?
    线上Kafka突发rebalance异常,如何快速解决?
  • 原文地址:https://www.cnblogs.com/wumac/p/4101840.html
Copyright © 2011-2022 走看看