Click here to Skip to main content
15,904,339 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralMDI FormView Printing Pin
vancouver7775-Oct-03 11:55
vancouver7775-Oct-03 11:55 
GeneralIP/name conversion Pin
Kuniva5-Oct-03 10:36
Kuniva5-Oct-03 10:36 
GeneralRe: IP/name conversion Pin
Michael Dunn5-Oct-03 12:09
sitebuilderMichael Dunn5-Oct-03 12:09 
GeneralAttributes in Visual C++ .NET 2003 Pin
Urban Olars5-Oct-03 9:43
Urban Olars5-Oct-03 9:43 
Generalpow Pin
iasaber5-Oct-03 8:55
iasaber5-Oct-03 8:55 
GeneralRe: pow Pin
ZoogieZork5-Oct-03 8:58
ZoogieZork5-Oct-03 8:58 
GeneralVisual Studio Wizards Pin
Franz Klein5-Oct-03 8:00
Franz Klein5-Oct-03 8:00 
GeneralWin 32 and MFC Problem Pin
spiritualfields5-Oct-03 7:36
spiritualfields5-Oct-03 7:36 
In migrating from VC 6.0 to VC 7.1 I'm running into a problem figuring out how to include stdafx.h into a Win 32 application. After creating an empty project, I changed settings to "Using MFC in a shared DLL". I was able to run the first program in Prosise's MFC Programming book, but received a warning. The program is so small that I'll repoduce it here and then specify the exact problem after it:

// Hello.h
class CMyApp : public CWinApp
{
public:
virtual BOOL InitInstance();
};

class CMainWindow : public CFrameWnd
{
public:
CMainWindow();

protected:
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP ()
};// end Hello.h

////// Here comes Hello.cpp
#include "afxwin.h" // actually used less than & greater than symbol here but needed quotes for this post
#include "Hello.h"

CMyApp myApp;

//////////////////////////////////////////////////////////
//////// CMyApp member functions

BOOL CMyApp::InitInstance()
{
m_pMainWnd = new CMainWindow;
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}

///////////////////////////////////////////////////////////
//////// CMainWindow message map and member functions

BEGIN_MESSAGE_MAP (CMainWindow, CFrameWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()

CMainWindow::CMainWindow()
{
Create(NULL, _T("The Hello Application"));
}

void CMainWindow::OnPaint()
{
CPaintDC dc(this);

CRect rect;
GetClientRect(&rect);

dc.DrawText(_T("Hello, MFC"), -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
}

///////////That's it

This program runs fine as is but I get the following warning during the build:

Compiling...
Hello.cpp
WINVER not defined. Defaulting to 0x0501 (Windows XP and Windows .NET Server)
Linking...

Build log was saved at "file://c:\TEST_MFCProsise\Hello\Debug\BuildLog.htm"
Hello - 0 error(s), 0 warning(s)


---------------------- Done ----------------------

Build: 1 succeeded, 0 failed, 0 skipped

///////////////

So then I commented out the afxwin.h include and included "stdafx.h" which, I thought, would take care of the warning. Instead the program would not compile and I received this error:

Compiling...
Hello.cpp
c:\TEST_MFCProsise\Hello\Hello.cpp(1) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory

Build log was saved at "file://c:\TEST_MFCProsise\Hello\Debug\BuildLog.htm"
Hello - 1 error(s), 0 warning(s)


---------------------- Done ----------------------

Build: 0 succeeded, 1 failed, 0 skipped


The stdafx.h file is right where it's supposed to be inside of the atlmfc subdirectory, and MFC applications don't have any problem finding it. What do I have to do to run Win 32 applications using MFC in a shared DLL and including stdafx.h?

Ed
GeneralRe: Win 32 and MFC Problem Pin
Navin5-Oct-03 10:19
Navin5-Oct-03 10:19 
GeneralRe: Win 32 and MFC Problem Pin
spiritualfields5-Oct-03 12:04
spiritualfields5-Oct-03 12:04 
GeneralRe: Win 32 and MFC Problem Pin
Navin5-Oct-03 14:12
Navin5-Oct-03 14:12 
GeneralAdding Custom containers to Access Database Pin
CHERCHALI KARIM5-Oct-03 6:42
CHERCHALI KARIM5-Oct-03 6:42 
Generalsyntax question Pin
boon kian5-Oct-03 5:29
boon kian5-Oct-03 5:29 
GeneralRe: syntax question Pin
Michael Dunn5-Oct-03 9:07
sitebuilderMichael Dunn5-Oct-03 9:07 
GeneralRe: syntax question Pin
boon kian6-Oct-03 4:42
boon kian6-Oct-03 4:42 
GeneralRe: syntax question Pin
Steve S6-Oct-03 5:08
Steve S6-Oct-03 5:08 
GeneralRe: syntax question Pin
boon kian7-Oct-03 3:21
boon kian7-Oct-03 3:21 
Generalno more ideas... Pin
Max Santos5-Oct-03 4:57
Max Santos5-Oct-03 4:57 
GeneralRe: no more ideas... Pin
includeh105-Oct-03 5:25
includeh105-Oct-03 5:25 
GeneralRe: no more ideas... Pin
Anonymous6-Oct-03 1:38
Anonymous6-Oct-03 1:38 
Generalfile extension and loaded by double click Pin
includeh105-Oct-03 3:42
includeh105-Oct-03 3:42 
GeneralRe: file extension and loaded by double click Pin
Dominik Reichl5-Oct-03 4:14
Dominik Reichl5-Oct-03 4:14 
GeneralRe: file extension and loaded by double click Pin
includeh105-Oct-03 4:17
includeh105-Oct-03 4:17 
GeneralRe: file extension and loaded by double click Pin
Dominik Reichl5-Oct-03 4:32
Dominik Reichl5-Oct-03 4:32 
Questionhow to get a menu wnd handle? Pin
muddog5-Oct-03 3:30
muddog5-Oct-03 3:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.