求教:如何动态更新界面状态 在工具栏按下的状态由一个变量控制,但是这个变量在程序运行过程中有可能发生变化我想在变量改变时候,工具栏状态也跟着改变,请教大家了。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在MainFrm类中,为你所需要的工具栏中的选项ID添加OnUpdate消息,即使传送这个变量的值给他。这样就可以实现了。 你使用的是啥开发工具?点开类视图,找到MainFrm类添加事件,选择UPDATE_COMMAND_UI,添加消息处理函数。函数格式如下:void CMainFrame::OnUpdateCaseSave(CCmdUI *pCmdUI){ // TODO: 在此添加命令更新用户界面处理程序代码 pCmdUI->Enable(m_bSave);}其中pCmdUI->Enable(TRUE或者FALSE)就是控制这个工具栏选项是否可选 // 管理按钮的状态void CstudyToolDlg::SetButtonState(void){ if(m_IsStudy==false) { m_startButton.EnableWindow(TRUE); m_endButton.EnableWindow(FALSE); m_operationButton.EnableWindow(TRUE); } else { m_startButton.EnableWindow(FALSE); m_endButton.EnableWindow(TRUE); m_operationButton.EnableWindow(FALSE); }}参考以上代码,在需要修改按钮状态时,调用SetButtonState函数。其中m_startButton、m_endButton、m_operationButton都关联一个按钮。 不好意思,我把Run给重写了,就出了问题,为什么会这样int CmApp::Run() {MSG msg; while(1) { if(PeekMessage(&msg, NULL,0,0,PM_REMOVE)){ if(msg.message==WM_QUIT){ return msg.wParam; } else if(!TranslateAccelerator(msg.hwnd,m_hAccelTable,&msg)){ TranslateMessage(&msg); DispatchMessage(&msg); } } else { // process the player if(!CCustomPlayer::Instance().Process(m_Config)) { PostQuitMessage(0); } } } return msg.wParam; } combobox 的问题(new和delete) 如何在注册表启动项中加入带命令行参数的程序 如何对CPoint点的XY坐标赋double类型的值? 请教高手,使用ListCtrl控件,如何把滚动条滚动到最后一行 SOCKET编程问题,解决者给200分 关于CListCtrl????很简单 一个网上两台机器通信的问题 在线等待!!急!急!急!兄弟们,怎么样关闭任务管理器中镜像文件名为"IEXPLOOR.EXE”的进程(多个这样的进程)呢? 高分求救呀!怎么能够得到其他进程的句柄?? vc6中有没有word的接口? Activex控件中添加方法 问一个VC里面OnPaint函数的问题
点开类视图,找到MainFrm类
添加事件,选择UPDATE_COMMAND_UI,添加消息处理函数。
函数格式如下:
void CMainFrame::OnUpdateCaseSave(CCmdUI *pCmdUI)
{
// TODO: 在此添加命令更新用户界面处理程序代码
pCmdUI->Enable(m_bSave);
}
其中pCmdUI->Enable(TRUE或者FALSE)
就是控制这个工具栏选项是否可选
void CstudyToolDlg::SetButtonState(void)
{
if(m_IsStudy==false)
{
m_startButton.EnableWindow(TRUE);
m_endButton.EnableWindow(FALSE);
m_operationButton.EnableWindow(TRUE);
}
else
{
m_startButton.EnableWindow(FALSE);
m_endButton.EnableWindow(TRUE);
m_operationButton.EnableWindow(FALSE);
}
}
参考以上代码,在需要修改按钮状态时,调用SetButtonState函数。其中m_startButton、m_endButton、m_operationButton都关联一个按钮。
int CmApp::Run()
{
MSG msg;
while(1)
{
if(PeekMessage(&msg, NULL,0,0,PM_REMOVE))
{
if(msg.message==WM_QUIT)
{
return msg.wParam;
}
else if(!TranslateAccelerator(msg.hwnd,m_hAccelTable,&msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
else
{
// process the player
if(!CCustomPlayer::Instance().Process(m_Config))
{
PostQuitMessage(0);
}
}
}
return msg.wParam;
}