powerbuilder中把图标放在时间显示处

类别:数据库 点击:0 评论:0 推荐:

将窗口最小化为时钟旁的小图标

编辑整理:panya

建立主窗口“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

 

定义结构型变量:

s_str:

size

Unsignedlong

Hwnd

Long

Id

Unsignedlong

Flags

Unsignedlong

Callbackmessage

Unsignedlong

Icon

Long

tips[64]

Character

 

定义实例变量:

private:

s_str istr_icon

 

窗口最小化按钮Click事件写入如下Script:

string ls_resource

Long ll_handle

// 下三句为装入图标资源,notepad.exe即为写字板,exe执行时显示的图标内定为1

ls_resource = "notepad.exe"

ll_handle = loadlibrary ( ls_resource )

istr_icon.icon = loadicon ( ll_handle, 1 )

// 窗口回调事件号,pbm_custom01即为1024,02为1025,依此类推

istr_icon.callbackmessage = 1024

istr_icon.tips = "应用程序"

istr_icon.hwnd = handle ( parent )

istr_icon.size = 88

istr_icon.id = 1

// 标识值,即为显示tips 4, 显示icon 2, 激活窗口对应事件号

istr_icon.flags = 7

// 显示icon关键函数, 0为显示,1为修改,2为删除

shell_notifyicon ( 0, istr_icon )

parent.hide ( )

// 释放资源

freelibrary ( ll_handle )

 

为窗口创建用户定义事件ue_event,event id为pbm_custom01,为其写script:

m_popup lm_popup

Integer li_X, li_Y

choose case lparam

Case 513 // LButtonUp

// 删除图标

Shell_NotifyIcon( 2, istr_icon )

// 显示窗口

this.show ( )

CASE 517 // RButtonUp

li_X = This.X

li_Y = This.Y

// 移动到屏幕外以免show 时看到,你可关闭此句看什么效果

This.Move ( - This.Width - 10, - This.Height - 10 )

// 加这句才能看到菜单条(菜单条属于此windows)

This.Show ( )

lm_popup = CREATE m_popup

lm_popup.m_item.PopMenu ( PointerX ( ), PointerY ( ) )

// 恢复设置

This.Hide ( )

This.Move ( li_X, li_Y )

DESTROY lm_popup

end choose

 

其中,“m_popup”为最小化成TRAYICON图标时点击右键时弹出的菜单。

本文地址:http://com.8s8s.com/it/it21518.htm