將窗口最小化為時(shí)鐘旁的小圖標(biāo)(PowerBulider)
2024-07-21 02:09:20
供稿:網(wǎng)友
中國最大的web開發(fā)資源網(wǎng)站及技術(shù)社區(qū),
將窗口最小化為時(shí)鐘旁的小圖標(biāo)
建立主窗口"w_main",口定義如下"local external fuctions":
function long loadlibrary( ref string string ) library "kernel32" alias for loadlibrarya
function long freelibrary( long long ) library "kernel32"
function boolean shell_notifyicon( ulong long, ref s_str str ) library "shell32" alias for "shell_notifyicona"
function long loadicon( long long, long long ) library "user32" alias for loadicona
定義結(jié)構(gòu)型變量:
s_str:
size
unsignedlong
hwnd
long
id
unsignedlong
flags
unsignedlong
callbackmessage
unsignedlong
icon
long
tips[64]
character
定義實(shí)例變量:
private:
s_str istr_icon
窗口最小化按鈕click事件寫入如下script:
string ls_resource
long ll_handle
// 下三句為裝入圖標(biāo)資源,notepad.exe即為寫字板,exe執(zhí)行時(shí)顯示的圖標(biāo)內(nèi)定為1
ls_resource = "notepad.exe"
ll_handle = loadlibrary ( ls_resource )
istr_icon.icon = loadicon ( ll_handle, 1 )
// 窗口回調(diào)事件號(hào),pbm_custom01即為1024,02為1025,依此類推
istr_icon.callbackmessage = 1024
istr_icon.tips = "應(yīng)用程序"
istr_icon.hwnd = handle ( parent )
istr_icon.size = 88
istr_icon.id = 1
// 標(biāo)識(shí)值,即為顯示tips 4, 顯示icon 2, 激活窗口對(duì)應(yīng)事件號(hào)
istr_icon.flags = 7
// 顯示icon關(guān)鍵函數(shù), 0為顯示,1為修改,2為刪除
shell_notifyicon ( 0, istr_icon )
parent.hide ( )
// 釋放資源
freelibrary ( ll_handle )
為窗口創(chuàng)建用戶定義事件ue_event,event id為pbm_custom01,為其寫script:
m_popup lm_popup
integer li_x, li_y
choose case lparam
case 513 // lbuttonup
// 刪除圖標(biāo)
shell_notifyicon( 2, istr_icon )
// 顯示窗口
this.show ( )
case 517 // rbuttonup
li_x = this.x
li_y = this.y
// 移動(dòng)到屏幕外以免show 時(shí)看到,你可關(guān)閉此句看什么效果
this.move ( - this.width - 10, - this.height - 10 )
// 加這句才能看到菜單條(菜單條屬于此windows)
this.show ( )
lm_popup = create m_popup
lm_popup.m_item.popmenu ( pointerx ( ), pointery ( ) )
// 恢復(fù)設(shè)置
this.hide ( )
this.move ( li_x, li_y )
destroy lm_popup
end choose
其中,"m_popup"為最小化成trayicon圖標(biāo)時(shí)點(diǎn)擊右鍵時(shí)彈出的菜單。