• 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

佚名通过本文主要向大家介绍了控件打开pdf出现问题,控件打开word出现问题,office控件出了点问题,mscomm控件的问题,office控件出了问题等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: 在设计控件时遇到的问题
描述:

我刚做了一个控件,遇到了一个麻烦:就是在IDE设计时设定的值在运行时却不存在了(明明在设计时指定了相关属性,可程序一运行,又回到了控件的最初状态)。不知如何解决,请大家帮帮忙~!


解决方案1:

Persistence.
COleObject uses DoPropExchange instead of Serialize. 
DoPropExchange uses Macros such as PX_STRING and PX_FLOAT to store and retrieve data from a source. This is fine for simple data types, but is far less powerful than the Serialize method, which allows us to delegate persistence down to self-contained units. Clearly this presents a problem if our ActiveX control contains child windows as described above.
In theory we should be able to use the PX_BLOB macro to persist these objects as a stream of binary data. There is what appears to be an example of this at Article ID: Q141274, in the Microsoft Knowledge Base, but the example does not work and after much fiddling I have not been able to fix it.
The alternative is to extract the properties from the Child Windows and persist those properties. In some more complicated situations this may be unsatisfactory, in which case you should try as I have to persist using normal serialization. Please contact me if you succeed.
Persisting Child Window Properties:
You must extract the properties into simple data types in order to use them in the PX macro. For this purpose you should add some member variables to your control's class. Don't forget to set default values for these variables in the constructor.
Because the DoPropExchange method is called before the OnCreate method, you must make some changes to ensure that you do not attempt to extract or set these properties before the Child Windows have been Created. Do this by adding a Boolean flag member variable which is set to false in the constructor, tested before Creating child windows, and set to true after Creating child windows.
You should create a member function which sets the child window properties then sets the boolean to true.
You should call this function in the OnCreate function so that, when OnCreate is called after DoPropExchange has loaded a new Control, the loaded values will be used.
You should also test this Boolean flag in DoPropExchange before extracting the child window properties and before setting them.
e.g.
   
void CExampleCtrl::DoPropExchange(CPropExchange* pPX)
{
    ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
     COleControl::DoPropExchange(pPX);
   
     if(m_bChildWindowsCreated) {
          m_Edit.GetWindowText(m_EditPXString);
     }
     PX_String(pPX, _T("EditText"), m_EditPXString, _T(""));
     if(m_bChildWindowsCreated) {
          SetChildWindowsProperties();
     }
}


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

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

  • 关于cabarc打包atl控件的问题,郁闷中~~~
  • 一个控件问题,请高手指教,在线等待
  • 控件有时不显示(一个奇怪的问题)
  • 怪问题,控件HTTP上传方法执行1,3,5,7次成功,第2,4,6,8次失败
  • 在控件中使用控件遇到的问题!
  • 控件注册的问题,在线等待,up有分呀
  • 控件调用控件问题
  • 控件应用的问题,很重要也很容易被忽略,您遇到过吗??
  • 关于外部控件的问题?
  • MFCActiveX控件中GetIDispatch的问题

相关文章

  • 2017-06-04 和简单的数据类型问题
  • 2017-06-05 我的主程序杀死子线程的问题,高手看看。。。。。。。
  • 2017-06-04 请教:已知一个ActiveX控件的CLSID,如何知道该控件是否已经安装?
  • 2017-06-04 问一个很菜的问题,OCX怎么注册,它的路径怎么写
  • 2017-06-04 捕获ie事件一问
  • 2017-06-05 简单问题求助:请问如何建立一个service的程序?
  • 2017-06-05 Word中插入透明的ActiveX控件刷新问题
  • 2017-06-04 新增com接口方法,当客户端调用时返回异常
  • 2017-06-04 com组件注册问题
  • 2017-06-05 在Degug下单步调试一线程类,结束的时候在该线程类中调用AfxEndThread0,结果就运行不下去,不知为什么?

文章分类

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

最近更新的内容

    • ActiveX属性的问题多了个list
    • 不用MFC类,而且在ATL使用宽字符串,如何将一个字符串中所有出现单引号替换为两个单引号!
    • IE调用OCX的问题,出现错误报告
    • 谁能帮忙解释一下这段特殊的VC代码
    • 关于activex控件的更踪调试
    • 请问那里有vc关于串行通讯的编程资料?
    • 请问一个Ocx的问题
    • dll如何得到主应用程序的当前路径?
    • ActiveX+Wmin权限问题
    • ATL作的COM中,对XML数据进行解析问题!恳请高手指点!

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

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