How can I refresh for Ribbon UI at any time?
I create a MFC SDI Application.
The application has CMFCRibbonEdit UI that refresh by constant rate.
But, I can't do my constant rate refresh by ON_UPDATE_COMMAND_UI.
I look like the following.
- moving a cursor on ribbon : refresh by 100ms
- oher : refresh by 1000ms
How can I refresh the UI by my rate (100ms) ?
Sample Code:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
....
m_wndRibbonBar.Create(this);
m_wndRibbonBar.LoadFromResource(IDR_RIBBON);
CMFCRibbonCategory* pCategoryTest = m_wndRibbonBar.AddCategory(L"TEST CAT", IDB_WRITESMALL, IDB_WRITELARGE);
CMFCRibbonPanel* pPanelTest = pCategoryTest->AddPanel(L"Test Panel");
pEdit_ = new CMFCRibbonEdit(ID_EDIT_1, 120, L"test");
pPanelTest->Add(pEdit_);
....
// data refresh by constant rate (100ms)
worker_ = std::thread([&] {
while (1)
{
count_ += 0.1f;
Sleep(100);
}
});
....
}
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx)
ON_WM_CREATE()
ON_WM_SETFOCUS()
ON_UPDATE_COMMAND_UI(ID_EDIT_1, &CMainFrame::UpdateCommandUI)
END_MESSAGE_MAP()
void CMainFrame::UpdateCommandUI(CCmdUI* pCmdUI)
{
if (pCmdUI->m_nID == ID_EDIT_1)
{
CString str;
str.Format(L"%f", count_);
pEdit_->SetEditText(str);
}
}
c++ mfc ribbon
add a comment |
I create a MFC SDI Application.
The application has CMFCRibbonEdit UI that refresh by constant rate.
But, I can't do my constant rate refresh by ON_UPDATE_COMMAND_UI.
I look like the following.
- moving a cursor on ribbon : refresh by 100ms
- oher : refresh by 1000ms
How can I refresh the UI by my rate (100ms) ?
Sample Code:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
....
m_wndRibbonBar.Create(this);
m_wndRibbonBar.LoadFromResource(IDR_RIBBON);
CMFCRibbonCategory* pCategoryTest = m_wndRibbonBar.AddCategory(L"TEST CAT", IDB_WRITESMALL, IDB_WRITELARGE);
CMFCRibbonPanel* pPanelTest = pCategoryTest->AddPanel(L"Test Panel");
pEdit_ = new CMFCRibbonEdit(ID_EDIT_1, 120, L"test");
pPanelTest->Add(pEdit_);
....
// data refresh by constant rate (100ms)
worker_ = std::thread([&] {
while (1)
{
count_ += 0.1f;
Sleep(100);
}
});
....
}
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx)
ON_WM_CREATE()
ON_WM_SETFOCUS()
ON_UPDATE_COMMAND_UI(ID_EDIT_1, &CMainFrame::UpdateCommandUI)
END_MESSAGE_MAP()
void CMainFrame::UpdateCommandUI(CCmdUI* pCmdUI)
{
if (pCmdUI->m_nID == ID_EDIT_1)
{
CString str;
str.Format(L"%f", count_);
pEdit_->SetEditText(str);
}
}
c++ mfc ribbon
2
Set up a timer (CWnd::SetTimer) and update the UI element(s) in the timer callback. Optionally adjust the timer in the timer callback when it starts to drift and you need a more steady update rate.
– IInspectable
Nov 25 '18 at 8:50
OK. I try it. Thank you, IInspectable!
– Evan.Titer
Nov 25 '18 at 14:54
add a comment |
I create a MFC SDI Application.
The application has CMFCRibbonEdit UI that refresh by constant rate.
But, I can't do my constant rate refresh by ON_UPDATE_COMMAND_UI.
I look like the following.
- moving a cursor on ribbon : refresh by 100ms
- oher : refresh by 1000ms
How can I refresh the UI by my rate (100ms) ?
Sample Code:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
....
m_wndRibbonBar.Create(this);
m_wndRibbonBar.LoadFromResource(IDR_RIBBON);
CMFCRibbonCategory* pCategoryTest = m_wndRibbonBar.AddCategory(L"TEST CAT", IDB_WRITESMALL, IDB_WRITELARGE);
CMFCRibbonPanel* pPanelTest = pCategoryTest->AddPanel(L"Test Panel");
pEdit_ = new CMFCRibbonEdit(ID_EDIT_1, 120, L"test");
pPanelTest->Add(pEdit_);
....
// data refresh by constant rate (100ms)
worker_ = std::thread([&] {
while (1)
{
count_ += 0.1f;
Sleep(100);
}
});
....
}
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx)
ON_WM_CREATE()
ON_WM_SETFOCUS()
ON_UPDATE_COMMAND_UI(ID_EDIT_1, &CMainFrame::UpdateCommandUI)
END_MESSAGE_MAP()
void CMainFrame::UpdateCommandUI(CCmdUI* pCmdUI)
{
if (pCmdUI->m_nID == ID_EDIT_1)
{
CString str;
str.Format(L"%f", count_);
pEdit_->SetEditText(str);
}
}
c++ mfc ribbon
I create a MFC SDI Application.
The application has CMFCRibbonEdit UI that refresh by constant rate.
But, I can't do my constant rate refresh by ON_UPDATE_COMMAND_UI.
I look like the following.
- moving a cursor on ribbon : refresh by 100ms
- oher : refresh by 1000ms
How can I refresh the UI by my rate (100ms) ?
Sample Code:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
....
m_wndRibbonBar.Create(this);
m_wndRibbonBar.LoadFromResource(IDR_RIBBON);
CMFCRibbonCategory* pCategoryTest = m_wndRibbonBar.AddCategory(L"TEST CAT", IDB_WRITESMALL, IDB_WRITELARGE);
CMFCRibbonPanel* pPanelTest = pCategoryTest->AddPanel(L"Test Panel");
pEdit_ = new CMFCRibbonEdit(ID_EDIT_1, 120, L"test");
pPanelTest->Add(pEdit_);
....
// data refresh by constant rate (100ms)
worker_ = std::thread([&] {
while (1)
{
count_ += 0.1f;
Sleep(100);
}
});
....
}
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx)
ON_WM_CREATE()
ON_WM_SETFOCUS()
ON_UPDATE_COMMAND_UI(ID_EDIT_1, &CMainFrame::UpdateCommandUI)
END_MESSAGE_MAP()
void CMainFrame::UpdateCommandUI(CCmdUI* pCmdUI)
{
if (pCmdUI->m_nID == ID_EDIT_1)
{
CString str;
str.Format(L"%f", count_);
pEdit_->SetEditText(str);
}
}
c++ mfc ribbon
c++ mfc ribbon
edited Nov 25 '18 at 6:39
Evan.Titer
asked Nov 25 '18 at 6:34
Evan.TiterEvan.Titer
687
687
2
Set up a timer (CWnd::SetTimer) and update the UI element(s) in the timer callback. Optionally adjust the timer in the timer callback when it starts to drift and you need a more steady update rate.
– IInspectable
Nov 25 '18 at 8:50
OK. I try it. Thank you, IInspectable!
– Evan.Titer
Nov 25 '18 at 14:54
add a comment |
2
Set up a timer (CWnd::SetTimer) and update the UI element(s) in the timer callback. Optionally adjust the timer in the timer callback when it starts to drift and you need a more steady update rate.
– IInspectable
Nov 25 '18 at 8:50
OK. I try it. Thank you, IInspectable!
– Evan.Titer
Nov 25 '18 at 14:54
2
2
Set up a timer (CWnd::SetTimer) and update the UI element(s) in the timer callback. Optionally adjust the timer in the timer callback when it starts to drift and you need a more steady update rate.
– IInspectable
Nov 25 '18 at 8:50
Set up a timer (CWnd::SetTimer) and update the UI element(s) in the timer callback. Optionally adjust the timer in the timer callback when it starts to drift and you need a more steady update rate.
– IInspectable
Nov 25 '18 at 8:50
OK. I try it. Thank you, IInspectable!
– Evan.Titer
Nov 25 '18 at 14:54
OK. I try it. Thank you, IInspectable!
– Evan.Titer
Nov 25 '18 at 14:54
add a comment |
1 Answer
1
active
oldest
votes
Success!
Thank you, IInspectable!
CMainFrame::~CMainFrame()
{
//KillTimer(TEST_TIMER_ID);
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
....
// Create CMFCRibbonEdit
....
// Delete worker thread
//worker_ = std::thread([&] {
....
// Setup Timer by 100ms
SetTimer(TEST_TIMER_ID, 100, NULL);
return 0;
}
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx)
ON_WM_CREATE()
ON_WM_SETFOCUS()
ON_WM_TIMER()
END_MESSAGE_MAP()
void CMainFrame::OnTimer(UINT_PTR nIDEvent)
{
if (nIDEvent == TEST_TIMER_ID)
{
count_ += 0.1f;
CString str;
str.Format(L"%f", count_);
pEdit_->SetEditText(str);
}
CFrameWndEx::OnTimer(nIDEvent);
}
KillTimer
is not doing anything because by that time the window handle is destroyed, and the timers are automatically destroyed by OS. You can skipKillTimer
if the timer is required throughout the process.
– Barmak Shemirani
Nov 25 '18 at 16:08
I update my answer. Thank you, Barmak Shemirani!
– Evan.Titer
Nov 26 '18 at 14:18
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53465233%2fhow-can-i-refresh-for-ribbon-ui-at-any-time%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Success!
Thank you, IInspectable!
CMainFrame::~CMainFrame()
{
//KillTimer(TEST_TIMER_ID);
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
....
// Create CMFCRibbonEdit
....
// Delete worker thread
//worker_ = std::thread([&] {
....
// Setup Timer by 100ms
SetTimer(TEST_TIMER_ID, 100, NULL);
return 0;
}
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx)
ON_WM_CREATE()
ON_WM_SETFOCUS()
ON_WM_TIMER()
END_MESSAGE_MAP()
void CMainFrame::OnTimer(UINT_PTR nIDEvent)
{
if (nIDEvent == TEST_TIMER_ID)
{
count_ += 0.1f;
CString str;
str.Format(L"%f", count_);
pEdit_->SetEditText(str);
}
CFrameWndEx::OnTimer(nIDEvent);
}
KillTimer
is not doing anything because by that time the window handle is destroyed, and the timers are automatically destroyed by OS. You can skipKillTimer
if the timer is required throughout the process.
– Barmak Shemirani
Nov 25 '18 at 16:08
I update my answer. Thank you, Barmak Shemirani!
– Evan.Titer
Nov 26 '18 at 14:18
add a comment |
Success!
Thank you, IInspectable!
CMainFrame::~CMainFrame()
{
//KillTimer(TEST_TIMER_ID);
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
....
// Create CMFCRibbonEdit
....
// Delete worker thread
//worker_ = std::thread([&] {
....
// Setup Timer by 100ms
SetTimer(TEST_TIMER_ID, 100, NULL);
return 0;
}
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx)
ON_WM_CREATE()
ON_WM_SETFOCUS()
ON_WM_TIMER()
END_MESSAGE_MAP()
void CMainFrame::OnTimer(UINT_PTR nIDEvent)
{
if (nIDEvent == TEST_TIMER_ID)
{
count_ += 0.1f;
CString str;
str.Format(L"%f", count_);
pEdit_->SetEditText(str);
}
CFrameWndEx::OnTimer(nIDEvent);
}
KillTimer
is not doing anything because by that time the window handle is destroyed, and the timers are automatically destroyed by OS. You can skipKillTimer
if the timer is required throughout the process.
– Barmak Shemirani
Nov 25 '18 at 16:08
I update my answer. Thank you, Barmak Shemirani!
– Evan.Titer
Nov 26 '18 at 14:18
add a comment |
Success!
Thank you, IInspectable!
CMainFrame::~CMainFrame()
{
//KillTimer(TEST_TIMER_ID);
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
....
// Create CMFCRibbonEdit
....
// Delete worker thread
//worker_ = std::thread([&] {
....
// Setup Timer by 100ms
SetTimer(TEST_TIMER_ID, 100, NULL);
return 0;
}
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx)
ON_WM_CREATE()
ON_WM_SETFOCUS()
ON_WM_TIMER()
END_MESSAGE_MAP()
void CMainFrame::OnTimer(UINT_PTR nIDEvent)
{
if (nIDEvent == TEST_TIMER_ID)
{
count_ += 0.1f;
CString str;
str.Format(L"%f", count_);
pEdit_->SetEditText(str);
}
CFrameWndEx::OnTimer(nIDEvent);
}
Success!
Thank you, IInspectable!
CMainFrame::~CMainFrame()
{
//KillTimer(TEST_TIMER_ID);
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
....
// Create CMFCRibbonEdit
....
// Delete worker thread
//worker_ = std::thread([&] {
....
// Setup Timer by 100ms
SetTimer(TEST_TIMER_ID, 100, NULL);
return 0;
}
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx)
ON_WM_CREATE()
ON_WM_SETFOCUS()
ON_WM_TIMER()
END_MESSAGE_MAP()
void CMainFrame::OnTimer(UINT_PTR nIDEvent)
{
if (nIDEvent == TEST_TIMER_ID)
{
count_ += 0.1f;
CString str;
str.Format(L"%f", count_);
pEdit_->SetEditText(str);
}
CFrameWndEx::OnTimer(nIDEvent);
}
edited Nov 26 '18 at 14:17
answered Nov 25 '18 at 15:40
Evan.TiterEvan.Titer
687
687
KillTimer
is not doing anything because by that time the window handle is destroyed, and the timers are automatically destroyed by OS. You can skipKillTimer
if the timer is required throughout the process.
– Barmak Shemirani
Nov 25 '18 at 16:08
I update my answer. Thank you, Barmak Shemirani!
– Evan.Titer
Nov 26 '18 at 14:18
add a comment |
KillTimer
is not doing anything because by that time the window handle is destroyed, and the timers are automatically destroyed by OS. You can skipKillTimer
if the timer is required throughout the process.
– Barmak Shemirani
Nov 25 '18 at 16:08
I update my answer. Thank you, Barmak Shemirani!
– Evan.Titer
Nov 26 '18 at 14:18
KillTimer
is not doing anything because by that time the window handle is destroyed, and the timers are automatically destroyed by OS. You can skip KillTimer
if the timer is required throughout the process.– Barmak Shemirani
Nov 25 '18 at 16:08
KillTimer
is not doing anything because by that time the window handle is destroyed, and the timers are automatically destroyed by OS. You can skip KillTimer
if the timer is required throughout the process.– Barmak Shemirani
Nov 25 '18 at 16:08
I update my answer. Thank you, Barmak Shemirani!
– Evan.Titer
Nov 26 '18 at 14:18
I update my answer. Thank you, Barmak Shemirani!
– Evan.Titer
Nov 26 '18 at 14:18
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53465233%2fhow-can-i-refresh-for-ribbon-ui-at-any-time%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Set up a timer (CWnd::SetTimer) and update the UI element(s) in the timer callback. Optionally adjust the timer in the timer callback when it starts to drift and you need a more steady update rate.
– IInspectable
Nov 25 '18 at 8:50
OK. I try it. Thank you, IInspectable!
– Evan.Titer
Nov 25 '18 at 14:54