|
说一下要点,
因为ComboBox是没有下拉按钮的,当鼠标点击右边下拉三角形的位置,系统就会自动弹出
下拉列表,这里有一个小窍门。注册combobox 左键弹起,然后在事件中模拟左键按下消息,
注意参数是 下拉按钮的坐标,这样就刚好可以实现了!和酷狗歌曲搜索框是一样的,大家可以
实验一下
具体可以查看炫彩编程助手 e69 这个例子
- .版本 2
- .程序集 程序集1
- .程序集变量 hComboBox, 整数型
- .子程序 _启动子程序, 整数型, , 请在本子程序中放置易模块初始化代码
- 第十四课ComboBox ()
- _临时子程序 () ' 在初始化代码执行完毕后调用测试代码
- 返回 (0) ' 可以根据您的需要返回任意数值
- .子程序 _临时子程序
- .子程序 第十四课ComboBox
- .局部变量 hWindow, 整数型
- .局部变量 hAdapter, 整数型
- .局部变量 txt, 字节集
- ' 初始化炫彩资源
- XInitXCGUI ({ })
- ' 创建窗口并且显示
- hWindow = XWnd_Create (0, 0, 500, 300, L (“dasemimi”), 0, #xc_window_style_default)
- hComboBox = XComboBox_Create (10, 30, 100, 50, hWindow)
- XComboBox_SetItemTemplateXML (hComboBox, L (“XML-template\ComboBox_ListBox_Item.xml”))
- hAdapter = XAdapterTable_Create ()
- XComboBox_BindApapter (hComboBox, hAdapter)
- XAdapterTable_AddColumn (hAdapter, L (“name”))
- ' 和酷狗一样,注册鼠标弹起时候,自动弹出下拉列表
- XEle_RegEventC (hComboBox, #XE_LBUTTONUP, 到整数 (&OnLButtonDown))
- XAdapterTable_AddItemText (hAdapter, L (“dasemimi”))
- XAdapterTable_AddItemText (hAdapter, L (“xcgui”))
- ' XEle_RegEventC (hComboBox, #XE_COMBOBOX_SELECT, 到整数 (&OnComboBoxSelect))
- XWnd_ShowWindow (hWindow, 5)
- XRunXCGUI () ' 内部消息处理等等
- XExitXCGUI () ' 释放资源
- .子程序 OnLButtonDown, 整数型, , int CALLBACK OnLButtonDown(UINT nFlags, POINT *pPt,BOOL *pbHandled);
- .参数 nFlags, 整数型
- .参数 pPt, 整数型
- .参数 pbHandled, 逻辑型, 参考
- .局部变量 rt, RECT
- .局部变量 pt, POINT
- XComboBox_GetButtonRect (hComboBox, rt)
- pt.x = rt.left + 1
- pt.y = rt.top + 1
- XEle_SendEvent (hComboBox, hComboBox, #XE_LBUTTONDOWN, 0, 取指针_Point (pt))
- 返回 (0)
- .子程序 OnComboBoxSelect, 整数型
- .参数 iItem, 整数型
- .参数 bHandled, 逻辑型, 参考
- .局部变量 pbHandled, 整数型
- 返回 (0)
- .子程序 取指针_Point, 整数型, 公开, 取变量数据地址 这个和文本的是一样的
- .参数 var, POINT, 参考, 这里取类的。。。。
- 置入代码 ({ 139, 69, 8, 139, 0, 201, 194, 4, 0 })
- ' mov eax,[ebp+8]
- ' mov eax,[eax]
- ' leave
- ' ret 4
- 返回 (0) ' 本源码来自易语言资源网(www.5A5X.com)
复制代码
|
|