Unit1.cpp
上传用户:lhxd_sz
上传日期:2014-10-02
资源大小:38814k
文件大小:2k
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "Unit1.h"
- #include "Unit2.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- MyIcon=new TIcon();
- TNotifyIconData IconData;
- MyIcon->LoadFromFile("Icon1.ico");
- IconData.cbSize=sizeof(IconData);
- IconData.hWnd=Handle;
- IconData.uID=100;
- IconData.hIcon=MyIcon->Handle;
- IconData.uFlags=NIF_ICON | NIF_MESSAGE | NIF_TIP;
- IconData.uCallbackMessage=WM_USER+100;
- strcpy(IconData.szTip,"托盘图标示例");
- Shell_NotifyIcon(NIM_ADD,&IconData);
- SetWindowLong(Application->Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);
- }
- //---------------------------------------------------------------------------
- __fastcall TForm1::~TForm1()
- {
- TNotifyIconData IconData;
- IconData.cbSize=sizeof(IconData);
- IconData.hWnd=Handle;
- IconData.uID=100;
- Shell_NotifyIcon(NIM_DELETE,&IconData);
- delete MyIcon;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::IconClick(TMessage& Msg)
- {
- TPoint po;
- if(Msg.LParam==WM_LBUTTONDBLCLK)
- {
- Form2->Show();
- }
- if(Msg.LParam==WM_RBUTTONDOWN)
- {
- GetCursorPos(&po);
- PopupMenu1->Popup(po.x,po.y);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormShow(TObject *Sender)
- {
- Width=0;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::N2Click(TObject *Sender)
- {
- Close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::N1Click(TObject *Sender)
- {
- Form2->Show();
- }
- //---------------------------------------------------------------------------