工具栏按钮变灰的一点疑问

tanwei1002 2008-11-28 04:54:28
如何我点击工具栏其中的一个按钮来控制其他按钮的是否变灰情况???

...全文
189 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
aility 2008-11-29
  • 打赏
  • 举报
回复
很多问题,有些函数,其实大家都知道,没试过就不要误人子弟哦。
tanwei1002 2008-11-29
  • 打赏
  • 举报
回复
非常感谢Tinary3v0
Tinary3v0 2008-11-29
  • 打赏
  • 举报
回复
控制工具栏按钮比较麻烦:
楼主用下面的代码应该可以:
头文件:
protected:  // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;

BOOL m_bContiune; //定义公有状态标志

void CMainFrame::OnKht2()   //禁用工具栏上"新建"和"打开"按钮
{
m_wndToolBar.GetToolBarCtrl().EnableButton( ID_FILE_NEW, FALSE );
m_wndToolBar.GetToolBarCtrl().EnableButton( ID_FILE_OPEN, FALSE );
m_wndToolBar.GetToolBarCtrl().Invalidate();

MSG msg; //定义消息

m_bContiune=TRUE; //直接在这里设定为TRUE

for(int ii=0;ii<2;ii++)
{
if( m_bContiune == TRUE ) //如果为TRUE 循环将不停止
{
ii = 0; //状态改变退出

GetMessage( &msg, NULL,0, 0 );//检查消息

TranslateMessage(&msg); //解释消息

DispatchMessage(&msg); //分配消息
}
}
}

void CMainFrame::OnKht1() ////启用工具栏上"新建"和"打开"按钮
{
m_bContiune = FALSE;
m_wndToolBar.GetToolBarCtrl().EnableButton( ID_FILE_NEW, TRUE );
m_wndToolBar.GetToolBarCtrl().EnableButton( ID_FILE_OPEN, TRUE );
m_wndToolBar.GetToolBarCtrl().Invalidate();
}


具体情况就不多解释了,楼主到这个位置去看看:http://www.rss88.com/c/163181.html
tanwei1002 2008-11-28
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 cxz1985 的回复:]
我以前有用过。。没问题啊。。
[/Quote]


怪了,我怎么行不通啊 就闪下。。。。。
莫非真是人品问题。。。。。。。。。
天啊。。。。。。。。。。
  • 打赏
  • 举报
回复
我以前有用过。。没问题啊。。
tanwei1002 2008-11-28
  • 打赏
  • 举报
回复
EnableButton 我也试了 就是只闪了下,马上又变亮了。。。。。
好奇怪哦
CToolBarCtrl *btn=(CToolBarCtrl*)&m_wndToolBar.GetToolBarCtrl();
btn->EnableButton(ID,false); //ID是我要变灰的按钮ID
yangyun1219 2008-11-28
  • 打赏
  • 举报
回复
使单选按钮变灰
GetDlgItem(IDC_RADIO1)->EnableWindow(0);
GetDlgItem(IDC_CHECK1)->EnableWindow(0);
其他按钮类似只要把其中的ID号换一下即可
wzg112 2008-11-28
  • 打赏
  • 举报
回复
让其他按钮不可用就行了
  • 打赏
  • 举报
回复
BOOL EnableButton( int nID, BOOL bEnable = TRUE );

Return Value

Nonzero if successful; otherwise zero.

Parameters

nID

Command identifier of the button to enable or disable.

bEnable

TRUE to enable the button; FALSE to disable the button.

Remarks

Call this function to enable or disable the specified button in a toolbar control. When a button has been enabled, it can be pressed and checked. If you want to change more than one button state, consider calling SetState instead。
  • 打赏
  • 举报
回复
CToolBarCtrl::EnableButton

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧