求助:托盘程序的问题

zifenglingx 2005-09-20 03:36:21
请各位帮帮忙看一下下面这个程序,为什么我在运行的时候系统托盘那里多出一个空位来却显示不出图标。

$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
...全文
157 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zifenglingx 2005-09-22
  • 打赏
  • 举报
回复
各位帮帮忙啊,急用啊
ybkenan 2005-09-21
  • 打赏
  • 举报
回复
可能是你圖片的位置不對﹐你先試一下絕對路徑試試。
用'd:\program\picture\1.ico'試試。
zifenglingx 2005-09-21
  • 打赏
  • 举报
回复
不是路径的问题,我测试的时候发现LoadImage函数已经load到图片了,而且就算改成绝对路径也还是有这个问题。
zifenglingx 2005-09-20
  • 打赏
  • 举报
回复
str_notifyicondata的定义如下:

global type str_notifyicondata from structure
long cbsize
long hwnd
long uid
long ucallbackmessage
long uflag
long hicon
char tips[64]
end type

680

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder API 调用
社区管理员
  • API 调用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧