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

首頁 > 開發 > 綜合 > 正文

淺談如何利用PB實現仿QQ自動顯示/隱藏窗口(二)(原創)

2024-07-21 02:10:10
字體:
來源:轉載
供稿:網友

作者:balloonman2002  2004年6月26日

三、自動顯示/隱藏窗口功能實現

1、處理該window的other事件,借助此事件來捕獲wm_mouseleave消息,來獲取并處理鼠標移出事件:

str_rect ls_rect

str_point ls_point,ls_tmp

 

//注:wm_mouseleave消息一旦離開窗口的client區域就會發送,如:當鼠標移至窗口上的控件時也會發送此消息,當鼠標移到窗口的caption或者menu或者border時也會發送此消息,故不能不加任何判斷而直接隱藏窗口,并且此消息只發送一遍,若需繼續跟蹤鼠標,則需再次調用trackmouseevent函數;

if  message.number = wm_mouseleave then

    ib_onform = false

    getcursorpos(ls_point)

   

    getclientrect(handle(this),ls_rect)

    ls_tmp.x = ls_rect.left

    ls_tmp.y = ls_rect.top

    clienttoscreen(handle(this),ls_tmp)

   offsetrect(ls_rect,ls_tmp.x,ls_tmp.y)

   

    //判斷鼠標如果超出客戶區,則自動隱藏窗口

    //只能使用客戶區判斷,不能使用整個窗口rect,否則當鼠標移至border時可能會無法隱藏窗口

    if (ptinrect(ls_rect,ls_point.x,ls_point.y) = 0) and ((this.x <= 0) or (this.y <= 0)) then

        if this.y <= 0 then

           wf_hide_v(this) //首先保證在v方向收縮滑動

        else

           wf_hide_h(this) //其次保證在h方向收縮滑動

        end if

        ib_display = false

    end if

end if

2、處理該window的mousemove事件來處理鼠標移入事件:

if ib_onform = false then

    ib_onform = true

    if ib_display = false then

        if this.y <= 0 then

           wf_display_v(this)

        else

           wf_display_h(this)          

        end if

        ib_display = true

   end if

    wf_capmouse(this)

end if

3、創建該窗口的open事件,以設置該窗口運行的初始位置:

this.backcolor = 16574393

this.title = "自動隱藏窗口示例___雙擊關閉窗口"

this.setposition(topmost!)

 

this.width = p_1.width

this.height = p_1.height

this.x = 100

this.y = -this.height

 

wf_display_v(this)

4、創建相應的窗口函數wf_capmouse以調用鼠標消息捕獲函數:

str_track_mouse str_trm

 

str_trm.nsize = 16

str_trm.hwndtrack = handle(ag_dest)

str_trm.nflags = 2

 

trackmouseevent(str_trm)

5、創建相應的窗口函數wf_display_h以設置窗口如何在水平方向滑動顯示:

integer li_left

str_rect ls_rect1,ls_rect2

str_point ls_tmp

 

getwindowrect(handle(this),ls_rect1)

getclientrect(handle(this),ls_rect2)

 

ls_tmp.x = ls_rect2.left

ls_tmp.y = ls_rect2.top

clienttoscreen(handle(this),ls_tmp)

offsetrect(ls_rect2,ls_tmp.x,ls_tmp.y)

 

li_left = ls_rect2.left - ls_rect1.left //計算出窗口邊框寬度

//計算窗口邊框還可以用getsystemmetrics+sm_cxborder/sm_cyborder/sm_cxframe/sm_cyframe,但是需要判斷窗口狀態是可變邊框還是不可變邊框還是無邊框,因此不如直接采用上述方法

 

do while as_win.x < -15

    as_win.x = as_win.x + 10 //這里的10主要用于控制窗口滑動速度

    if ib_first_display then

        p_1.draw(0,0) //這里主要防止第一次滑動窗口時不顯示圖象

    end if

    sleep(0.01) //這里的sleep函數主要用于控制窗口滑動速度

loop

as_win.x = -3*li_left //這里值不能太小否則,鼠標移到左側時易出邊界

ib_first_display = false

注:用于設置窗口如何在垂直方向滑動顯示的wf_display_v函數不再贅述,修改as_win.y屬性即可。

6、創建相應的窗口函數wf_display_h以設置窗口如何在水平方向滑動隱藏:

do while as_win.x > -as_win.width + 25

    as_win.x = as_win.x - 10

    if ib_first_hide then

        p_1.draw(0,0) //這里主要防止第一次隱藏窗口時不顯示圖象

    end if

    sleep(0.005)

loop

as_win.x = -as_win.width + 10 //這里的10用于控制最后窗口隱藏后留在外側的邊距

ib_first_hide = false

注:用于設置窗口如何在垂直方向滑動顯示的wf_display_v函數不再贅述,修改as_win.y屬性即可。

7、由于該窗口為no titlebar窗口,因此無法拖動,需要專門編寫腳本來實現拖動效果,方法為處理窗口的mousedown事件:

ulong ll_arg

releasecapture() //釋放對mouse消息的捕獲,故在拖動期間不會發生wm_mouseleave事件

ll_arg = 0

sendmessage(handle(this),wm_nclbuttondown,htcaption,ll_arg)

//即發送wm_nclbuttondown消息,模擬用戶拖動titlebar效果

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 普陀区| 佛坪县| 井陉县| 哈巴河县| 砚山县| 南京市| 交城县| 台山市| 靖安县| 辽阳市| 灵璧县| 临高县| 林芝县| 项城市| 德格县| 张家界市| 松滋市| 安吉县| 崇礼县| 凤山县| 固安县| 榆林市| 安岳县| 深水埗区| 荆州市| 河南省| 拉萨市| 西乌珠穆沁旗| 鄂伦春自治旗| 青阳县| 九江市| 栖霞市| 嵊州市| 镇康县| 舞阳县| 修文县| 石屏县| 疏附县| 新绛县| 安乡县| 万安县|