MFC:CDialog工具栏中的EditBox [英] MFC: EditBox in Toolbar of CDialog

查看:80
本文介绍了MFC:CDialog工具栏中的EditBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

在MFC / C ++应用程序中我需要创建一个对话框,其中包含本地菜单和工具栏。

in an MFC/C++ applikation I need to create a dialog, which has local Menue and Toolbar.

Menue和Toolbar我已经解决了;似乎工作100%

Menue and Toolbar I have solved already; seems to work 100%

此外,我需要用EditBox替换虚拟按钮。有这个我有问题。

Additionally I need to replace a dummy button with an EditBox. With this I have issues.

工具栏中的虚拟按钮消失,但没有可见的EditBox。

The dummy button in the toolbar disappears, but there is no EditBox visible.

这是我的代码。我的所有初始化都位于OnInitDialog()

Here is my code. All my initialisation is located in OnInitDialog()

//-------------------------
// .h:

	CMFCToolBar m_ToolBar;
	CMFCToolBarEditBoxButton* m_pEditBtnFrom;


//-----------
// .cpp :

BOOL CDlgDiagCCLink::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// Toolbar
	if (m_ToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, 100))
	{
		m_ToolBar.SetPaneStyle(m_ToolBar.GetPaneStyle()
			& ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_ANY));

		m_ToolBar.LoadToolBar(IDR_TOOLBAR_DIAG_CCLINK, 0, 0, TRUE /* Ist gesperrt */);

		CSize   sizeToolBar = m_ToolBar.CalcFixedLayout(FALSE, TRUE);
		m_ToolBar.SetWindowPos(NULL, 0, 0, sizeToolBar.cx, sizeToolBar.cy,
			SWP_NOACTIVATE | SWP_NOZORDER);
		m_ToolBar.SetOwner(this);
		m_ToolBar.SetRouteCommandsViaFrame(FALSE);

		// Toolbar Edit Box, replace dummy button

		CMFCToolBarEditBoxButton editBox(
			ID_SEARCH_SEARCHCHANGES_FROM,
			GetCmdMgr()->GetCmdImage(ID_SEARCH_SEARCHCHANGES_FROM, FALSE));
		editBox.SetContents(_T("0"));
		m_ToolBar.ReplaceButton(ID_SEARCH_SEARCHCHANGES_FROM, editBox);

		CMFCToolBarEditBoxButton* m_pEditBtnFrom = dynamic_cast<CMFCToolBarEditBoxButton*>
			(m_ToolBar.GetButton(m_ToolBar.CommandToIndex(ID_SEARCH_SEARCHCHANGES_FROM)));

		if (m_pEditBtnFrom == nullptr) 
		{
			AfxMessageBox(_T("failed to create EditBox"), MB_ICONERROR | MB_OK);
		}
		m_pEditBtnFrom->EnableWindow();
	}
	
//	...

推荐答案

Hello  itr_rrauch,

Hello itr_rrauch,

我会将此主题移至  Visual C ++论坛获得更多专业支持。感谢您的公司。

I'll move this thread to Visual C++ forum for more professional support. Thanks for your corporation.

祝你好运,

Rita


这篇关于MFC:CDialog工具栏中的EditBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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