taskbar icon problem Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
cyrixware
Earned some good credits
Earned some good credits
Posts: 103
Joined: Mon Apr 17, 2006 1:24 pm
Location: Philippines
Contact:

taskbar icon problem

Post by cyrixware »

HI just wana ask smething regarding the tskbar icon when minimizing the current wxFrame.

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
Then partly included in my sipXezPhoneFrame.cpp

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."));

But still does not work after i click the minimize button.. somebody help me pls...

thanks
WinXP SP2, VS.NET
wxDev-C++ 4.9.9.2, wxWindows-2.4.2
Need4Speed!
cyrixware
Earned some good credits
Earned some good credits
Posts: 103
Joined: Mon Apr 17, 2006 1:24 pm
Location: Philippines
Contact:

Post by cyrixware »

ok i got the answer now it works well. But one thing the icon didnt show on the task bar....

Code: Select all

wxIcon taskbar_icon(wxT("res/cc.ico", wxBITMAP_TYPE_ICO));
		 if (!m_taskBarIcon.SetIcon(taskbar_icon, wxT("Callcloud (Beta)"))) wxMessageBox(wxT("Could not set icon."));
Last edited by cyrixware on Thu Jun 15, 2006 6:28 am, edited 1 time in total.
WinXP SP2, VS.NET
wxDev-C++ 4.9.9.2, wxWindows-2.4.2
Need4Speed!
cyrixware
Earned some good credits
Earned some good credits
Posts: 103
Joined: Mon Apr 17, 2006 1:24 pm
Location: Philippines
Contact:

Post by cyrixware »

ok now it works fine....
WinXP SP2, VS.NET
wxDev-C++ 4.9.9.2, wxWindows-2.4.2
Need4Speed!
Post Reply