Mon appli lance un certain nombre de threads.
Parmis ces threads, il y en a un qui, à partir d'une classe derivant de CDialog, affiche une boîte de dialogue :
DWORD ProcIHM(LPVOID lpParametre)
{
if (lpParametre == NULL)
{
return PARAMETRE_NULL;
}
/*** DEBUT INITIALISATION ***/
// Copy local au thread de l'objet de communication
CCommunication com;
memcpy(&com,lpParametre,sizeof(CCommunication));
// Creation de l'IHM principale //
CMainIhm* p_ihm = new CMainIhm();
p_ihm->StartIhm();
....
[i]MainIhm.h :[/i]
#pragma once
#include "afxwin.h"
#include "resource.h"
// CMainIhm dialog
class CMainIhm : public CDialog
{
DECLARE_DYNAMIC(CMainIhm)
public:
CMainIhm(CWnd* pParent = NULL); // standard constructor
virtual ~CMainIhm();
void StartIhm(void);
HBITMAP m_TabCarte[13][4];
// Dialog Data
enum { IDD = IDD_MAINIHM };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
CStatic m_PictCtrlTapis;
};
MainIhm.cpp :
// MainIhm.cpp : implementation file
//
#include "stdafx.h"
#include "MainIhm.h"
// CMainIhm dialog
IMPLEMENT_DYNAMIC(CMainIhm, CDialog)
CMainIhm::CMainIhm(CWnd* pParent /*=NULL*/)
: CDialog(CMainIhm::IDD, pParent)
{
}
CMainIhm::~CMainIhm()
{
}
void CMainIhm::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_PICTURE, m_PictCtrlTapis);
}
void CMainIhm::StartIhm(void)
{
this->Create(IDD_MAINIHM);
this->SetForegroundWindow();
this->SetActiveWindow();
CString path = _T("" );
DWORD result = 0;
for (int i = 0; i < 12; i++)
{
for ( int j = 0 ; j < 4; j++)
{
path = _T("" );
path.AppendFormat(_T("E:\\Cissou\\Projets\\RFID Gaming\\Visual2008_projects\\Prototype_V0\\IHM\\Images\\cartes\\" ));
path.AppendFormat(_T("%d" ), i+2);
path.AppendFormat(_T("_" ));
path.AppendFormat(_T("%d" ), j+1);
path.AppendFormat(_T(".bmp" ));
m_TabCarte[i][j] = (HBITMAP) LoadImage(NULL, path.GetString(), IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);
if ( m_TabCarte[i][j] == NULL)
{
result = GetLastError();
}
else
{
CWnd * hWndViewerCarte = this->GetDlgItem(IDC_PICTURE);
m_PictCtrlTapis.SetWindowPos(NULL, 0, 0, /*CardBmp.GetBitmapDimension().cx*/45, /*CardBmp.GetBitmapDimension().cy*/63, SWP_SHOWWINDOW);
// Associate picture to the control
hWndViewerCarte->SendMessage( STM_SETIMAGE,
(WPARAM) IMAGE_BITMAP,
(LPARAM) m_TabCarte[i][j] );
Sleep(500);
}
#ifdef _DEBUG
TRACE("Resultat crtCheckMemory apres remplissage m_TabCarte[%d][%d] : %d\n", i, j, _CrtCheckMemory());
#endif
}
}
#ifdef _DEBUG
TRACE("Resultat crtCheckMemory avant sorie du constructeur de CMainIhm : %d\n", _CrtCheckMemory());
#endif
}
BEGIN_MESSAGE_MAP(CMainIhm, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
END_MESSAGE_MAP()
// CMainIhm message handlers
Voilà, si quelqu'un a une idée....
petite précision : l'appel de la fonction StartIhm() dans le thread principal donne le même résultat.