如何在Devexpress中使用代码折叠/展开功能区? [英] How to collapse/expand ribbon using code in Devexpress?

查看:669
本文介绍了如何在Devexpress中使用代码折叠/展开功能区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用DevX的Ribbon接口构建csharp应用程序,并且在通过代码折叠/扩展Ribbon控件时遇到麻烦,看来我们只能通过单击折叠/扩展"按钮来做到这一点.您能否给我一些有关如何通过代码实现该想法的想法?我已经使用Google搜索了几个小时而没有找到任何内容.
非常感谢!

I am building a csharp application using Ribbon Interface of DevX and I have a trouble with collapsing/expanding the Ribbon control by code, it seems that we can only do that by clicking on the Collapse/Expand button. Could you please give me some idea on how to achieve that by code? I have searched using Google for hours without finding anything.
Thank you so much!

推荐答案

RibbonControl.Minimized = true ???????? oO
what about RibbonControl.Minimized = true ????? oO


再一次,我为自己找到了解决方案!

我已经尝试了多种方法来实现自己想要的目标,但这确实并不简单.
最后,我必须使用PostMessageWM_LBUTTONDOWNWM_LBUTTONUP消息发送到要单击的点(此点必须在展开/折叠"按钮的区域内).这个小按钮没有任何所谓的HANDLE,但是它属于功能区控件.如果有手柄,我可以使用代码更轻松地单击它.现在,我们所需要做的就是计算该按钮区域内的点.我已经尝试过了,并且效果很好,但是不确定是否有任何情况不起作用.

代码如下:
声明WinAPI函数WindowFromPointGetWindowRectPostMessage后:
Once again, I have found the solution for myself!

I have tried many ways to achieve what I want but it was really not simple.
At last, I had to use PostMessage to send WM_LBUTTONDOWN and WM_LBUTTONUP messages to the point I want to click (this point must be within the region of Expand/Collapse button). This small button doesn''t have any so-called HANDLE, but it is belong to ribbon control. If it had a handle, I could make a click on it using code more easily. Now, all we need is to calculate the point which is within that button''s region. I have tried this and it works well, but not sure if there may be any case it doesn''t work.

Here''s the code:
After declaring the WinAPI functions WindowFromPoint, GetWindowRect, PostMessage:
int x = ribbon.Width - 10;
IntPtr h = WindowFromPoint(Left + 1, Top + 1);
RECT rect;
GetWindowRect(h, out rect);
int y = rect.bottom - rect.top - 5;
PostMessage(ribbon.Handle, 0x201, 0, x + (y <<16));
PostMessage(ribbon.Handle, 0x202, 0, x + (y <<16));

只需单击展开/使用代码折叠按钮.当然,如果它是不可见的,我仍然不知道该怎么做.

That''s all to click on the Expand/ Collapse button using code. Of course if it''s invisible, I have still not found out how to do.


通过设置Ribbon.Minimized = true,您可以折叠分类目录


公共无效CollapseMenu()
{
Ribbon.Minimized = true;
}
By setting Ribbon.Minimized = true you can collapse the cattogary


Public void CollapseMenu()
{
Ribbon.Minimized = true ;
}


这篇关于如何在Devexpress中使用代码折叠/展开功能区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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