Activex Messages don´t work at runtime
-
Hello I´m new in developes Controls with VC++ (VS2005) When I use a activex, creating in desinger mode, the message OnLButtonUp (WM_LBUTTONUP) define in Warpper class return very well, but when I Create the activex in runtime mode, it don´t work. What is my error ? I mistake some code ? Parts of my code to better explain ..
// Test2001Dlg.h : header file
//
class CTest2001Dlg : public CDialog
{
//.....public:
CListView2 LV1; // static designer mode CListView2 \*pLV3; // Pointer to run time creation. afx\_msg void OnBnClickedButton1();
};
// Test2001Dlg.cpp
//void CTest2001Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LISTVIEWCTRL1, LV1);}
void CTest2001Dlg::OnBnClickedButton1()
{
CRect cPosition(300, 100, 400, 200);
pLV3 = new CListView2();
pLV3->Create(_T("{BDD1F04B-858B-11D1-B16A-00C0F0283628}"),NULL, WS_TABSTOP | WS_VISIBLE,cPosition,this,IDC_LISTVIEWCTRL_3,NULL);/// I Need to do something else here ???
// IDC_LISTVIEWCTRL_3 is define in resource.h
// {BDD1F04B-858B-11D1-B16A-00C0F0283628} I Take in Test2001.rc from the IDC_LISTVIEWCTRL1}
// CListView2.h : Declaration of ActiveX Control wrapper class(es) created by Microsoft Visual C++
#pragma once
/////////////////////////////////////////////////////////////////////////////
// CListView2class CListView2 : public CWnd
{//...
DECLARE\_MESSAGE\_MAP() afx\_msg void OnLButtonUp(UINT nFlags, CPoint point);
};
// CListView2.cpp : Definition of ActiveX Control wrapper class(es) created by Microsoft Visual C++
#include "stdafx.h"
#include "CListView2.h"/////////////////////////////////////////////////////////////////////////////
// CListView2IMPLEMENT_DYNCREATE(CListView2, CWnd)
// CListView2 properties
// CListView2 operations
BEGIN_MESSAGE_MAP(CListView2, CWnd)
ON_WM_LBUTTONUP()
END_MESSAGE_MAP()void CListView2::OnLButtonUp(UINT nFlags, CPoint point)
{AfxMessageBox (\_T("Clicked in CListView2::OnLButtonUp " ) , MB\_OK|MB\_ICONSTOP); CWnd::OnLButtonUp(nFlags, point);
}
thank´s
-
Hello I´m new in developes Controls with VC++ (VS2005) When I use a activex, creating in desinger mode, the message OnLButtonUp (WM_LBUTTONUP) define in Warpper class return very well, but when I Create the activex in runtime mode, it don´t work. What is my error ? I mistake some code ? Parts of my code to better explain ..
// Test2001Dlg.h : header file
//
class CTest2001Dlg : public CDialog
{
//.....public:
CListView2 LV1; // static designer mode CListView2 \*pLV3; // Pointer to run time creation. afx\_msg void OnBnClickedButton1();
};
// Test2001Dlg.cpp
//void CTest2001Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LISTVIEWCTRL1, LV1);}
void CTest2001Dlg::OnBnClickedButton1()
{
CRect cPosition(300, 100, 400, 200);
pLV3 = new CListView2();
pLV3->Create(_T("{BDD1F04B-858B-11D1-B16A-00C0F0283628}"),NULL, WS_TABSTOP | WS_VISIBLE,cPosition,this,IDC_LISTVIEWCTRL_3,NULL);/// I Need to do something else here ???
// IDC_LISTVIEWCTRL_3 is define in resource.h
// {BDD1F04B-858B-11D1-B16A-00C0F0283628} I Take in Test2001.rc from the IDC_LISTVIEWCTRL1}
// CListView2.h : Declaration of ActiveX Control wrapper class(es) created by Microsoft Visual C++
#pragma once
/////////////////////////////////////////////////////////////////////////////
// CListView2class CListView2 : public CWnd
{//...
DECLARE\_MESSAGE\_MAP() afx\_msg void OnLButtonUp(UINT nFlags, CPoint point);
};
// CListView2.cpp : Definition of ActiveX Control wrapper class(es) created by Microsoft Visual C++
#include "stdafx.h"
#include "CListView2.h"/////////////////////////////////////////////////////////////////////////////
// CListView2IMPLEMENT_DYNCREATE(CListView2, CWnd)
// CListView2 properties
// CListView2 operations
BEGIN_MESSAGE_MAP(CListView2, CWnd)
ON_WM_LBUTTONUP()
END_MESSAGE_MAP()void CListView2::OnLButtonUp(UINT nFlags, CPoint point)
{AfxMessageBox (\_T("Clicked in CListView2::OnLButtonUp " ) , MB\_OK|MB\_ICONSTOP); CWnd::OnLButtonUp(nFlags, point);
}
thank´s
-
hi, if you are trying to create an ActiveX control at runtime , be sure that you are calling the AfxEnableControlContainer() of method. and CoInitialize() also. call these functions in OnInitIntstance()/CWinApp hope this works!
^-^ @|@ - redCat
Hi, thank's so much, but i'm using : InitCommonControls(); AfxEnableControlContainer(); CoInitialize(NULL); on MyApp.InitInstance(); A think my problem is beacause a Runtime Acitivex don´t have a : DDX_Control(pDX, IDC_LISTVIEWCTRL1, LV1); On :DoDataExchange(CDataExchange* pDX); Somebody have anything idea ? One more Thank You.