子窗口到父窗口的通知问题 [英] Child window to parent window notification problem

查看:87
本文介绍了子窗口到父窗口的通知问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.
我上课:

Hi all.
I have a class:

CMyClass : public CWnd
{
...
HWND		m_hImageWindow;
CBitmapButton   m_HelpButton;

afx_msg void OnHelpBtnClick();
afx_msg LONG OnPictureClick( WPARAM wParam, LPARAM lParam );
afx_msg void OnTimer( unsigned int id ) ;
...
}
...
BEGIN_MESSAGE_MAP(CMyClass, CWnd)
...
  ON_WM_TIMER()
  ON_BN_CLICKED( 1, OnHelpBtnClick )
//How can I implement the message handler for the window I created in 
OnTimer function? the fiollowing line does not work
  ON_MESSAGE(MESSAGE_ID, OnPictureClick) 
...
END_MESSAGE_MAP()

...
afx_msg int CMyClass::OnCreate( LPCREATESTRUCT )
{
  RECT rc;
  SetRect( &rc, 100, 100, 120, 120 );
  m_HelpButton.Create( 0, WS_VISIBLE | BS_OWNERDRAW, rc, this, 2 );
  m_HelpButton.LoadBitmaps( IDB_BITMAP2, IDB_BITMAP3 );
}

afx_msg void CMyClass::OnTimer( unsigned int id )
{
  if( m_hImageWindow )
  {
	  ::DestroyWindow( m_hImageWindow );
	  m_hImageWindow = NULL;
  }

  void* init = GetProcAddress( LoadLibrary( "atl" ), "AtlAxWinInit" );
  _asm call init;
  m_hImageWindow = CreateWindow( "AtlAxWin", somePictureURL,
	  WS_CHILDWINDOW | WS_VISIBLE, 0, 0, 100, 100,
	  this->GetSafeHwnd(), (HMENU)(UINT_PTR)MESSAGE_ID, (HINSTANCE)GetWindowLong( this->GetSafeHwnd(), GWL_HINSTANCE ), 0 );
}

afx_msg void CMyClass::OnHelpBtnClick()
{
}

afx_msg LONG OnPictureClick( WPARAM wParam, LPARAM lParam );
{
}
...



谁能告诉我如何为在OnTimer()中创建的窗口实现消息处理程序并将OnPictureClick()函数附加到此消息处理程序吗?

Nelek:只需格式化代码



Can anybody tell me how I can implement the message handler for the window I created in OnTimer() and attach to this message handler the function OnPictureClick()?

Nelek: just format code

推荐答案

bartello写道:
bartello wrote:

我如何实现我在OnTimer()中创建的窗口的消息处理程序,并将函数OnPictureClick()附加到此消息处理程序上?

how I can implement the message handler for the window I created in OnTimer() and attach to this message handler the function OnPictureClick()?



所述窗口必须向其父级发送或发布所述消息.将其菜单句柄设置为MESSAGE_ID(BTW不是真正的HMENU)无济于事:(

#include <atlwin.h>声明class MyWind : public ATL::CWindowImpl<MyWind, ATL::CAxWindow>并在那里处理WM_LBUTTONUP:GetParent().SendMessage(MESSAGE_ID);

欢呼声,
AR



The said window MUST Send or Post the said message to it''s parent. Setting it''s menu handle to MESSAGE_ID (which BTW is not a real HMENU) does not help :(

#include <atlwin.h> declare a class MyWind : public ATL::CWindowImpl<MyWind, ATL::CAxWindow> and handle there WM_LBUTTONUP: GetParent().SendMessage(MESSAGE_ID);

cheers,
AR


我认为您要查找的消息是
I think the message you''re looking for is WM_PARENTNOTIFY[^]


这篇关于子窗口到父窗口的通知问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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