MFC开发基于对话框的ActiveX控件中嵌入菜单和为工具栏添加tooltip问题???本人绝对守信用。

vagabondkq 2003-06-11 05:01:16
我开始怀疑在ActiveX中实现菜单和tooltip的可行性了。
我做了基于dialog的.exe的test程序,没问题,以上两项功能都可实现。

但我把相同的代码放到我的ActiveX工程里时,编译全部通过,但出现问题:
1.tooltip部分,在ActiveX控件的toolbar上屁提示都没有。
2.menu部分,.exe中对话框的Style都是"Popup",在对话框上实现菜单也必须是Popup;而ActiveX中,想要实现对话框并可精确定位Style则必须是"Child",而这项选中Child则无法实现菜单,若这里也是"Popup"的话弹出dialog的位置根本不是你想要的。

哪位大侠也做过相同的东西?请指教。本人已经快郁闷致死,这个东西弄了好几天了:(
...全文
114 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
wbamos 2003-06-27
  • 打赏
  • 举报
回复
怎么能够加上菜单呢?
ffit 2003-06-13
  • 打赏
  • 举报
回复
再回你一次:
在.h中定义
CToolBar m_wndToolBar;
CReBar m_wndReBar;
在.Cpp的OnInitDialog()加
CImageList img;
CString str;

if (!m_wndReBar.Create(this))
{
TRACE0("Failed to create rebar\n");
return -1; // fail to create
}

if (!m_wndToolBar.CreateEx(this))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
// set up toolbar properties
m_wndToolBar.GetToolBarCtrl().SetButtonWidth(50, 150);
m_wndToolBar.GetToolBarCtrl().SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS);

img.Create(IDR_TOOLBAR1, 16, 0, RGB(255, 0, 255));
m_wndToolBar.GetToolBarCtrl().SetImageList(&img);
img.Detach();
m_wndToolBar.ModifyStyle(0, TBSTYLE_FLAT | TBSTYLE_TRANSPARENT);
m_wndToolBar.SetButtons(NULL, 13);

CRect rectToolBar;

// set up toolbar button sizes
m_wndToolBar.GetItemRect(0, &rectToolBar);
rectToolBar.bottom=2*rectToolBar.bottom-7;
m_wndToolBar.SetSizes(rectToolBar.Size(), CSize(16,15));
// set up each toolbar button
m_wndToolBar.SetButtonInfo(0, IDM_ADDUSER, TBSTYLE_BUTTON, 0);
str.LoadString(IDS_ADDUSER);
m_wndToolBar.SetButtonText(0, "s");//解决工具条显示问题
m_wndToolBar.SetButtonText(0, str);
m_wndToolBar.SetButtonInfo(1, IDM_USERMODIFY, TBSTYLE_BUTTON, 1);
str.LoadString(IDS_MODIFY);
m_wndToolBar.SetButtonText(1, str);
m_wndToolBar.SetButtonInfo(2, 0, TBBS_SEPARATOR , 2);
m_wndToolBar.SetButtonInfo(3, IDM_QUERYUSER, TBSTYLE_BUTTON, 3);
m_wndToolBar.SetButtonText(3, "用户");
m_wndToolBar.SetButtonInfo(4, IDM_QUERYFEE, TBSTYLE_BUTTON , 4);
m_wndToolBar.SetButtonText(4, "收费");
m_wndToolBar.SetButtonInfo(5, IDM_QUERYOTHER, TBSTYLE_BUTTON, 5);
m_wndToolBar.SetButtonText(5, "登录");
m_wndToolBar.SetButtonInfo(6, 0, TBBS_SEPARATOR, 6);
m_wndToolBar.SetButtonInfo(7, IDM_STATUSER, TBSTYLE_BUTTON, 7);
m_wndToolBar.SetButtonText(7, "统计");
m_wndToolBar.SetButtonInfo(8, IDM_STATFEE, TBSTYLE_BUTTON , 8);
m_wndToolBar.SetButtonText(8, "计");
m_wndToolBar.SetButtonInfo(9, 0, TBBS_SEPARATOR, 9);
m_wndToolBar.SetButtonInfo(10, IDM_PASSWORD, TBSTYLE_BUTTON, 10);
m_wndToolBar.SetButtonText(10, "密码");
m_wndToolBar.SetButtonInfo(11, IDM_ABOUT, TBSTYLE_BUTTON , 11);
m_wndToolBar.SetButtonText(11, "关于");
m_wndToolBar.SetButtonInfo(12, IDM_EXIT, TBSTYLE_BUTTON , 12);
m_wndToolBar.SetButtonText(12, "退出");


// add the toolbar, animation, and address bar to the rebar
m_wndReBar.AddBar(&m_wndToolBar,NULL,RGB(192,192,255));

// set up min/max sizes and ideal sizes for pieces of the rebar
REBARBANDINFO rbbi;

//CBitmap bmp;
//bmp.LoadBitmap(IDB_BITMAP1);

rbbi.cbSize = sizeof(rbbi);
rbbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE | RBBIM_SIZE;
rbbi.cxMinChild = rectToolBar.Width();
rbbi.cyMinChild = rectToolBar.Height();
rbbi.cx = rbbi.cxIdeal = rectToolBar.Width() * 9;
//rbbi.hbmBack=(HBITMAP)bmp;
m_wndReBar.GetReBarCtrl().SetBandInfo(0, &rbbi);

// We need to resize the dialog to make room for control bars.
// First, figure out how big the control bars are.
CRect rcClientStart;
CRect rcClientNow;
GetClientRect(rcClientStart);
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST,
0, reposQuery, rcClientNow);

// Now move all the controls so they are in the same relative
// position within the remaining client area as they would be
// with no control bars.
CPoint ptOffset(rcClientNow.left - rcClientStart.left,
rcClientNow.top - rcClientStart.top);

CRect rcChild;
CWnd* pwndChild = GetWindow(GW_CHILD);
while (pwndChild)
{
pwndChild->GetWindowRect(rcChild);
ScreenToClient(rcChild);
rcChild.OffsetRect(ptOffset);
pwndChild->MoveWindow(rcChild, FALSE);
pwndChild = pwndChild->GetNextWindow();
}

// Adjust the dialog window dimensions
CRect rcWindow;
GetWindowRect(rcWindow);
rcWindow.right += rcClientStart.Width() - rcClientNow.Width();
rcWindow.bottom += rcClientStart.Height() - rcClientNow.Height();
MoveWindow(rcWindow, FALSE);

// And position the control bars
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);

IDM_ADDUSER--------------菜单(工具条按钮)的ID号,一般用IDM开头
IDS_ADDUSER--------------字符串的ID号,在Resource的String中加,实在不行,你就直
接写"字符",一般用IDS开头,不直接写字符串的目的是如果
需要改动,只要修改资源,而不必到源程序中去改
IDM_USERMODIFY----------同上
IDS_MODIFY---------------同上
这段代码是我公司以前的系统的一部分,用的是CRebar,加了背景色,你还可以加背景图,当然,这里我删除了一些其他的东西
vagabondkq 2003-06-13
  • 打赏
  • 举报
回复
ffit(ffit):谢谢.没想到你跑到这里接分来了,呵呵。你解决了在toolbar中加文本的问题。这帖子的100分都归你了:)
vagabondkq 2003-06-12
  • 打赏
  • 举报
回复
哪位仁兄帮忙看一下啊,哪怕提点建议也成。
没有菜单我这程序实在是不好控制啊。
vagabondkq 2003-06-12
  • 打赏
  • 举报
回复
up
vagabondkq 2003-06-11
  • 打赏
  • 举报
回复
就是在.exe的dialog上实现的代码呀。
oiq 2003-06-11
  • 打赏
  • 举报
回复
你什么代码添到了ACTIVEX工程里了?不明白。
可以参考我网站上的WORD编辑控件。

http://www.dpspace.com/
新贴:一起探讨结构化存储技术

3,248

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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