]>
git.saurik.com Git - wxWidgets.git/blob - samples/taskbar/tbtest.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxTaskBarIcon demo
4 // Author: Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
23 #include <wx/msw/taskbar.h>
27 MyDialog
*dialog
= NULL
;
31 bool MyApp::OnInit(void)
33 wxIcon
icon(wxT("mondrian_icon"));
35 if (!m_taskBarIcon
.SetIcon(icon
, wxT("wxTaskBarIcon Sample")))
36 wxMessageBox(wxT("Could not set icon."));
38 // Create the main frame window
39 dialog
= new MyDialog(NULL
, -1, wxT("wxTaskBarIcon Test Dialog"), wxPoint(-1, -1), wxSize(365, 290), wxDIALOG_MODELESS
|wxDEFAULT_DIALOG_STYLE
);
47 BEGIN_EVENT_TABLE(MyDialog
, wxDialog
)
48 EVT_BUTTON(wxID_OK
, MyDialog::OnOK
)
49 EVT_BUTTON(wxID_EXIT
, MyDialog::OnExit
)
50 EVT_CLOSE(MyDialog::OnCloseWindow
)
55 MyDialog::MyDialog(wxWindow
* parent
, const wxWindowID id
, const wxString
& title
,
56 const wxPoint
& pos
, const wxSize
& size
, const long windowStyle
):
57 wxDialog(parent
, id
, title
, pos
, size
, windowStyle
)
62 void MyDialog::OnOK(wxCommandEvent
& event
)
67 void MyDialog::OnExit(wxCommandEvent
& event
)
72 void MyDialog::OnCloseWindow(wxCloseEvent
& event
)
77 void MyDialog::Init(void)
79 (void)new wxStaticText(this, -1, "Press OK to hide me, Exit to quit.",
82 (void)new wxStaticText(this, -1, "Double-click on the taskbar icon to show me again.",
85 (void)new wxButton(this, wxID_EXIT
, "Exit", wxPoint(185, 230), wxSize(80, 25));
86 (new wxButton(this, wxID_OK
, "OK", wxPoint(100, 230), wxSize(80, 25)))->SetDefault();
98 BEGIN_EVENT_TABLE(MyTaskBarIcon
, wxTaskBarIcon
)
99 EVT_MENU(PU_RESTORE
, MyTaskBarIcon::OnMenuRestore
)
100 EVT_MENU(PU_EXIT
, MyTaskBarIcon::OnMenuExit
)
101 EVT_MENU(PU_NEW_ICON
,MyTaskBarIcon::OnMenuSetNewIcon
)
104 void MyTaskBarIcon::OnMenuRestore(wxCommandEvent
& )
109 void MyTaskBarIcon::OnMenuExit(wxCommandEvent
& )
113 // Nudge wxWindows into destroying the dialog, since
114 // with a hidden window no messages will get sent to put
115 // it into idle processing.
116 wxGetApp().ProcessIdle();
119 void MyTaskBarIcon::OnMenuSetNewIcon(wxCommandEvent
&)
122 wxIcon
icon(wxT("wxDEFAULT_FRAME"));
124 if (!SetIcon(icon
, wxT("wxTaskBarIcon Sample")))
125 wxMessageBox(wxT("Could not set new icon."));
130 void MyTaskBarIcon::OnMouseMove(wxEvent
&)
134 void MyTaskBarIcon::OnLButtonDown(wxEvent
&)
138 void MyTaskBarIcon::OnLButtonUp(wxEvent
&)
142 void MyTaskBarIcon::OnRButtonDown(wxEvent
&)
146 void MyTaskBarIcon::OnRButtonUp(wxEvent
&)
150 menu
.Append(PU_RESTORE
, "&Restore TBTest");
152 menu
.Append(PU_NEW_ICON
,"&Set New Icon");
154 menu
.Append(PU_EXIT
, "E&xit");
159 void MyTaskBarIcon::OnLButtonDClick(wxEvent
&)
164 void MyTaskBarIcon::OnRButtonDClick(wxEvent
&)