首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > PB >

pb托盘+菜单+热键呼出,该如何解决

2014-04-25 
pb托盘+菜单+热键呼出谁给个完整的代码?200分注意,是要托盘,和托盘上面显示的菜单,还有显示成托盘用热键可

pb托盘+菜单+热键呼出
谁给个完整的代码?200分
注意,是要托盘,和托盘上面显示的菜单,还有显示成托盘用热键可以呼出来的,最好是可以自定义热键的

邮箱tangfengsh@eyou.com
[解决办法]
api定义:
Public Function Integer Shell_NotifyIcon (Long dwMessage, Any lpData) Library "shell32" Alias For "Shell_NotifyIconA"

Public Function Long LoadImage (Long hInst, String lpsz, Long un1, Long n1, Long n2, Long un2) Library "user32" Alias  For "LoadImageA" 
Public Function Long DestroyIcon (Long hIcon) Library "user32" Alias For "DestroyIcon"

Public Function Long SetForegroundWindow  (Long hwnd) Library "user32" Alias For "SetForegroundWindow"

Public Function Long OpenIcon  (Long hwnd) Library "user32" Alias For "OpenIcon"

自定义函数  :
// Boolean AddToTray ()

Any nid

if hIcon = 0 then
// the icon has not been loaded yet
hIcon = LoadImage(0, "RED.ICO", IMAGE_ICON, 0, 0, LR_LOADFROMFILE)
end if

if hIcon = 0 then
//MessageBox ("Error", "Can't load icon!")
//
//Return False
else
nid = SetNotifyIconData (Handle (This), 0, NIF_MESSAGEorNIF_ICONorNIF_TIP, WM_MOUSEMOVE, hIcon, "南京**数据采集程序")
Shell_NotifyIcon (NIM_ADD, nid)
Return True
end if



// RemoveFromTray ()

Any nid

nid = SetNotifyIconData (Handle (This), 0, NIF_MESSAGEorNIF_ICONorNIF_TIP, 0, hIcon, "")
Shell_NotifyIcon (NIM_DELETE, nid)

if hIcon <> 0 then DestroyIcon (hIcon)
hIcon = 0


// NotifyIconData SetNotifyIconData (Long hWnd, Long ID, Long Flags, Long CallbackMessage, Long Icon, String Tip)

Char MyTip [64]

NotifyIconData NidTemp
 
NidTemp.cbSize = 88 // Len (NidTemp)
NidTemp.hWnd = hWnd
NidTemp.uID = ID
NidTemp.uFlags = Flags
NidTemp.uCallbackMessage = CallbackMessage
NidTemp.hIcon = Icon1
MyTip = Tip + Char (0)
NidTemp.szTip = MyTip
 
return NidTemp



事件  :

open:
if AddToTray () then Visible = False
MouseMove:

// Long MouseMove (UnsignedLong Flags, Int xPos, Int yPos)

if yPos <> 0 And Visible then
// This event has been triggered by really moving the
// mouse over the window. Note that we can't trace a
// first graphic line (yPos = 0) of mouse movements any
// more since tray events always set yPos to 0 but that
// won't be a problem in most of the cases anyway.
// TODO: place your own code here to handle then MouseMove event
//       if you want.
        
        
else
// This is really a tray event. We can find out what
// triggered this event by examining xPos value.

choose case Mod (xPos, 256)
// case 84, 41   // Left MouseDown
      // case 88, 46   // Left MouseUp

 case 95, 55   // Right MouseDown
 m_taskbarlm_Current
    integerli_X, li_Y
lm_Current = CREATE m_Taskbar
li_X = This.X
li_Y = This.Y

This.X = - This.Width - 10
This.Y = - This.Height - 10 

This.Visible=TRUE
lm_Current.m_main.Popmenu(PointerX(), PointerY())
This.Visible=FALSE

This.X = li_X
This.Y = li_Y


DESTROY lm_Current
//case 99, 59   // Right MouseUp
       case 91, 50   // Left DoubleClick
OpenIcon (Handle (This))
Visible = True
SetForegroundWindow (Handle (This))
// case 102, 64  // Right DoubleClick
      // case else // MouseMove
// Note that the only guarantee that the mouse
// is really moving over the tray icon is that
// the form is not being visible at this time.
// The mouse could also be moving over the


// first graphic line of a form (yPos = 0) otherwise.

// if Not Visible then
// end if
end choose
end if
[解决办法]


http://mmm.onegreen.net/code/pccode_2006910134714507.rar

里面有源代码,pbhelp

热点排行