Guidance
指路人
g.yi.org
software / rapidq / examples / gui / tray.bas

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
' How to put your application icon into the system tray area.
' Double click your icon to "re-display" the application.
' Written in Rapid-Q by William Yu

     $TYPECHECK ON

     TYPE TNOTIFYICONDATA
      cbSize AS DWORD
      hWnd AS LONG
      uID AS LONG
      uFlags AS LONG
      uCallbackMessage AS LONG
      hIcon AS LONG
      szTip AS STRING*64
     END TYPE

     DECLARE SUB Shell_NotifyIcon LIB "SHELL32" ALIAS "Shell_NotifyIconA" _
      (dwMessage AS LONG, NIDATA AS TNOTIFYICONDATA)

     CONST FALSE = 0
     CONST TRUE = 1

     CONST NIM_ADD = 0
     CONST NIM_MODIFY = 1
     CONST NIM_DELETE = 2

     CONST NIM_MESSAGE = 1
     CONST NIM_ICON = 2
     CONST NIM_TIP = 4

     CONST WM_USER = &H400
     CONST WM_TRAYICON = WM_USER + 400

     CONST WM_COMMAND = &H111
     CONST WM_SYSCOMMAND = &H112

     CONST WM_LBUTTONDOWN = &H201
     CONST WM_LBUTTONDBLCLK = &H203
     CONST WM_RBUTTONDOWN = &H204
     CONST WM_RBUTTONDBLCLK = &H206

     CONST SC_MINIMIZE = 61472
     CONST SC_CLOSE = 61536

     DIM Form AS QFORM
     DIM Button AS QBUTTON
     DIM NI AS TNotifyIconData
     DIM AlreadyTrayed AS INTEGER
     AlreadyTrayed = FALSE

     SUB FormClose
      IF AlreadyTrayed THEN
       Shell_NotifyIcon(NIM_DELETE, NI)   '-- Remove our tray icon
      END IF
      Application.Terminate
     END SUB

     SUB ButtonClick
      IF NOT AlreadyTrayed THEN
       NI.cbSize = SIZEOF(NI)
       NI.hWnd = Form.Handle
       NI.uID = Application.hInstance
       NI.uFlags = NIM_ICON OR NIM_MESSAGE OR NIM_TIP
       NI.hIcon = Application.Icon
       NI.uCallBackMessage = WM_TRAYICON
       NI.szTip = "Rapid-Q Tray Example"+CHR$(0)
       Shell_NotifyIcon(NIM_ADD, NI)
       AlreadyTrayed = TRUE
      END IF
      Form.Visible = FALSE
     END SUB

     SUB FormWndProc (Handle AS INTEGER, uMsg AS DWORD, wParam AS LONG, lParam AS LONG)
      IF uMsg = WM_SYSCOMMAND THEN
       IF wParam = SC_MINIMIZE THEN
       '-- Minimize to system tray
        ButtonClick
       END IF
      ELSEIF uMsg = WM_TRAYICON THEN
       IF (lParam AND &HFFFF) = WM_LBUTTONDBLCLK THEN   '-- Respond on double click
        Form.CAPTION = "I'm back!"
        Form.Visible = TRUE                           '-- Bring back our form
        Form.WindowState = 0
       END IF
      END IF
     END SUB


     Button.PARENT = Form
     Button.CAPTION = "Tray me"
     Button.OnClick = ButtonClick

     Form.CAPTION = "Tray Example"
     Form.Center
     Form.OnClose = FormClose
     Form.WndProc = FormWndProc
     Form.SHOWMODAL
掌柜推荐
 
 
¥900.00 ·
 
 
¥880.00 ·
 
 
¥497.00 ·
 
 
¥380.00 ·
 
 
¥980.00 ·
 
 
¥1,080.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-19 07:41:29