Guidance
指路人
g.yi.org
software / rapidq / examples / GUI / systray2.bas

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

  
' Source from "minimize to systray-parent.bas"
' Unnecessary stuff removed. 2 lines added for better working
' by paul@lenz-online.de


     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 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 NI AS TNotifyIconData
     DIM AlreadyTrayed AS INTEGER
     AlreadyTrayed = 0

     DECLARE SUB FormWndProc(Handle AS INTEGER, uMsg AS DWORD, wParam AS LONG, lParam AS LONG)
     DECLARE SUB Form_OnPaint
     DECLARE SUB TermApp


     CREATE Form AS QFORM
      OnPaint = Form_OnPaint
      WndProc = FormWndProc
      CAPTION = "Form"
     END CREATE


     CREATE ParentForm AS QFORM
      OnClose = TermApp
      CAPTION = "Parent"
      Center
     END CREATE

     form.SHOWMODAL

     SUB Form_OnPaint
      IF ParentForm.Visible = 0 THEN ParentForm.Show
      Form.Visible = 0
     END SUB

     SUB TermApp
      Shell_NotifyIcon(NIM_DELETE, NI)           ' This was missing!!!
      Application.Terminate
     END SUB


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


     SUB FormWndProc (Handle AS INTEGER, uMsg AS DWORD, wParam AS LONG, lParam AS LONG)
      IF ParentForm.WindowState = 1 THEN
       ParentForm.Visible = 0
       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 = 1
       END IF
      END IF
      IF uMsg = WM_TRAYICON THEN
       IF (lParam AND &HFFFF) = WM_LBUTTONDBLCLK THEN   '-- Respond on double click
        Shell_NotifyIcon(NIM_DELETE, NI)             ' This was missing!!!
        ParentForm.WindowState = 0                   ' normal
        ParentForm.Visible = 1
       END IF
      END IF
     END SUB

掌柜推荐
 
 
¥860.00 ·
 
 
¥900.00 ·
 
 
¥810.00 ·
 
 
¥317.00 ·
 
 
¥1,370.00 ·
 
 
¥660.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-19 07:41:28