Grazie alla spiegazioni di alka e cercando in google la direttiva MESSAGE in borland c++ ho trovato come fare.
Posto i codici, magari a qualcuno può interessare:
Nel Header File:
codice:
#define ID_CALLBACK WM_USER
#define ID_TRAYICON 1006
....
public:
virtual __fastcall TF_Main(TComponent* Owner);
void __fastcall TrayEvent(TMessage& Msg);
bool __fastcall ShowBalloonTip(DWORD Visible, DWORD Icon, String Title, String TipText);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(ID_CALLBACK,TMessage,TrayEvent);
END_MESSAGE_MAP(TForm)
....
Nel CPP File:
codice:
....
//-------------------------------------------------------------------
void __fastcall TF_Main::TrayEvent(TMessage& Msg)
{
POINT MousePos;
switch(Msg.LParam)
{
case WM_RBUTTONUP:
if (GetCursorPos(&MousePos))
{
PM_TrayIcon->PopupComponent = F_Main;
SetForegroundWindow(Handle);
PM_TrayIcon->Popup(MousePos.x, MousePos.y);
}
break;
case WM_LBUTTONUP:
ShowMessage("Click su Tray Icon");
break:
case 1029:
ShowMessage("Click su Balloon Tip");
break;
default:
break;
}
TForm::Dispatch(&Msg);
}
//-------------------------------------------------------------------
bool __fastcall TF_Main::ShowBalloonTip(DWORD Visible, DWORD Icon, String Title, String TipText)
{
NOTIFYICONDATA m_nid;
m_nid.cbSize=sizeof(NOTIFYICONDATA);
m_nid.hWnd= Handle;
m_nid.uID= ID_TRAYICON;
m_nid.uFlags = NIF_TIP | NIF_ICON |NIF_INFO | NIF_MESSAGE;
m_nid.uCallbackMessage= ID_CALLBACK;
m_nid.hIcon= Application->Icon->Handle;
m_nid.uTimeout = 2000;
m_nid.dwInfoFlags = Icon;
lstrcpy(m_nid.szInfo,TipText.c_str());
lstrcpy(m_nid.szInfoTitle,Title.c_str());
lstrcpy(m_nid.szTip,"Gestione Telefonia Message");
Shell_NotifyIcon(Visible, &m_nid);
return (Shell_NotifyIcon(Visible, &m_nid));
}
//-------------------------------------------------------------------
....
Ancora Grazie a Alka..
Ciao...