国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

PB中消息對話框的居中顯示

2024-07-21 02:10:20
字體:
來源:轉載
供稿:網友
pb中消息對話框的居中顯示
上海大學 孫淵磊

sharedobject系列函數和共享對象有關的函數包括:sharedobjectregister、sharedobjectget、sharedobjectunregister和sharedobjectdirectory函數。首先,用sharedobjectregister函數初始化共享對象,并建立一個單獨的線程。如:sharedobjectregister (“ccuo_thread” ,“thread1” )其中ccuo_thread是一個共享的自定義類用戶對象的類名,thread1是共享對象實例的共享名。如果sharedobjectregister函數返回success,則新線程創建成功。然后,執行指定代碼。有兩種方法讓新線程執行指定的代碼:一種是在自定義類用戶對象的constructor事件中編寫腳本,新線程創建后就會自動執行該事件腳本;另一種方法是使用sharedobjectget函數。該函數實現共享對象實例的引用,如:sharedobjectget ( “thread1” ,inv_thread ) 其中inv_thread是用來存儲共享對象實例的一個對象變量,要求與ccuo_thread具有同一個類名。最后,通過使用post語句,即以inv_thread.post of_function(agrs)的形式,異步調用共享對象的函數of_function。在完成任務后,可以用sharedobjectunregister函數中止線程,也可用sharedobjectdirectory函數列出所有有效的共享對象。函數調用部分本文所用win32 api函數原型為:function ulong findwindowa ( string lpclassname ,string lpwindowname ) library “user32.dll”function ulong gettickcount ( ) library “kernel32.dll” function ulong getdesktopwindow ( ) library “user32.dll” function boolean getwindowrect ( ulong hwnd ,ref stc_rect lprect ) library “user32.dll”function boolean movewindow ( ulong hwnd ,int x ,int y ,int nwidth ,int nheight ,boolean brepaint ) library “user32.dll” 下面具體討論如何實現消息對話框的居中顯示://聲明對象變量ccuo_thread lccuo_thread //創建新線程sharedobjectregister (‘ccuo_thread’ ,‘thread_center’ )//引用實例sharedobjectget (‘thread_center’ ,lccuo_thread ) //調用窗口居中函數lccuo_thread.post of_center (‘#32770’ ,‘demostration’ ,2000 ) //創建消息對話框messagebox ( ‘demostration’ ,‘copyright(c) 2001 by y.l.sun’ ) //中止線程sharedobjectunregister ( ‘thread_center’ ) 函數實現部分實現窗口居中顯示的函數是自定義類用戶對象ccuo_thread的對象函數of_center,其實現代碼如下:ccuo_thread.of_center ( string lpclassname ,string lpwindowname , ulong dwtimeout ) return boolean//lpclassname: 消息對話框的類名(#32770)//lpwindowname: 消息對話框的標題//dwtimeout: 超時計數ulong lul_hwnd //存放消息對話框的句柄ulong lul_start //計時開始時刻的值lul_start = gettickcount ( ) //計時開始do//查找頂層窗口lul_hwnd=findwindowa ( lpclassname ,lpwindowname )//找到頂層窗口后,跳出循環if lul_hwnd <> 0 then exit//判斷是否已超時loop while gettickcount( )-lul_start< dwtimeout //沒有找到消息對話框if lul_hwnd = 0 then return false else//對話框居中return of_center ( 0 ,lul_hwnd ) end ifof_center的重載函數代碼如下:ccuo_thread.of_center ( ulong hwndp ,ulong hwndc ) return boolean//hwndp:父窗口的句柄,值為0時認為是桌面//hwndc:子窗口的句柄 int li_x //窗口的x坐標int li_y //窗口的y坐標stc_rect lstc_parent //父窗口的4邊坐標stc_rect lstc_child //子窗口的4邊坐標//值為0時認為是桌面if hwndp = 0 then hwndparent = getdesktopwindow ( ) //獲得窗口的4邊坐標if not getwindowrect ( hwndcurrent ,lstc_child ) then return false if not getwindowrect ( hwndparent ,lstc_parent ) then return falseli_x = (( lstc_parent.right - lstc_parent.left ) - ( lstc_child.right -lstc_child.left )) /2li_y = (( lstc_parent.bottom - lstc_parent.top ) - ( lstc_child.bottom -lstc_child.top )) /2//計算子窗口的x、y坐標if li_x < 0 or li_y < 0 then return false //移動子窗口if not movewindow ( hwndcurrent ,li_x ,li_y ,lstc_child.right -lstc_child.left ,lstc_child.bottom - lstc_child.top ,false ) then return false return true本文代碼在pb 7.0下通過。國內最大的酷站演示中心!
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 嘉义市| 且末县| 阜城县| 临夏县| 大邑县| 吉木乃县| 清水县| 麦盖提县| 萨迦县| 武义县| 延长县| 石渠县| 南和县| 金溪县| 建宁县| 朝阳县| 绥中县| 华蓥市| 双江| 宣汉县| 武宁县| 太仆寺旗| 平利县| 股票| 安乡县| 泾源县| 汶上县| 海淀区| 卢湾区| 长沙县| 保山市| 姚安县| 商河县| 原阳县| 上林县| 华安县| 旺苍县| 台北市| 陈巴尔虎旗| 江川县| 宾川县|