Bonjour,
j'ai un petit problème que je n'arrive pour l'instant pas
à résoudre car je doit mal m'y prendre.
J'essaye de créer une MFC de type DLL en utilisant un OCX
qui me rajoute des classes à mon projet de base.
Je souhaiterais utiliser une instance de cet OCX mais sans
passer par une dialog box (inutile dans mon cas).
Lorsque je créé un projet exe en incluant l'OCX, tout se passe
bien mais je n'arrive pas a trouver comment l'intégrer dans
mon code en appelant le Create de l'OCX.
Voici un bout du code que je possède pour l'instant:
- Pour le .h
#include "imgoptwin.h"
class CTestDLL1App : public CWinApp { public: CTestDLL1App(); CImgOptWin m_xatocx;
protected: // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CTestDLL1App) //}}AFX_VIRTUAL
//{{AFX_MSG(CTestDLL1App) // NOTE - the ClassWizard will add and remove member functions here. // DO NOT EDIT what you see in these blocks of generated code ! afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); //}}AFX_MSG DECLARE_MESSAGE_MAP() };
|
- Pour le .cpp
#include "TestDLL1.h"
#ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif
#define ID_XATCTRL 0
BEGIN_MESSAGE_MAP(CTestDLL1App, CWinApp) //{{AFX_MSG_MAP(CTestDLL1App) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_MSG_MAP END_MESSAGE_MAP()
//CTestDLL1App * testXat;
///////////////////////////////////////////////////////////////////////////// // CTestDLL1App construction
CTestDLL1App::CTestDLL1App() { // TODO: add construction code here, // Place all significant initialization in InitInstance // testXat = new CTestDLL1App(); }
///////////////////////////////////////////////////////////////////////////// // The one and only CTestDLL1App object
CTestDLL1App theApp;
int CTestDLL1App::OnCreate(LPCREATESTRUCT lpCreateStruct) { MessageBox(0,"OnCreate","TestDLL",0); // AfxEnableControlContainer(); if (CTestDLL1App::OnCreate(lpCreateStruct) == -1) return -1; // TODO: Add your specialized creation code here m_xatocx.Create(NULL, WS_VISIBLE, CRect(50,50,250,100), (CWnd *)this,ID_XATCTRL); return 0; }
|
En fait il ne passe jamais par ma méthode onCreate car je
pensais qu'il le ferait automatiquement (mois non !!!!!).
Merci.
Reydau 31
