Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 );
{
}
...


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
Posted
Updated 29-Jan-10 2:05am
v2

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


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
 
Share this answer
 
v2
I think the message you're looking for is WM_PARENTNOTIFY[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900