]>
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("mondrian_icon");
35 if (!m_taskBarIcon
.SetIcon(icon
, "wxTaskBarIcon Sample"))
36 wxMessageBox("Could not set icon.");
38 // Create the main frame window
39 dialog
= new MyDialog(NULL
, -1, "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 int dialogWidth
= 365;
80 int dialogHeight
= 290;
82 wxStaticText
* stat
= new wxStaticText(this, -1, "Press OK to hide me, Exit to quit.",
85 wxStaticText
* stat2
= new wxStaticText(this, -1, "Double-click on the taskbar icon to show me again.",
88 wxButton
*okButton
= new wxButton(this, wxID_OK
, "OK", wxPoint(100, 230), wxSize(80, 25));
89 wxButton
*exitButton
= new wxButton(this, wxID_EXIT
, "Exit", wxPoint(185, 230), wxSize(80, 25));
90 okButton
->SetDefault();
101 BEGIN_EVENT_TABLE(MyTaskBarIcon
, wxTaskBarIcon
)
102 EVT_MENU(PU_RESTORE
, MyTaskBarIcon::OnMenuRestore
)
103 EVT_MENU(PU_EXIT
, MyTaskBarIcon::OnMenuExit
)
106 void MyTaskBarIcon::OnMenuRestore(wxCommandEvent
& )
111 void MyTaskBarIcon::OnMenuExit(wxCommandEvent
& )
115 // Nudge wxWindows into destroying the dialog, since
116 // with a hidden window no messages will get sent to put
117 // it into idle processing.
118 wxGetApp().ProcessIdle();
123 void MyTaskBarIcon::OnMouseMove(wxEvent
&)
127 void MyTaskBarIcon::OnLButtonDown(wxEvent
&)
131 void MyTaskBarIcon::OnLButtonUp(wxEvent
&)
135 void MyTaskBarIcon::OnRButtonDown(wxEvent
&)
139 void MyTaskBarIcon::OnRButtonUp(wxEvent
&)
143 menu
.Append(PU_RESTORE
, "&Restore TBTest");
144 menu
.Append(PU_EXIT
, "E&xit");
149 void MyTaskBarIcon::OnLButtonDClick(wxEvent
&)
154 void MyTaskBarIcon::OnRButtonDClick(wxEvent
&)