1,076
社区成员
发帖
与我相关
我的任务
分享
我在pb程序中的测试代码: Function integer SndMsg(long hWnd, long uMsg, long wp, & ref string filename) library "user32.dll" Alias For "SendMessageA" long ll_dw_handle ll_dw_handle = handle(dw_1) string s s="c:\111.txt" SndMsg(ll_dw_handle, 1305, 2, s) 如果要编写一个数据窗口外挂程序,只要得到数据窗口的句柄就可以了,我就点到这里为止了。
例子如下 这里当然指一个程序读取另一个程序中数据窗口的数据。设想的方法有多种,简单的方法是向数据窗口传递消息啦!先看看这个: How to manipulate Datawindow without using datawindow functions. // I test only on PowerBuilder 6.5 build 444 long ll_dw_handle ll_dw_handle = handle(dw_1) Function Power Script Retrieve Post(ll_dw_handle, 1306, 0, 0) Post(ll_dw_handle, 1320, 0, 0) ScrollNextPage Post(ll_dw_handle, 1318, 0, 0) ScrollPriorPage Post(ll_dw_handle, 1319, 0, 0) ScrollToFirstPage Post(ll_dw_handle, 1315, 0, 1) // 1 = first row? ScrollToLastPage Post(ll_dw_handle, 1315, 0, 99999999) // 99999999 = last page ? pb6 programmer don't know how to get the last page :) Sort Dialog Post(ll_dw_handle, 1309, 0, 0) Filter Dialog Post(ll_dw_handle, 1311, 0, 0) DeleteRow Post(ll_dw_handle, 1357, 0, 0) Post(ll_dw_handle, 1307, 0, 0) Append Row Post(ll_dw_handle, 1357, 0, 0) Post(ll_dw_handle, 1312, 0, 0) Post(ll_dw_handle, 1315, 0, dw_1.rowcount() + 1) Post(ll_dw_handle, 1325, 0, 0) InsertRow Post(ll_dw_handle, 1357, 0, 0) Post(ll_dw_handle, 1313, 0, 0) Post(ll_dw_handle, 1312, 0, dw_1.getrow()) Post(ll_dw_handle, 1315, 0, dw_1.getrow()) Post(ll_dw_handle, 1325, 0, 0) Update Post(ll_dw_handle, 1357, 0, 0) Post(ll_dw_handle, 1338, 0, 0) Post(ll_dw_handle, 1304, 0, 0) SaveAs Dialog Post(ll_dw_handle, 1338, 0, 0) Post(ll_dw_handle, 1305, 0, 0) Print Post(ll_dw_handle, 1303, 0, 0) Retrieve (yield) Post(ll_dw_handle, 1306, 1, 0) Post(ll_dw_handle, 1320, 0, 0) Cancel Post(ll_dw_handle, 1320, 0, 0) 通过测试发现使用Post(ll_dw_handle, 1305, 0, 0) ,可以使数据窗口弹出saveas的对话框,经过进一步的试验,发现wparam和lparam参数的含义分别是 :saveas type和 savefilename字符串的地址,所以我们就可以使用发送消息的方式使数据窗口内容保存为文本文件,然后读取文件就可以获取数据了。 我在pb程序中的测试代码: Function integer SndMsg(long hWnd, long uMsg, long wp, & ref string filename) library "user32.dll" Alias For "SendMessageA" long ll_dw_handle ll_dw_handle = handle(dw_1) string s s="c:\111.txt" SndMsg(ll_dw_handle, 1305, 2, s) 如果要编写一个数据窗口外挂程序,只要得到数据窗口的句柄就可以了,我就点到这里为止了。
long ll_dw_handle ll_dw_handle = handle(dw_1) string s s="c:\111.txt" SndMsg(ll_dw_handle, 1305, 2, s) 如果要编写一个数据窗口外挂程序,只要得到数据窗口的句柄就可以了,我就点到这里为止了。
我的想法是這樣的: 第一個PB程序抓第二個PB程序中的窗口控件屬性和數據窗口的數據。然後存到數據庫,第三個PB程序中就從數據庫抓數據再重新構造出來。 舉個列子:第一個程序相當於一個照相機,第二個程序就是目標,第三個程序相當於打印機。 請問有什麼辦法可以做到? 我現在通過GetWindow,GetWindowText 兩個API 函數 已經把運行中的所有窗口的標題都抓出來了,但是我只想把PB的程序的標題顯示出來,請問要怎麼過濾法?有沒有可以判斷窗口類型的API函數,還有怎麼通過窗口的句柄去取窗口裡面的信息? 求高手幫忙~