Function Long FindWindowA(uLong lpClassName,ref string lpWindowName) Library "user32"
************************************************************************************
功能:根據窗口標題查找窗口
示例:
ulong l_handle
string ls_wname
ls_wname="<窗口標題>"//如,無標題---記事本
l_handle=FindWindowA(0,ls_wname)
*******************************************************example 1
Function Long PostMessage(Long hwnd,Long wMsg,Long wParam,Long lParam) Library "user32" Alias for "PostMessageA"
功能:向創建指定窗口的線索發送一條消息,便不等待線索處理該消息
示例:
ulong l_handle
boolean rtn
l_handle=handle(w_main)
//61472=最小化窗口; 61488=最大化窗口 61728=正常窗口
rtn=PostMessageA(l_handle,274,61472,0)
////////////////////////////////////////////////////////////////////////////////////////////example 2
For applications on Windows, the Handle function does not return a useful value when the previous flag is TRUE. You can use the FindWindowA Windows function to determine whether a Windows application is already running.
Declare FindWindowA as a global external function:
FUNCTION uint FindWindowA (long classname, &
string windowname) LIBRARY "user32.dll"
Then add code like the following to your application's open event:
uint val
val = FindWindowA(0, "MyApp Main Window")
IF val > 0 THEN
MessageBox("Application already running", &
"MyApp is already running. You cannot &
start it again")
HALT CLOSE
ELSE
open(w_main)
END IF
Handle = FindWindowA(nul,wtitle)
SetParent(handle,Handle(w_main))
//使Run程序窗口成爲PB主程序的子窗口
/////////////////////////////////////////////////////////////////////////////////example 3
Long WM_CLOSE,hwnd,Mval
WM_CLOSE=16
hwnd=FindWindowA(0,cTitle)
if hwnd=0 then
messagebox("系統提示","沒有打開該應用程序!")
else
Mval=PostMessage(hwnd,WM_CLOSE,0,0)
end if