• 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

佚名通过本文主要向大家介绍了ntko控件安装方法,自定义控件方法,人脸识别控件安装方法,建立控件数组的方法,建立控件数组的方法有等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: ~~(急!)在控件方法中如何相控件自身发送消息?~~
描述:

我需要在控件的一个方法中向控件自身发送WM_DRAWITEM消息 调用OnDraw 但是我不知道该控件的句柄 请问 如何在ATL编写的控件中向控件自身发送消息? 也就是如何获取控件的句柄?
还有 在创建ATL的向导里 Miscellaneous页中 Windowed Only 这个选项 有什么作用? 书上说可以提供HWND 但是我不知道如何获取!


解决方案1:

都有
class your_Miscellaneous : 
public CAxDialogImpl<CSBaseCodeEdit>,
.........
CAxDialogImpl derives from CDialogImplBaseT, which in turn derives from TBase (by default, CWindow) and CMessageMap.
class ATL_NO_VTABLE your_Ctl :
public CComObjectRootEx<CComSingleThreadModel>,
public CStockPropImpl<CPolyCtl, IPolyCtl, &IID_IPolyCtl, &LIBID_POLYGONLib>,
public CComControl<your_Ctl>,
........
CComControl is a set of useful control helper functions and essential data members for ATL controls. When you create a standard control or a DHTML control using the ATL Control Wizard, the wizard will automatically derive your class from CComControl. CComControl derives most of its methods from CComControlBase.
 ATL Library Reference   
CComControlBase::FireViewChangeSee Also
CComControlBase Overview | Class Members
Call this method to tell the container to redraw the control, or notify the registered advise sinks that the control's view has changed.
HRESULT FireViewChange( );
Return Value
One of the standard HRESULT values.
Remarks
If the control is active (the control class data member CComControlBase::m_bInPlaceActive is TRUE), notifies the container that you want to redraw the entire control. If the control is inactive, notifies the control's registered advise sinks (through the control class data member CComControlBase::m_spAdviseSink) that the control's view has changed.
Example
STDMETHODIMP CSomeCtrl::put_Shape(short newVal)
{
   // store newVal in m_nShape user-defined member
   m_nShape = newVal;
   // notify container to redraw control
   FireViewChange();
   return S_OK;
}
See Also
CComControlBase Overview | Class Members
--------------------------------------------------------------------------------
Send feedback on this topic to Microsoft
&copy; Microsoft Corporation. All rights reserved.

解决方案2:

1. FireViewChange()
2.
CWindow::operator HWND
operator HWND( ) const;
Remarks
Converts a CWindow object to an HWND.
CWindow Overview |  Class Members

解决方案3:

你的控件没有m_hWnd吗?这个就是hwnd

解决方案4:

::m_hWnd就直接可用,可以在方法中直接调用::FireViewChange()来让OnDraw()重绘


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

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

  • MFCActiveX控件的对外方法,在接收到非法参数时,怎样报错
  • 求助,关于控件返回方法?
  • ~~(急!)在控件方法中如何相控件自身发送消息?~~

相关文章

  • 2017-06-04 哪些服务器支持CORBA,有没有免费的?
  • 2017-06-04 CFileDialog的问题
  • 2017-06-04 如何让OCX控件包含另外一个控件
  • 2017-06-05 vs2010位图的加载
  • 2017-06-05 VC6+GE6SetCamera异常,实在不知道问题在哪里?
  • 2017-06-04 240分求组件的一些简单使用方法,有关NetMeetingSDKCOM的,关键时刻了,赶程序啊,这也是全部家底了
  • 2017-06-04 请问我的主窗口怎么知道控件被移动了?
  • 2017-06-05 特急请问如何屏蔽这个消息???
  • 2017-06-05 如何枚举系统所有进程的执行文件的详细路径?
  • 2017-06-04 VB编的Com组件在ASP环境下与在应用程序下使用的问题

文章分类

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

最近更新的内容

    • 老问题还未解决,帮忙啊!!!
    • 请教两个COM的基本问题
    • 扩展dll想获得调用它的exe的句柄应该怎么取?谢!
    • 请教一个比较普通的问题:如何获得服务管理器中所有服务列表
    • 把程序改成DLL问题分析
    • 为什么Vc写的dll库在vc下好用,在delphi下不能用?
    • 这样的要求,使用进程间内存共享能作到吗,高手指点
    • 可以用程序来设置DCOM的访问权限和启用激活权限,并添加用户吗
    • ADO连接在系统自动时出错
    • 大家好,为什么我win7上的mfc程序在xp运行就特别卡

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

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