A
Ahmad Noori
Hello,
I created a Regular Dll that should display a Dialog Box so that the
user can enter some information. But when i call my dll nothing gets
display to the user. I am kinda lost. I started by creating a regular
dll with the option of using MFC libs using vc++ 6.0. I exported a
function which calls my Dialog box class:
extern "C" __declspec(dllexport) long CallDlg()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CmcDlg dlg;
dlg.DoModal();
DWORD dw = GetLastError();
printf("failed: GetLastError returned %u\n", dw);
return 0;
}
and here is the code for my CmcDlg class:
// mcDlg.cpp : implementation file
//
#include "stdafx.h"
#include "MFCdll.h"
#include "mcDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CmcDlg dialog
CmcDlg::CmcDlg(CWnd* pParent /*=NULL*/)
: CDialog(CmcDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CmcDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CmcDlg:oDataExchange(CDataExchange* pDX)
{
CDialog:oDataExchange(pDX);
//{{AFX_DATA_MAP(CmcDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CmcDlg, CDialog)
//{{AFX_MSG_MAP(CmcDlg)
ON_BN_CLICKED(IDC_Add, OnAdd)
ON_BN_CLICKED(IDC_Multiply, OnMultiply)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CmcDlg message handlers
void CmcDlg::OnAdd()
{
// TODO: Add your control notification handler code here
int iVar1 = GetDlgItemInt( IDC_EDIT1 );
int iVar2 = GetDlgItemInt( IDC_EDIT2 );
int iRes = iVar1 + iVar2 ;
SetDlgItemInt( IDC_EDIT3, iRes, TRUE );
UpdateData(FALSE);
}
void CmcDlg::OnMultiply()
{
// TODO: Add your control notification handler code here
int iVar1 = GetDlgItemInt( IDC_EDIT1 );
int iVar2 = GetDlgItemInt( IDC_EDIT2 );
int iRes = iVar1 * iVar2 ;
SetDlgItemInt( IDC_EDIT3, iRes, TRUE );
UpdateData(FALSE);
}
void CmcDlg::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
}
void CmcDlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
Anybody knows why? Thanks in advance for you help.
I created a Regular Dll that should display a Dialog Box so that the
user can enter some information. But when i call my dll nothing gets
display to the user. I am kinda lost. I started by creating a regular
dll with the option of using MFC libs using vc++ 6.0. I exported a
function which calls my Dialog box class:
extern "C" __declspec(dllexport) long CallDlg()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CmcDlg dlg;
dlg.DoModal();
DWORD dw = GetLastError();
printf("failed: GetLastError returned %u\n", dw);
return 0;
}
and here is the code for my CmcDlg class:
// mcDlg.cpp : implementation file
//
#include "stdafx.h"
#include "MFCdll.h"
#include "mcDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CmcDlg dialog
CmcDlg::CmcDlg(CWnd* pParent /*=NULL*/)
: CDialog(CmcDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CmcDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CmcDlg:oDataExchange(CDataExchange* pDX)
{
CDialog:oDataExchange(pDX);
//{{AFX_DATA_MAP(CmcDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CmcDlg, CDialog)
//{{AFX_MSG_MAP(CmcDlg)
ON_BN_CLICKED(IDC_Add, OnAdd)
ON_BN_CLICKED(IDC_Multiply, OnMultiply)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CmcDlg message handlers
void CmcDlg::OnAdd()
{
// TODO: Add your control notification handler code here
int iVar1 = GetDlgItemInt( IDC_EDIT1 );
int iVar2 = GetDlgItemInt( IDC_EDIT2 );
int iRes = iVar1 + iVar2 ;
SetDlgItemInt( IDC_EDIT3, iRes, TRUE );
UpdateData(FALSE);
}
void CmcDlg::OnMultiply()
{
// TODO: Add your control notification handler code here
int iVar1 = GetDlgItemInt( IDC_EDIT1 );
int iVar2 = GetDlgItemInt( IDC_EDIT2 );
int iRes = iVar1 * iVar2 ;
SetDlgItemInt( IDC_EDIT3, iRes, TRUE );
UpdateData(FALSE);
}
void CmcDlg::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
}
void CmcDlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
Anybody knows why? Thanks in advance for you help.