| 发表于:2007-04-11 23:15:39 楼主 |
我新建一个文件名为 "new "的文本文件,在后台或者最小化时,用如下函数到前台怎么没用啊? option explicit private declare function switchtothiswindow lib "user32.dll " (byval hwnd as long, byval brestore as boolean) private declare function findwindow lib "user32 " alias "findwindowa " (byval lpclassname as string, byval lpwindowname as string) as long private declare function getforegroundwindow lib "user32 " () as long private declare function setfocusapi& lib "user32 " alias "setfocus " (byval hwnd as long) private declare function bringwindowtotop lib "user32 " (byval hwnd as long) as long private declare function setactivewindow lib "user32 " (byval hwnd as long) as long private declare sub sleep lib "kernel32 " (byval dwmilliseconds as long) private declare function setforegroundwindow lib "user32 " (byval hwnd as long) as long private const em_setpasswordchar = &hcc private const hwnd_topmost& = -1 private const swp_nosize& = &h1 private const swp_nomove& = &h2 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 sub command1_click() dim hdl as long dim b hdl = findwindow( "notepad ", "new ") 'vbnullstring #32770 'setwindowpos hdl, hwnd_topmost, 0, 0, 0, 0, swp_nomove or swp_nosize 'b = switchtothiswindow(hdl, true) 'setfocusapi (hdl) 'setactivewindow (hdl) 'appactivate "new " ' bringwindowtotop (hdl) setforegroundwindow (hdl) end sub 以上函数我都试过了,为什么窗口就是不到前台呢? |
|
|
|
|