This code works in vc++6; how to make it work in msvc2005?

T

tonyjeffs

This code to create an empty window is from a web tutorial that goes
into interesting detail on message maps.
It is written for msvc6.
I have a stupid way to make it work in 2005; install a different
outdated program and let msvc update it, then substitute the code from
this exercise.

But what is the proper way to make it work?

/*Error: fatal error C1189: #error : Building MFC application with /
MD[d] (CRT dll version) requires MFC shared dll version. Please
#define _AFXDLL or do not use /MD[d]
....What does this mean and why is it not an issue in the version that
works... (same code)?*/

thanks
Tony


//MFC2.CPP - MFC Tutorial Part 2 from CoderSource.net

#include <afxwin.h>

class MFC_Tutorial_Window :public CFrameWnd
{
public:
MFC_Tutorial_Window()
{
Create(NULL,"MFC Tutorial Part 2 CoderSource Window");
}
void OnLButtonDown(UINT nFlags, CPoint point);
DECLARE_MESSAGE_MAP()
};

BEGIN_MESSAGE_MAP( MFC_Tutorial_Window, CFrameWnd)
ON_WM_LBUTTONDOWN() //Macro to map the left button click to the
handler
END_MESSAGE_MAP()

void MFC_Tutorial_Window::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CFrameWnd::OnLButtonDown(nFlags, point);
MessageBox("Left Button clicked");
}


class MyApp :public CWinApp
{
MFC_Tutorial_Window *wnd;
public:
BOOL InitInstance()
{
wnd = new MFC_Tutorial_Window();
m_pMainWnd = wnd;
m_pMainWnd->ShowWindow(1);
return 1;
}
};

MyApp theApp;




Thanks
Tony
 
M

Mark Salsbery [MVP]

The issue looks like project settings, not the code.

Set

Project Settings/General/Use of MFC to "Use MFC in a shared DLL"

and

Project Settings/C/C++/Code Generation/Runtime Library to "Multi-threaded
Debug DLL (/MDd)"

and it should build fine.

Mark
 
T

tonyjeffs

The issue looks like project settings, not the code.

Set

Project Settings/General/Use of MFC to "Use MFC in a shared DLL"

and

Project Settings/C/C++/Code Generation/Runtime Library to "Multi-threaded
Debug DLL (/MDd)"

and it should build fine.

Mark

--
Mark Salsbery
Microsoft MVP - Visual C++




This code to create an empty window is from a web tutorial that goes
into interesting detail on message maps.
It is written for msvc6.
I have a stupid way to make it work in 2005; install a different
outdated program and let msvc update it, then substitute the code from
this exercise.
But what is the proper way to make it work?
/*Error: fatal error C1189: #error : Building MFC application with /
MD[d] (CRT dll version) requires MFC shared dll version. Please
#define _AFXDLL or do not use /MD[d]
...What does this mean and why is it not an issue in the version that
works... (same code)?*/
thanks
Tony

//MFC2.CPP - MFC Tutorial Part 2 from CoderSource.net
#include <afxwin.h>
class MFC_Tutorial_Window :public CFrameWnd
{
public:
MFC_Tutorial_Window()
{
Create(NULL,"MFC Tutorial Part 2 CoderSource Window");
}
void OnLButtonDown(UINT nFlags, CPoint point);
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP( MFC_Tutorial_Window, CFrameWnd)
ON_WM_LBUTTONDOWN() //Macro to map the left button click to the
handler
END_MESSAGE_MAP()
void MFC_Tutorial_Window::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CFrameWnd::OnLButtonDown(nFlags, point);
MessageBox("Left Button clicked");
}
class MyApp :public CWinApp
{
MFC_Tutorial_Window *wnd;
public:
BOOL InitInstance()
{
wnd = new MFC_Tutorial_Window();
m_pMainWnd = wnd;
m_pMainWnd->ShowWindow(1);
return 1;
}
};
MyApp theApp;
Thanks
Tony- Hide quoted text -

- Show quoted text -

Hi Mark.

I knew that yesterday! I just needed to take a break.
Understandably, it works with use of MFC in static library too.

Thanks
Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top