显示-以编程方式隐藏状态栏 [英] Show - Hide Status Bar Programmatically

查看:102
本文介绍了显示-以编程方式隐藏状态栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对象:以编程方式显示或隐藏状态栏.

按照惯例,大型机(MF)由Visual Studio 10向导作为Doc/View应用程序创建为CFrameWndEx类.

状态栏(SB)是从CFrameWndEx类的OnCreate消息创建的.

***** CFrameWndEx.h *****

Object: To show or hide the Status Bar programmatically.

The mainframe (MF) is created conventionally as CFrameWndEx class by Visual Studio 10 wizard as a Doc/View application.

The status bar (SB) is created from the OnCreate message of CFrameWndEx class.

***** CFrameWndEx.h *****

#define SB_STYLE        WS_CHILD | CBRS_BOTTOM | CBRS_TOOLTIPS | CBRS_FLYBY | WS_VISIBLE
#define SB_STYLE_EX     WS_EX_CLIENTEDGE
CMFCStatusBar*   p_SBCls;



***** CFrameWndEx.cpp *****



***** CFrameWndEx.cpp *****

p_SBCls = new CJBK_III_SB;
ASSERT(p_SBCls->CreateEx(this, SB_STYLE_EX, SB_STYLE, nID)); 

The SB is toggled in CFrameWndEx class by:

b_Flag = p_RegCls->m_bGetRegFlag(ID_REGKEY_Item_SB, KEY_READ); //ID_REGKEY_Item_SB == nID

if (b_Flag)            
  p_SBCls->ShowWindow(SW_SHOW);  
else
  p_SBCls->ShowWindow(SW_HIDE); 
        
p_SBCls->Invalidate(TRUE);
p_SBCls->UpdateWindow();


切换标志b_Flag存储在注册表中,并由RibbonBar中的复选框设置;它是由m_bGetRegFlag(...)检索的.当复选框处于选中状态(或未选中)以及从主框架类创建状态栏之后,将调用切换代码(上方).

上面的方法可以正常工作,并且SB可以根据需要显示或隐藏.问题出在创建应用程序时,将b_Flag检索为TRUE,然后尝试通过选中功能区栏上的复选框来隐藏状态栏. p_SCBls-> IsVisible()== FALSE,但状态栏仍然可见.

如果将鼠标移到CFrameWndEx的框架上并单击鼠标左键,SB将消失.单击更多复选框不会执行任何操作.如果应用程序以b_Flag == FALSE打开,则一切都会按要求进行.我不确定是什么原因造成的,但是我感觉到必须重新绘制主框架或SB区域才能重新绘制CFrameWndEx以重新绘制和擦除状态栏.

任何输入将不胜感激.

谢谢,

Barry


where the toggle flag, b_Flag, is stored in the registry and set by a check box in the RibbonBar; it is retrieved by m_bGetRegFlag(…). The toggle code (above) is called when either the check box is checked (or unchecked) and after the Status Bar is created from the main frame class.

The above works and the SB toggles as shown or hidden as required. The problem comes about when the application is created, the b_Flag is retrieved as TRUE and one attempts to hide the Status Bar by checking the checkbox on the Ribbon Bar. p_SCBls->IsVisible() == FALSE but the Status Bar is still visible.

If I move the mouse over the frame of CFrameWndEx and left click, the SB disappears. More check box clicking does nothing. If the application opens with b_Flag == FALSE, everything works as required. I am not sure what is causing this, however I get the feeling that I have to get the main frame or the SB region to redraw to get CFrameWndEx to redraw and erase the Status Bar.

Any input would be appreciated.

Thanks,

Barry

推荐答案

对不起,但ShowControlBar(...)似乎没有效果.但是,我确实做了一些逆向工程",发现隐藏/显示动作似乎围绕着ID_VIEW_STATUS_BAR,这是Microsoft在支持文件中提供的消息ID之一.

最终似乎将ID_VIEW_STATUS_BAR插入Windows内部消息循环和命令结构中.这比我的薪水等级还高.我想我必须设计一个自己的设计,例如停靠的对话框.

谁将CMFC .....代码放在一起,显然可以将大部分代码保留给他/她自己,而且会碰上很多麻烦!谢谢您的努力. :-)
Sorry, but ShowControlBar(...) seems to have no effect. I did, however, do some "reverse engineering" and found that the hide/show actions seem to revolve around ID_VIEW_STATUS_BAR, one of the message ID''s that Microsoft supplies in the support files.

ID_VIEW_STATUS_BAR eventually appears to get inserted in the Windows internal message loop and command structure. This is way above my pay grade. I guess I will have to design my own, on say a docked dialog box.

Whom ever put the CMFC..... code together apparently kept most of it to him/herself and cut a bunch of corners! Thanks for the effort though. :-)


我希望使用ShowControlBar() [
I expect that using ShowControlBar() [^] to show or hide the status bar will solve your problem.


这篇关于显示-以编程方式隐藏状态栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆