永发信息网

vb,向指定的子窗口发送消息,没反应~~

答案:2  悬赏:40  手机版
解决时间 2021-02-27 13:31
  • 提问者网友:风月客
  • 2021-02-26 19:15
PostMessage 120728, WM_KEYDOWN, 13, 0
Sleep 100
PostMessage 120728, WM_KEYUP, 13, 0
句柄我用spy++获取的,就是没反应,请教是怎么回事啊???360已退出···
子窗口是我自己用vb生成的按钮,无特殊性~

不好意思,我自己把单击理解成enter了,可以问一下vb中怎么获取磁盘信息吗?比如C盘:磁盘0分区1,先谢谢了~
最佳答案
  • 五星知识达人网友:痴妹与他
  • 2021-02-26 19:43
你发按键消息的时候,子窗口的按钮是否有默认焦点,或者检查子窗体的keyPreview属性是否为true
全部回答
  • 1楼网友:鱼忧
  • 2021-02-26 20:32
'这个程序运行的效果是,单击一下窗体,变成无标题栏,再次单击,又变有标题栏。 '刚才试验过,把me.hwnd改成windows计算器的句柄,就可以随意改变计算器的窗体类型 '设置窗体结构信息函数 private declare function setwindowlong lib "user32" alias "setwindowlonga" (byval hwnd as long, byval nindex as long, byval dwnewlong as long) as long '获取窗体结构信息函数 private declare function getwindowlong lib "user32" alias "getwindowlonga" (byval hwnd as long, byval nindex as long) as long private const gwl_style = (-16) private const ws_sysmenu = &h80000 private const ws_caption = &hc00000 private const ws_sizebox = &h40000 private const ws_maximizebox = &h10000 private const ws_minimizebox = &h20000 '为窗体指定一个新位置和状态函数 private declare function setwindowpos lib "user32" (byval hwnd as long, byval hwndinsertafter as long, byval x as long, byval y as long, byval cx as long, byval cy as long, byval wflags as long) as long private const swp_nozorder = &h4 private const swp_framechanged = &h20 private const swp_noreposition = &h200 '获得整个窗体的大小和位置 private declare function getwindowrect lib "user32" (byval hwnd as long, lprect as rect) as long private type rect left as long top as long right as long bottom as long end type private change as boolean private sub form_click() dim lstyle as long dim myrect as rect '获取窗体的大小和位置 getwindowrect me.hwnd, myrect '取得当前窗体信息 lstyle = getwindowlong(me.hwnd, gwl_style) if change then '分别使系统菜单(包括图标)、标题、大小、最大化、最小化显示/有效 lstyle = lstyle or ws_sysmenu lstyle = lstyle or ws_caption lstyle = lstyle or ws_sizebox lstyle = lstyle or ws_maximizebox lstyle = lstyle or ws_minimizebox else '分别使系统菜单(包括图标)、标题、大小、最大化、最小化隐藏/无效 lstyle = lstyle and not ws_sysmenu lstyle = lstyle and not ws_caption lstyle = lstyle and not ws_sizebox lstyle = lstyle and not ws_maximizebox lstyle = lstyle and not ws_minimizebox end if '按lstyle的值设置窗体信息 setwindowlong me.hwnd, gwl_style, lstyle '保持窗体的大小与位置不变 setwindowpos me.hwnd, 0, myrect.left, myrect.top, myrect.right - myrect.left, myrect.bottom - myrect.top, swp_noreposition or swp_nozorder or swp_framechanged '改变显示/隐藏状态 change = not change end sub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯