天天被操天天被操综合网,亚洲黄色一区二区三区性色,国产成人精品日本亚洲11,欧美zozo另类特级,www.黄片视频在线播放,啪啪网站永久免费看,特别一级a免费大片视频网站

      現(xiàn)在位置:范文先生網(wǎng)>理工論文>計(jì)算機(jī)信息技術(shù)>系統(tǒng)托盤的編程

      系統(tǒng)托盤的編程

      • 相關(guān)推薦

      系統(tǒng)托盤的編程

      托盤消息處理:
          在Shell32.DLL動態(tài)鏈接庫中包括一個函數(shù)Shell_NotifyIconA()可通知Windows在任務(wù)條右下角加入一個小圖標(biāo),可惜該函數(shù)的詳細(xì)說明未收入Delphi的幫助文檔中,F(xiàn)將實(shí)現(xiàn)例程示范如下:
      unit pro2;
      interface

      uses
        。。。, Menus,shellAPI;    //TNotifyIconData是定義在shellAPI單元的

      {自定義消息,當(dāng)小圖標(biāo)捕捉到鼠標(biāo)事件時Windows向回調(diào)函數(shù)發(fā)送此消息}
      const WM_MYTRAYICONCALLBACK = WM_USER + 1000 ;
      。。。。

      private
         MyTrayIcon : TNotifyIconData ;
         procedure WMMyTrayIconCallBack(Var Msg : TMessage);   message WM_MYTRAYICONCALLBACK ;
            //托盤消息處理過程
         procedure WMCommand(Var msg : TWMCommand);   message WM_Command;
            //處理托盤圖標(biāo)的右鍵菜單事件
         procedure Minimize(var mess:TWMNCLBUTTONDOWN);   message WM_NCLBUTTONDOWN;
            //窗體最小化時的消息處理
      。。。。。。。。

      procedure TForm1.FormCreate(Sender: TObject);
      begin 
          //將程序窗口樣式設(shè)為TOOL窗口,避免在任務(wù)欄上出現(xiàn)
         SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);
      end;

      procedure TForm1.FormShow(Sender: TObject);
      begin
          //設(shè)置托盤
          Icon.Handle := LoadIcon(Hinstance,'MAINICON');
          MyTrayIcon.cbSize := SizeOf(TNotifyIconData);// nid變量的字節(jié)數(shù)
          MyTrayIcon.Wnd := Handle ;// 主窗口句柄
          MyTrayIcon.uID := 1 ;// 內(nèi)部標(biāo)識,可設(shè)為任意數(shù)
          MyTrayIcon.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE ;// 指明哪些字段有效
          MyTrayIcon.uCallBackMessage := WM_MYTRAYICONCALLBACK ;//回調(diào)函數(shù)消息,將自定義托盤消息傳遞進(jìn)去
          MyTrayIcon.hIcon := Application.Icon.Handle; // 要加入的圖標(biāo)句柄,可任意指定
          StrCopy(MyTrayIcon.szTip, PChar(Caption));
          Shell_NotifyIcon(NIM_ADD,@MyTrayIcon);
          ShowWindow(Handle,sw_Hide);
          // Visible := False ;//當(dāng)程序啟動時就最小化在托盤區(qū)即Form.Create時啟用此語句
          Application.ShowMainForm := False ;
          SetForegroundWindow(Application.Handle);
      end;

      ////消息過程實(shí)現(xiàn)
      procedure TForm1.WMMyTrayIconCallBack(var Msg: TMessage);
      var CursorPos : TPoint;
      begin
         case Msg.LParam of
           WM_LBUTTONDBLCLK : //雙擊消息:彈出主窗口
           begin
             Visible := not Visible ;
             Application.ShowMainForm := Visible ;
             SetForegroundWindow(Application.Handle);
           end ;
           WM_RBUTTONDOWN : //鼠標(biāo)右鍵:彈出菜單

        begin
             GetCursorPos(CursorPos);
      {      Popupmenu1.Popup(CursorPos.X,CursorPos.Y);
             popupmen1里面就可以加入顯示主窗口、退出等功能。這個右鍵菜單可以是靜態(tài)的,如上面一句來彈出;也可以動態(tài)建立,如下面所示的方法:}
             pm := createpopupmenu;//建立一個Hmenu,pm:hmenu;
             AppendMenu(pm,0,ord('A'),'關(guān)于....');//在指定的菜單里添加一個菜單項(xiàng)
             AppendMenu(pm,0,Ord('B'),'&Exit');
             //加入菜單事件---》處理WMCOMMAND消息即可
             TrackPopupMenu(pm,Tpm_BottomAlign or Tpm_RightAlign, CursorPos.x, CursorPos.y, 0,handle,nil);
             //在圖標(biāo)上方顯示該彈出式菜單
           end ;
         end ;
      end;

      procedure TForm1.WMCommand(var msg : TWMCommand);
      begin
         Case msg.ItemID of
           Ord('A') : showmessage('我的右鍵菜單!');
           Ord('B') : Self.close;//關(guān)閉程序主窗體
           else inherited;
         end;
      end;

      procedure Tform1.Minimize(var mess:TWMNCLBUTTONDOWN);//應(yīng)用程序最小化消息處理
      begin
         if Mess.Hittest = htReduce then
           Self.Hide
         else inherited;
      end;

      procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
      var              {程序被關(guān)閉時通知Windows去掉小圖標(biāo)}
         nid: TNotifyIconData;
      begin
         nid.cbSize := sizeof(nid); // nid變量的字節(jié)數(shù)
         nid.uID := 1; //內(nèi)部標(biāo)識,與加入小圖標(biāo)時的數(shù)一致
         nid.Wnd := Handle; //主窗口句柄
         Shell_NotifyIcon(NIM_DELETE, @nid); //去掉小圖標(biāo)
      end;