summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfcolin2011-01-06 15:01:31 +0000
committerfcolin2011-01-06 15:01:31 +0000
commite00eb376f45ead6e5c5eccd79810d16ce72999b0 (patch)
treebbcceca709b40fa5bd4c2775c3d42d2ad4149e66
parente6df643b48aee1e56a0a6f4200991e3515dbce88 (diff)
downloadivy-cplusplus-e00eb376f45ead6e5c5eccd79810d16ce72999b0.zip
ivy-cplusplus-e00eb376f45ead6e5c5eccd79810d16ce72999b0.tar.gz
ivy-cplusplus-e00eb376f45ead6e5c5eccd79810d16ce72999b0.tar.bz2
ivy-cplusplus-e00eb376f45ead6e5c5eccd79810d16ce72999b0.tar.xz
modification bouton acceleration
-rw-r--r--Horloge/HorlogeDlg.cpp117
-rw-r--r--Horloge/HorlogeDlg.h8
-rw-r--r--Horloge/resource.h9
3 files changed, 130 insertions, 4 deletions
diff --git a/Horloge/HorlogeDlg.cpp b/Horloge/HorlogeDlg.cpp
index 5ec075a..8f83b07 100644
--- a/Horloge/HorlogeDlg.cpp
+++ b/Horloge/HorlogeDlg.cpp
@@ -14,6 +14,9 @@
static char THIS_FILE[] = __FILE__;
#endif
+
+UINT g_uTBBC = RegisterWindowMessage(L"TaskbarButtonCreated"); // for taskbar shell integration
+
/////////////////////////////////////////////////////////////////////////////
// CHorlogeDlg dialog
@@ -24,6 +27,7 @@ CHorlogeDlg::CHorlogeDlg(CWnd* pParent /*=NULL*/)
m_busnumber = _T("");
m_big_speed = FALSE;
m_filename = _T("");
+ m_pTaskBarlist = NULL;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
@@ -46,6 +50,7 @@ void CHorlogeDlg::DoDataExchange(CDataExchange* pDX)
DDX_Text(pDX, IDC_FILENAME, m_filename);
//}}AFX_DATA_MAP
DDX_Control(pDX, IDC_FILEPROGRESS, file_progress);
+ DDX_Control(pDX, IDC_SPIN1, m_speed_spin);
}
BEGIN_MESSAGE_MAP(CHorlogeDlg, CDialog)
@@ -67,7 +72,11 @@ BEGIN_MESSAGE_MAP(CHorlogeDlg, CDialog)
ON_BN_CLICKED(IDC_FILE, OnFile)
ON_BN_CLICKED(IDC_NORMAL_SPEED, OnNormalSpeed)
ON_LBN_DBLCLK(IDC_APPLIST, OnDblclkApplist)
+ ON_REGISTERED_MESSAGE( g_uTBBC, CHorlogeDlg::OnCreateThumbToolBar )
//}}AFX_MSG_MAP
+// ON_BN_DOUBLECLICKED(IDC_FORWARD, &CHorlogeDlg::OnBnDoubleclickedForward)
+// ON_BN_DOUBLECLICKED(IDC_BACKWARD, &CHorlogeDlg::OnBnDoubleclickedBackward)
+ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN1, &CHorlogeDlg::OnDeltaposSpin1)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
@@ -82,8 +91,6 @@ BOOL CHorlogeDlg::OnInitDialog()
//SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
- ((CButton*)GetDlgItem(IDC_FORWARD))->SetIcon( AfxGetApp()->LoadIcon(IDI_FORWARD));
- ((CButton*)GetDlgItem(IDC_BACKWARD))->SetIcon(AfxGetApp()->LoadIcon(IDI_BACKWARD));
((CButton*)GetDlgItem(IDC_PAUSE))->SetIcon(AfxGetApp()->LoadIcon(IDI_PAUSE));
((CButton*)GetDlgItem(IDC_START))->SetIcon(AfxGetApp()->LoadIcon(IDI_START));
((CButton*)GetDlgItem(IDC_NORMAL_SPEED))->SetIcon(AfxGetApp()->LoadIcon(IDI_NORMAL_SPEED));
@@ -119,7 +126,92 @@ BOOL CHorlogeDlg::OnInitDialog()
return TRUE; // return TRUE unless you set the focus to a control
}
+LRESULT CHorlogeDlg::OnCreateThumbToolBar( WPARAM, LPARAM )
+{
+ AddThumbarButtons();
+ return 0;
+}
+
+void CHorlogeDlg::AddThumbarButtons()
+{
+ // Initialize the pointer. You can also do this in the constructor.
+ // Remember to release after use
+ if( NULL == m_pTaskBarlist )
+ {
+ CoCreateInstance( CLSID_TaskbarList, NULL, CLSCTX_ALL,
+ IID_ITaskbarList3, (void**)&m_pTaskBarlist);
+ }
+
+ m_pTaskBarlist->HrInit();
+
+ // We mention that, we're specifying bitmap, tooltpi and other flags.
+ // This is mask, only specified parameters will be taken from structure
+ THUMBBUTTONMASK dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
+
+ // Create the images from a single bitmap which contains
+ // buttons seperated 16pix width. Like we handle toolbar buttons
+ CImageList ImageList;
+ ImageList.Create( MAKEINTRESOURCE( IDB_BITMAP_PAUSE), 16, 2, RGB( 0xFF,0,0xFF));
+
+ // Prepare the thumbar buttons
+ THUMBBUTTON thbButtons[2];
+ thbButtons[0].dwMask = dwMask;
+ // This can be any integer required on handling button events
+ thbButtons[0].iId = IDB_THB_BUTTON_START;
+ thbButtons[0].iBitmap = 0;
+ lstrcpy( thbButtons[0].szTip, TEXT("Start"));
+ thbButtons[0].dwFlags = THBF_ENABLED | THBF_DISMISSONCLICK;
+
+ thbButtons[1].dwMask = dwMask;
+ thbButtons[1].iId = IDB_THB_BUTTON_PAUSE;
+ thbButtons[1].iBitmap = 1;
+ thbButtons[1].dwFlags = THBF_ENABLED/*THBF_DISABLED*/ | THBF_DISMISSONCLICK;
+ lstrcpy( thbButtons[1].szTip, TEXT("Pause"));
+
+ // Declare the image list that contains the button images.
+ m_pTaskBarlist->ThumbBarSetImageList(m_hWnd, ImageList.GetSafeHandle());
+
+ // Attach the toolbar to the thumbnail.
+ m_pTaskBarlist->ThumbBarAddButtons(m_hWnd, ARRAYSIZE(thbButtons), thbButtons);
+
+ // In this program we're using the interface later, so not releasing now.
+ // It's Ok to release if finished using. We can create again when necessary
+}
+
+
+BOOL CHorlogeDlg::OnCommand(WPARAM wParam, LPARAM lParam)
+{
+ UINT CommandID = LOWORD( wParam );
+ if( IDB_THB_BUTTON_START == CommandID )
+ {
+ OnStart();
+ }
+ else if( IDB_THB_BUTTON_PAUSE == CommandID )
+ {
+ OnPause();
+ }
+ else
+ return CDialog::OnCommand(wParam, lParam);
+}
+
+void CHorlogeDlg::OnBnClickedButton1()
+{
+
+ THUMBBUTTONMASK dwMask = THB_FLAGS;
+
+ THUMBBUTTON thbButtons[2] = { };
+ thbButtons[0].dwMask = dwMask;
+ thbButtons[0].iId = IDB_THB_BUTTON_START;
+ thbButtons[0].dwFlags = THBF_DISABLED| THBF_DISMISSONCLICK;
+
+ thbButtons[1].dwMask = dwMask;
+ thbButtons[1].iId = IDB_THB_BUTTON_PAUSE;
+ thbButtons[1].dwFlags = THBF_ENABLED | THBF_DISMISSONCLICK;
+
+ m_pTaskBarlist->ThumbBarUpdateButtons( m_hWnd, ARRAYSIZE(thbButtons), thbButtons );
+
+}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
@@ -259,17 +351,21 @@ void CHorlogeDlg::OnBackward()
bus->SendMsg("SetClock Rate=%.2f",rate);
}
+
void CHorlogeDlg::OnForward()
{
rate += 0.5;
m_Speed.Format(TEXT("%.2f"), rate );
bus->SendMsg("SetClock Rate=%.2f",rate);
}
+
+
void CHorlogeDlg::OnNormalSpeed()
{
rate = 1.0;
m_Speed.Format(TEXT("%.2f"), rate );
bus->SendMsg("SetClock Rate=%.2f",rate);
+ m_speed_spin.SetPos( 0 );
}
@@ -345,3 +441,20 @@ void CHorlogeDlg::OnFile()
}
}
+
+
+void CHorlogeDlg::OnDeltaposSpin1(NMHDR *pNMHDR, LRESULT *pResult)
+{
+ LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
+ if ( rate <= 0.5 && pNMUpDown->iDelta < 0 )
+ {
+ *pResult = 1;
+ }
+ else
+ {
+ rate += 0.5 * pNMUpDown->iDelta;
+ m_Speed.Format(TEXT("%.2f"), rate );
+ bus->SendMsg("SetClock Rate=%.2f",rate);
+ *pResult = 0;
+ }
+}
diff --git a/Horloge/HorlogeDlg.h b/Horloge/HorlogeDlg.h
index 93cb915..51a4ee5 100644
--- a/Horloge/HorlogeDlg.h
+++ b/Horloge/HorlogeDlg.h
@@ -10,6 +10,7 @@
#include "Ivy.h"
#include "afxcmn.h"
+#include "afxwin.h"
/////////////////////////////////////////////////////////////////////////////
// CHorlogeDlg dialog
@@ -70,10 +71,17 @@ protected:
afx_msg void OnFile();
afx_msg void OnNormalSpeed();
afx_msg void OnDblclkApplist();
+ afx_msg void OnBnClickedButton1();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
public:
+ void AddThumbarButtons();
+ LRESULT OnCreateThumbToolBar( WPARAM, LPARAM );
CProgressCtrl file_progress;
+ afx_msg void OnDeltaposSpin1(NMHDR *pNMHDR, LRESULT *pResult);
+ CSpinButtonCtrl m_speed_spin;
+ ITaskbarList3* m_pTaskBarlist;
+ virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
};
//{{AFX_INSERT_LOCATION}}
diff --git a/Horloge/resource.h b/Horloge/resource.h
index a400f6a..60cccc6 100644
--- a/Horloge/resource.h
+++ b/Horloge/resource.h
@@ -9,6 +9,10 @@
#define IDI_PAUSE 143
#define IDI_START 144
#define IDI_NORMAL_SPEED 146
+#define IDB_THB_BUTTON_START 150
+#define IDB_THB_BUTTON_PAUSE 151
+#define IDB_BITMAP1 153
+#define IDB_BITMAP_PAUSE 153
#define IDC_PAUSE 1001
#define IDC_START 1002
#define IDC_BACKWARD 1003
@@ -31,14 +35,15 @@
#define IDC_FILENAME 1041
#define IDC_PROGRESS1 1043
#define IDC_FILEPROGRESS 1043
+#define IDC_SPIN1 1051
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 149
+#define _APS_NEXT_RESOURCE_VALUE 154
#define _APS_NEXT_COMMAND_VALUE 32772
-#define _APS_NEXT_CONTROL_VALUE 1044
+#define _APS_NEXT_CONTROL_VALUE 1052
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif