hirs the code:
Code: Select all
sipxezphoneapp.h
#ifndef _sipxezphoneapp_h
#define _sipxezphoneapp_h
// SYSTEM INCLUDES
#include "utl/UtlDefs.h"
#include "utl/UtlString.h"
#include "sipXezPhoneFrame.h"
#include "wx/taskbar.h"
// APPLICATION INCLUDES
// DEFINES
// define the event table macros
#define EVT_STATUS_MESSAGE_COMMAND(id, fn) \
DECLARE_EVENT_TABLE_ENTRY ( \
ezEVT_STATUS_MESSAGE_COMMAND, id, -1, \
(wxObjectEventFunction)(wxEventFunction)(wxCommandEventFunction)&fn, \
(wxObject*) NULL \
),
#define EVT_LOG_MESSAGE_COMMAND(id, fn) \
DECLARE_EVENT_TABLE_ENTRY ( \
ezEVT_LOG_MESSAGE_COMMAND, id, -1, \
(wxObjectEventFunction)(wxEventFunction)(wxCommandEventFunction)&fn, \
(wxObject*) NULL \
),
// MACROS
// EXTERNAL FUNCTIONS
// EXTERNAL VARIABLES
// CONSTANTS
// STRUCTS
// TYPEDEFS
// FORWARD DECLARATIONS
/**
* This is the main wxApp derived class for the phone.
*/
class MyTaskBarIcon: public wxTaskBarIcon
{
public:
MyTaskBarIcon() {};
virtual void OnMouseMove(wxEvent&);
virtual void OnLButtonDown(wxEvent&);
virtual void OnLButtonUp(wxEvent&);
virtual void OnRButtonDown(wxEvent&);
virtual void OnRButtonUp(wxEvent&);
virtual void OnLButtonDClick(wxEvent&);
virtual void OnRButtonDClick(wxEvent&);
void OnMenuRestore(wxCommandEvent& event);
void OnMenuExit(wxCommandEvent& event);
void OnMenuSetNewIcon(wxCommandEvent& event);
private:
// sipXezPhoneFrame *mpFrame;
DECLARE_EVENT_TABLE()
};
class sipXezPhoneApp : public wxApp
{
/* //////////////////////////// PUBLIC //////////////////////////////////// */
public:
//add
void OnOK(wxCommandEvent& event);
void OnExit(wxCommandEvent& event);
void OnCloseWindow(wxCloseEvent& event);
void Init(void);
/* ============================ CREATORS ================================== */
/**
* Contructor.
*/
sipXezPhoneApp();
/**
* Destructor.
*/
virtual ~sipXezPhoneApp();
* Initialization routine called by wxWidgets. Creates the frame window.
*/
virtual bool OnInit();
/**
* Displays a message in the UI. Good for testing / debugging.
*/
void addLogMessage(UtlString message);
/**
* Displays a status message in the UI. User feedback to indicate the state of the phone
*/
void setStatusMessage(const wxString& message);
/**
* Retrieves the string value entered in the combo box;
*/
const wxString getEnteredText();
/**
* Accessor for the Frame derived class object
*/
sipXezPhoneFrame& getFrame() const;
void OnProcessStatusMessage(wxCommandEvent& event);
void OnProcessLogMessage(wxCommandEvent& event);
protected:
MyTaskBarIcon m_taskBarIcon;
private:
sipXezPhoneFrame* mpFrame;
wxString mStatusMessage;
wxString mLogMessage;
DECLARE_EVENT_TABLE()
};
#endif
Code: Select all
BEGIN_EVENT_TABLE(MyTaskBarIcon, wxTaskBarIcon)
EVT_MENU(PU_RESTORE, MyTaskBarIcon::OnMenuRestore)
EVT_MENU(PU_EXIT, MyTaskBarIcon::OnMenuExit)
EVT_MENU(PU_NEW_ICON,MyTaskBarIcon::OnMenuSetNewIcon)
END_EVENT_TABLE()
void MyTaskBarIcon::OnMenuRestore(wxCommandEvent& )
{
mpFrame->Show(TRUE);
}
void MyTaskBarIcon::OnMenuExit(wxCommandEvent& )
{
mpFrame->Close(TRUE);
// Nudge wxWindows into destroying the dialog, since
// with a hidden window no messages will get sent to put
// it into idle processing.
//wxGetApp().ProcessIdle();
}
void MyTaskBarIcon::OnMenuSetNewIcon(wxCommandEvent&)
{
#ifdef __WXMSW__
wxIcon icon(wxT("res/cc.ico"));
if (!SetIcon(icon, wxT("wxTaskBarIcon Sample")))
wxMessageBox(wxT("Could not set new icon."));
#endif
}
// Overridables
void MyTaskBarIcon::OnMouseMove(wxEvent&)
{
}
void MyTaskBarIcon::OnLButtonDown(wxEvent&)
{
}
void MyTaskBarIcon::OnLButtonUp(wxEvent&)
{
}
void MyTaskBarIcon::OnRButtonDown(wxEvent&)
{
}
void MyTaskBarIcon::OnRButtonUp(wxEvent&)
{
wxMenu menu;
menu.Append(PU_RESTORE, _T("&Restore TBTest"));
#ifdef __WXMSW__
menu.Append(PU_NEW_ICON,_T("&Set New Icon"));
#endif
menu.Append(PU_EXIT, _T("E&xit"));
PopupMenu(&menu);
}
void MyTaskBarIcon::OnLButtonDClick(wxEvent&)
{
mpFrame->Show(TRUE);
}
void MyTaskBarIcon::OnRButtonDClick(wxEvent&)
{
}
Code: Select all
sipXezPhoneApp.cpp
wxIcon taskbar_icon(wxT("res/cc.ico"));
if (!m_taskBarIcon.SetIcon(taskbar_icon, wxT("wxTaskBarIcon Sample")))
wxMessageBox(wxT("Could not set icon."));
thanks