利用sendmessage触发listbox的onselchange消息
By
admin
at 2021-08-22 • 0人收藏 • 749人看过
群里有人问, 怎么用代码触发外部exe中listbox的onselchange消息?
根据他提供的vb中的代码, 那么转换到aardio中应该这样:
vb代码如下:
HiWord& = LBN_SELCHANGE * &H10000 LoWord& = GetDlgCtrlID(tHWND) And &HFFFF& SendMessage hwnd, WM_COMMAND, HiWord Or LoWord, tHWND
转换到aardio后, 使用示例如下:
import win.ui; /*DSG{{*/ var winform = win.form(text="aardio form";right=423;bottom=476) winform.add( button={cls="button";text="Button";left=242;top=382;right=410;bottom=437;z=2}; listbox={cls="listbox";left=25;top=31;right=225;bottom=443;edge=1;items={"1";"2";"3";"4";"5";"6"};z=1} ) /*}}*/ import console console.open() winform.listbox.onSelChange = function(){ console.log("出发了onchange") } winform.button.oncommand = function(id,event){ var mainhwnd = winform.hwnd; var listboxhwnd = winform.listbox.hwnd; var id = win.getId(listboxhwnd); //第一种方式 //::SendMessage(mainhwnd, 0x111/*_WM_COMMAND*/, topointer(::MAKELONG(id,0x1/*_LBN_SELCHANGE*/)),topointer(listboxhwnd)) //第二种方式 ::SendMessageInt(mainhwnd, 0x111/*_WM_COMMAND*/, ::MAKELONG(id,0x1/*_LBN_SELCHANGE*/),listboxhwnd); } winform.show(); win.loopMessage();
触发外部exe中的listbox , 只需要你自己去查找窗口并定位到listbox句柄, 然后用上面的代码即可.
登录后方可回帖