求助:托盘程序的问题
请各位帮帮忙看一下下面这个程序,为什么我在运行的时候系统托盘那里多出一个空位来却显示不出图标。
$PBExportHeader$w_ab.srw
forward
global type w_ab from window
end type
end forward
global type w_ab from window
integer width = 2533
integer height = 1408
boolean titlebar = true
string title = "aa"
boolean controlmenu = true
boolean minbox = true
boolean maxbox = true
boolean resizable = true
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
event ue_event pbm_custom01
end type
global w_ab w_ab
type variables
str_notifyicondata istr_notifyicondata
Constant Long NIM_ADD = 0 //显示
Constant Long NIM_MODIFY = 1 //修改
Constant Long NIM_DELETE = 2 //删除
Constant Long NIF_MESSAGEorNIF_ICONorNIF_TIP = 7
Constant Long IMAGE_ICON = 1
Constant Long LR_LOADFROMFILE = 16
Constant Long WM_LBUTTONDBLCLK = 515 //双击
Constant Long WM_RBUTTONUP = 517 //右键单击
Long hIcon
end variables
forward prototypes
public function integer wf_removefromtray ()
public function integer wf_addtotray (string as_icon, long al_handle, string as_tips)
end prototypes
event ue_event;//m_pop 为右键弹出式菜单(可自己随意定义)
m_pop lm_popup
Integer li_X, li_Y
Choose Case lparam
Case WM_LBUTTONDBLCLK//双击
wf_RemoveFromTray()//删除图标
This.Show()//显示窗口
CASE WM_RBUTTONUP//右键
//messagebox(string(This.X),string(This.y))
li_X = This.X
li_Y = This.Y
//移动到屏幕外以免show时看到
This.Move( - This.Width - 10, - This.Height - 10 )
//在屏幕外显示窗口,以便能看到菜单条(菜单条属于此窗口)
This.Show()
//在鼠标位置弹出菜单
lm_popup = CREATE m_pop
lm_popup.m_pop_menu.PopMenu(PointerX(),PointerY())
//恢复设置
if isvalid(This) then
This.Hide()
This.Move(li_X,li_Y)
DESTROY lm_popup
end if
end choose
end event
public function integer wf_removefromtray ();Shell_NotifyIcon(NIM_DELETE,istr_notifyicondata)
if hIcon <> 0 then DestroyIcon(hIcon)
hIcon = 0
return 0
end function
public function integer wf_addtotray (string as_icon, long al_handle, string as_tips);if hIcon = 0 then//图标还没有装载
hIcon = LoadImage(0,as_icon,IMAGE_ICON,0,0,LR_LOADFROMFILE)
messagebox("",string(hIcon))
end if
if hIcon = 0 then
MessageBox ("系统提示", "装载图标失败!")
Return -1
end if
istr_notifyicondata.cbsize = 88
istr_notifyicondata.Hwnd = al_handle
istr_notifyicondata.uid = 0
//窗口回调事件号,pbm_custom01即为1024,02为1025,依此类推
istr_notifyicondata.ucallbackmessage = 1024
istr_notifyicondata.hIcon = hIcon
istr_notifyicondata.tips = as_tips
istr_notifyicondata.uflag = NIF_MESSAGEorNIF_ICONorNIF_TIP
shell_notifyicon(NIM_ADD,istr_notifyicondata)
messagebox("",string(shell_notifyicon(NIM_ADD,istr_notifyicondata)))
return 1
end function
event resize;string ls
ls=GetCurrentDirectory()
If SizeType = 1 Then//窗口最小化
wf_RemoveFromTray()//删除图标
//加载新图标
if wf_AddToTray('picture\1.ico', handle(this), "医保系统") = 1 then
this.Hide()
end if
end if
end event
event close;wf_RemoveFromTray()
end event