如何在应用程序中添加BCGControlBar的Ribbon控件

如何在应用程序中添加BCGControlBar的Ribbon控件,第1张

本文分步介绍了如何在应用程序中添加BCGControlBar的Ribbon控件,并且附源码。

1、打开MainFrme.h,移除CBCGPMenuBar、 m_wndMenuBar、CBCGPToolBar、 m_wndToolBar。

2、对Ribbon Bar和主要的 Ribbon Button添加自定义。

1

2

CBCGPRibbonBar m_wndRibbonBar

CBCGPRibbonMainButton m_MainButton

3、添加定义面板图像列表。

1

CBCGPToolBarImages m_PanelIcons

4、打开MainFrm.cpp,移除m_wndMenuBar 和m_wndToolBar有关的东西。

5、对源添加一个Ribbon Main Button(IDB_MAIN)26X26像素的位图,小图标(16像素高度)的位图列表以及大图标(32像素高度)位图列表,并将他们命名为IDB_SMALL_ICONS和IDB_LARGE_ICONS respectively。

6、在CMainFrame::OnCreate中创建Ribbon Bar:

1

m_wndRibbonBar.Create (this)

7、初始化和设置主要的Ribbon Button:

1

2

3

4

m_MainButton.SetMenu (IDR_FILE_MENU)

m_MainButton.SetImage (IDB_MAIN)

m_MainButton.SetToolTipText (_T("File"))

m_wndRibbonBar.SetMainButton (&m_MainButton, CSize (45, 45))

8、初始化和加载面板图标的图像列表。

1

2

m_PanelIcons.SetImageSize (CSize (16, 16))

m_PanelIcons.Load (IDB_PANEL_ICONS)

9、添加第一类:

1

2

3

4

CBCGPRibbonCategory* pCategory = m_wndRibbonBar.AddCategory

(_T("&Write"), // Category name

IDB_WRITE, // Category small images (16 x 16)

IDB_WRITE_LARGE) // Category large images (32 x 32)

10、添加第一个面板到这个类别:

1

2

3

CBCGPRibbonPanel* pPanel = pCategory->AddPanel (

_T("Clipboard"), // Panel name

m_PanelIcons.ExtractIcon (0)) // Panel icon

11、添加ribbon元素到面板:

1

2

3

4

5

6

7

8

9

10

11

12

// Create the first button to Panel ("Paste"):

CBCGPRibbonButton* pPasteButton = new CBCGPRibbonButton (ID_EDIT_PASTE, _T("Paste"), -1, 0)

// The third parameter (-1) tells that this button does not have a small icon.

// Therefore the "Paste" button will be always displayed with large icon.

// Associate a popup menu with the "Paste" button:

pPasteButton->SetMenu (IDR_CONTEXT_MENU)

// Add other buttons to the panel. These buttons have small icons only:

pPanel->Add (new CBCGPRibbonButton (ID_EDIT_CUT, _T("Cut"), 1))

pPanel->Add (new CBCGPRibbonButton (ID_EDIT_COPY, _T("Copy"), 2))

pPanel->Add (new CBCGPRibbonButton (ID_EDIT_PAINT, _T("Paint"), 9))

spring cloud ribbon 是一个基于http和TCP客户度负载均衡工具,它基于Netflix Ribbon实现。通过Spring Cloud的封装,可以让我们轻松地将面向服务的REST模版请求自动转换成客户端负载均衡的服务调用。

负载均衡有两种,一般是服务器负载均衡,分为硬件负载均衡和软件负载均衡.

硬件负载均衡是用于服务器节点之间的负载均衡设备

软件负载均衡是通过在服务器上安装一些负载均衡的软件,来完成一些请求分发的工作,例如我们现在用的Nginx

创建一个spring boot的工程,然后勾选上

添加配置文件

在启动类上添加

我们需要使用对象RestTemplate。该对象会使用Ribbon的自动化配置,同时通过配置@LoadBalanced开启客户端负载均衡。

编写一个测试类,注入template

启动两个producer

可以在注册中心看到

▪️ getForEntity(String url, Class responseType,Object... urlVariables);

▪️ getForEntity(String url, Class responseType, Map urlVariables)

▪️ getForEntity(URI url, Class responseType)

RestTemplate restTemplate = new RestTemplate()

String result = restTemplate.getForObject(uri, String.class)

RestTemplate restTemplate = new RestTemplate()

User result = restTemplate.getForObject(uri, User.class)

▪️ getForObject(String url, Class responseType, Object ... urlVariables)

▪️ getForObject(String url, Class responseType, Map urlVariables)

▪️ getForObject(URI url, Class responseType)

▪️ 第一种:postForEntity函数。

postForEntity函数也实现了三种不同的重载方法。

▪️ postForEntity(String url, Object request, Class responseType, Object... uriVariables)

▪️ postForEntity(String url, Object request, Class responseType, Map uriVariables)

▪️ postForEntity(URI url, Object request, Class responseType)

▪️ 第二种:postForObject函数。

postForObject函数也实现了三种不同的重载方法:

▪️ postForObject(String url, Object request, Class responseType, Object... uriVariables)

▪️ postForObject(String url, Object request, Class responseType, Map uriVariables)

▪️ postForObject(URI url, Object request, Class responseType)

▪️ 第三种:postForLocation函数。

▪️ postForLocation(String url, Object request, Object... uriVariables)

▪️ postForLocation(String url, Object request, Map uriVariables)

▪️ postForLocation(URI url, Object request)

由于postForLocation函数会返回新资源的URI,该URI就相当于指定了返回类型,所以此方法实现的POST请求不需要像postForEntity和postForObject那样指定responseType。其他的参数用法相同。

参考文章: https://www.jianshu.com/p/1bd66db5dc46

excel ribbon菜单的创建:

首先创建一个VSTO程序,如图在VS中创建一个Excel外接程序:

然后接下来,添加项,添加一个Ribbon菜单:

在创建菜单之前,需要明确我们的插件具有哪些模块。这里为了演示如何创建菜单以及后面的功能点,我们的插件打算做四个功能点。 首先是财经模块,包括从一些开放的财经API如新浪财经API,雅虎API中获取实时或者历史行情数据;地图模块,包括地图显示,地址检索,专题制图等;天气模块,获取天气,天气保表;系统模块,包括登录,帮助,关于模块等。确定好功能点之后,就可以开始创建菜单了。

添加了Ribbon菜单之后,就可以打开ToolBox开始设计了,如下图。下面介绍各个菜单项的功能及设计要点。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/11387877.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-15
下一篇2023-05-15

发表评论

登录后才能评论

评论列表(0条)

    保存