• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >vc/mfc > 请问:怎样才能弹出一个默认的属性单对话框?

请问:怎样才能弹出一个默认的属性单对话框?

作者:佚名 字体:[增加 减小] 来源:互联网 时间:2017-06-04

佚名通过本文主要向大家介绍了请问买家具去哪里,请问家具品牌,请问 痔疮怎么,请问您今天要来点兔子,请问430是不锈钢吗等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: 请问:怎样才能弹出一个默认的属性单对话框?
描述:

在进行ActiveX开发时,会用到属性页,你可以自己添加系统属性页也可以自己定制属性页,这些属性页都是添加在属性单(CPropertySheet)上的。我的问题是,怎样才能在控件运行的时候,也可以把属性单显示出来。就是想知道控件默认的属性单是什么?谢谢,那位大虾可以告知小弟~~


解决方案1:

我在一个网站让发现的,给你贴过来,试试看
Can I display my control's property page at run-time? 
Original Question:
We would like our OCX end users to be able to pop up the design-time OLE property page at run-time, as well. I tried a quick hack to make this happen: 
1) I trapped the right-button mouse click
2) In the mouse-click message handler, I invoked COleControl::OnProperties(0, NULL, NULL) 
This worked OK, except 
a) The Property page was modeless, rather than modal
b) because of (a), I was able to popup several copies of the property page!
c) The property page sometimes would eat the first (activating) mouse click before it would respond. 
Now, Visual Basic pops up the properties in a modal way ... is there any way for me to get Visual Basic (or the container, in general) to display the properties at run-time as it does at design time? 
Answer:
I did a little research on your problem and here's what I've come up with. 
According to the documentation for IOleControlSite, if a control wants to display a property sheet, it must first ask the container to do it, something like this: 
   m_pControlSite->ShowPropertyFrame();
This is basically because the container may have an extended control and so would possibly like to add its property pages to those of the control. So, a control should call IOleControlSite::ShowPropertyFrame if it wants to display its property pages. This will allow the container to "handle" the property sheet. If the call returns E_NOTIMPL, then the control must perform the work itself. But, if it returns S_OK, then the container has successfully displayed it and everything should be just fine. This is exactly what COleControl::OnProperties does. You would expect then that all you need to do is call OnProperties from your control when you want to display its property pages. Well, as you've noticed, at least in Visual Basic anyway, the container shows the property sheet modeless. It also allows multiple instances of the property sheet. 
To solve the problem, I just cut the code from COleControl::OnProperties and placed in the OnRButtonDown handler and everything seemed to work. It may not be the "recommended way", but it works. I've only tried it in VB though, this approach may not work in other containers (e.g. VC++). Let me know what you find out. Here's the code for OnRButtonDown. 
void CMyCtrl::OnRButtonDown( UINT nFlags, CPoint point ) 
{
   CWnd* pWnd = GetParent();
   HWND hWndParent;
   // Various ways to get the parent window
   if ( pWnd )
      hWndParent = pWnd->GetSafeHwnd();
   else
      hWndParent = NULL;
   hWndParent = GetApplicationWindow();
  // Need to include <afxpriv.h> for this macro
  USES_CONVERSION;      
  HRESULT hr;
  LPUNKNOWN pUnk = GetIDispatch(FALSE);
  CWnd* pWndOwner = CWnd::GetSafeOwner(CWnd::FromHandle(hWndParent));
  HWND hWndOwner = pWndOwner->GetSafeHwnd();
  LCID lcid = AmbientLocaleID();
  ULONG cPropPages;
  LPCLSID pclsidPropPages = GetPropPageIDs(cPropPages);
 
  RECT rectParent;
  RECT rectTop;
  ::GetWindowRect(hWndParent, &rectParent);
  ::GetWindowRect(hWndOwner, &rectTop);
  TCHAR szUserType[256];
  GetUserType(szUserType);
  // Display the property page modally
  PreModalDialog(hWndOwner);
  hr = OleCreatePropertyFrame(hWndOwner, rectParent.left - rectTop.left,
         rectParent.top - rectTop.top, T2COLE(szUserType), 1, &pUnk,
         cPropPages, pclsidPropPages, lcid, NULL, 0);
  PostModalDialog(hWndOwner);

解决方案2:

说到属性单,俺也不熟啊!
不过属性页也是一个COM对象,一般来说在设计时由编译器提供一个表单来放置,设计时是指使用这个控件来进行开发的时候;
你的“在控件运行的时候,也可以把属性单显示出来”的意思如果是指已经开发完运行时的话,就需要显示这样的属性页需要你自己装载属性页对象了。
不过这有意义吗?属性页的工作是简化控件设计时的工作量,不是在运行时来改控件属性的。


分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • 急救:请问怎样可以用鼠标获取IE中frame里的图片
  • 请问注册dll时,注册表中的?表示什么?
  • 请问如何用代码改变EXCEL某一单元格的颜色?
  • 请问如何在Word中插入图片?
  • 请问有人知道在vc里面如何实现vb的集合对象
  • 请问,怎样才能用c实现com?在很多书上都是用c++。
  • 请问如何获取本机IIS所有网站的本地路径?
  • 请问能在不关闭网页的情况下卸载ATL控件吗?
  • 请问哪里有嵌入IE后性能较好的树控件?
  • 请问在VC下如何修改IE控件的背景颜色?

相关文章

  • 2017-06-05 PrintDlgEx打印设置对话框如何实现不连续的页码打印
  • 2017-06-04 请问各位大侠及lop5712LOP大侠一下,还是关于动态生成浏览器的问题
  • 2017-06-04 关于mfc类库
  • 2017-06-04 用MFC实现OLEDBConsumer的问题
  • 2017-06-04 vc6和vc7在activex的使用上有什么区别?
  • 2017-06-04 vcmatlab混合编程
  • 2017-06-04 给点建议:-----关于结构体的定义
  • 2017-06-05 2000下如何屏蔽三键和按??
  • 2017-06-05 做了一个监视线程消息的钩子函数,设置为系统钩子时可运行,但设置为线程钩子则无法运行,不知道为什么?
  • 2017-06-05 comdll生成的_ic文件怎么用法?

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • 请问COM问题:有谁用过ActiveX中的IFont接口?
    • 怎么才能各普通的IE浏览器功能一样?
    • 关于深入浅出MFC中,多线程的问题
    • 一个wordCom插件,注册了以后,删除dll后,无法卸载了吗?
    • 控件与浏览器移动的问题
    • 急!ATL与MFC的问题----高手请进!!!
    • 怎样在inf文件里面指定安装目录没分了,帮下忙:)
    • 怎么在自己做的浏览器上集成Google工具栏
    • 请问一个vc调用excel的问题:向excel中添加了数据后保存时怎样弹出提示框?
    • 请问:WINDOWS是如何启动某个程序的?

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有