|
here is an easy difference :
MFC is native code
WinForms is .NET
|
|
|
|
|
thanks, but can you explain a bit more where you use those, in what setting?
Does it make any difference in the final result?
As i understand, they almost give the same result, but im unsure what i need to use?
Thanks
|
|
|
|
|
Nobody can give you a short answer. You've been already asked to read up on .NET and native language programming. You'll then know the differences.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Oki thanks guys,
I try to read also on internett and find a lot of stuff, but are little confused though, because some place it looks like .net will take over for MFC because .net is future and MFC is the old fasion, and somepalces it looks like MFC are still the best.
But i guess its just to learn both then
|
|
|
|
|
frankis78 wrote: I am a bit new to C++ and struggle to see the difference between MFC and windows form application.
Then you should be reading relevant material to learn both rather than posting questions in internet forums. Since you know how to use the internet well enough to find this site and post your question, I will assume you know how to use Google to find the relevant material.
led mike
|
|
|
|
|
You're right that windows forms are simpler. MFC has many different window types which make it more complex. When moving from MFC to .NET, I've found that windows forms generally have every capability I've gotten used to using in MFC. It's easier to do things with windows forms because everything is implemented as properties and methods, which are easy to find.
|
|
|
|
|
I am getting the following error in .NET after converting my project from VC++ 6.0:
d:\utilities\FlightReport\FlightReport\FlightReportDoc.cpp(31): error C2440: 'static_cast' : cannot convert from 'BOOL (__thiscall CFlightReportDoc::* )(void)' to 'AFX_PMSG'
Can anyone help with this error and how to fix it? I did not get this error in VC++ 6.0!
Here is the code causing the error:
#if !defined(AFX_FLIGHTREPORTDOC_H__3EF623EF_987A_11D4_8093_00B0D0200BF9__INCLUDED_)
#define AFX_FLIGHTREPORTDOC_H__3EF623EF_987A_11D4_8093_00B0D0200BF9__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "StatNode.h"
#include "ReportParameters.h"
class CFlightReportDoc : public CDocument
{
protected:
CFlightReportDoc();
DECLARE_DYNCREATE(CFlightReportDoc)
public:
public:
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive& ar);
public:
virtual ~CFlightReportDoc();
CString m_saved_filename;
CString m_html_file;
CString m_current_path;
CString m_temp_report;
CStringList* m_model_list;
CStatNode* m_stat_node;
CString m_model_directory;
static CReportParameters* m_report_parameters;
CString GetFilenameWithoutPath(CString filename);
CString GetBaseName(CString model_name);
void CloseHTMLFile(CStdioFile &OutFile);
void WriteHTMLFile(CStdioFile &OutFile);
void InitStandardReportFile(CStdioFile &OutFile, CString m_version, bool view_only);
void InitAbbreviatedReportFile(CStdioFile &OutFile, CString m_catalog_full_pages, CString m_version);
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
protected:
afx_msg void OnFileOpen();
afx_msg void OnFileSaveAs();
afx_msg void OnFileSave();
DECLARE_MESSAGE_MAP()
public:
void DeleteContents(void);
};
#endif // !defined(AFX_FLIGHTREPORTDOC_H__3EF623EF_987A_11D4_8093_00B0D0200BF9__INCLUDED_)
#include "stdafx.h"
#include "FlightReport.h"
#include "FlightReportDoc.h"
#include "StatNode.h"
#include "DescriptionList.h"
#include "FileProgress.h"
#include "SelectFilesDialog.h"
#include "RunSilent.h"
#include <cderr.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
static int counter = 0;
IMPLEMENT_DYNCREATE(CFlightReportDoc, CDocument)
BEGIN_MESSAGE_MAP(CFlightReportDoc, CDocument)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
ON_COMMAND(ID_FILE_SAVE, OnFileSave)
ON_COMMAND(ID_FILE_NEW, OnNewDocument)
END_MESSAGE_MAP()
CReportParameters* CFlightReportDoc::m_report_parameters = new CReportParameters();
CFlightReportDoc::CFlightReportDoc()
{
m_stat_node = new CStatNode();
m_model_list = new CStringList();
m_saved_filename.Empty();
m_current_path.Empty();
m_current_path = getenv( "TEMP" );
if( m_current_path.IsEmpty() )
m_current_path = getenv( "TMP" );
if( m_current_path.IsEmpty() )
m_current_path = "C:";
srand((unsigned)time(0));
m_temp_report.Format("%s\\_report_%i.htm", m_current_path, rand());
}
CFlightReportDoc::~CFlightReportDoc()
{
delete m_stat_node;
delete m_model_list;
sprintf(cmd, "");
sprintf(args, "del /Q \"%s\"", m_temp_report);
RunSilent(cmd, args);
CWaitCursor wc;
}
BOOL CFlightReportDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
delete m_stat_node;
m_stat_node = new CStatNode();
delete m_model_list;
m_model_list = new CStringList();
m_saved_filename.Empty();
m_model_directory.Empty();
delete m_report_parameters;
m_report_parameters = new CReportParameters();
m_report_parameters->m_write_reset_files = false;
m_report_parameters->m_rst_ms_num = 3;
m_report_parameters->m_rst_slot_num = 10;
m_report_parameters->m_write_mht = false;
m_report_parameters->m_rt_shadow_sw = 20;
m_report_parameters->m_ref_folders = false;
m_report_parameters->m_disable_versioning = false;
CWinApp* pApp = AfxGetApp();
m_report_parameters->m_install_dir = pApp->GetProfileString(_T(""), _T("Dir") );
return TRUE;
}
void CFlightReportDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
}
else
{
}
}
#ifdef _DEBUG
void CFlightReportDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CFlightReportDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
|
|
|
|
|
To quote from this page, "The definition of ON_COMMAND (and other macros) changed between 6.0 and 7.0, from using explicit casting to static_cast." This means that it can now detect that you're returning a BOOL , when an ON_COMMAND handler should actually be void .
|
|
|
|
|
I tried changing the return value to void and I get a different error:
d:\utilities\FlightReport\FlightReport\FlightReportDoc.h(72) : error C2555: 'CFlightReportDoc::OnNewDocument': overriding virtual function return type differs and is not covariant from 'CDocument::OnNewDocument'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxwin.h(4831) : see declaration of 'CDocument::OnNewDocument'
All the help I looked up on overriding OnNewDocument matches with my code. I am not sure what to do now. I am new to this, so any help would be appreciated.
***UPDATE***
I took out the ON_COMMAND line and everything seems fine now.
modified on Tuesday, December 2, 2008 3:06 PM
|
|
|
|
|
CarolLamoreaux wrote: I took out the ON_COMMAND line and everything seems fine now.
Yes, it would be - I've just looked at one of my MFC apps - ID_FILE_NEW is handled by your app class (which would be derived from CWinApp ), which then delegates to the OnNewDocument in your document class, so you shouldn't have been handling ID_FILE_NEW in your document anyway.
|
|
|
|
|
i have a custom treectrl derived from mfc's ctreectrl
i'm using custom draw to modify it's layout (colors, fonts, etc..). i'm only drawing the text part because i dont wanna go into drawing and coding the other tree stuff like the open/close buttons and stuff
the last thing i need to do is to add text wrapping. when the text is too long to display, i need it to wrap to the next line instead of being truncated (adding elipsis)
i've been searching for a while and i still couldn't find a way to solve this
i can do the text wrapping part easily using cdc and drawtext, my only problem is the item's "row height". it looks like it is set to accommodate only one line of text per item row. a 2nd line would paint, but it would get overwritten by the next item row.
any suggestions? thanks
|
|
|
|
|
See this[^].
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
that won't work in my case because the texts have different lengths
some only have 1 line, some needs to wrap in 2, and some needs to wrap in 4 or more lines
if i used that, all item (all rows) would have the same height. if i set the height to the highest that i need, the ones with only 1 line would have some trailing line breaks
if i use a smaller height that the highest that i need, the highest one would still be truncated
i need a way to change the height on a per item basis
|
|
|
|
|
Then maybe look at this[^] and read up the description for the iIntegral member.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
that worked great, thanks
|
|
|
|
|
Hi,
I also have the same requirement, actually I want to implement the word wrap functionality in the tree view control but in my case it is CTreeViewCtrl that belongs to WTL and not MFC.
Could you please share your code fragment if possible or guide me how to handle the custom draw for the control and wrap the text.
Thanks in advance.
|
|
|
|
|
Please consider the following C program.
main()
{
int i, j, *p;
i = 25;
j = 100;
p = &i;
printf("%f", i/(*p) );
}
I took an online quiz on C and the correct answer was syntax error. I cannot find anything
wrong with the above program. I tried both GCC and the Microsoft Development Stdio
and both conmpilers accept the program.
Please comment.
Thanks
Bob
|
|
|
|
|
it's ok for me as well. p is of type int* , so *p is an int ...
and nothing forbids you to divide an int with another int .
so the result should be 1. (notice the . which means it is a float - actually, the division returns an int, but I suspect (not sure though) that the %f asks for an implicit cast)
|
|
|
|
|
Well, i see no syntax error either, what i do see and imho could cause a problem are the following:
-if main is actually the main entry routine then it should look like this: int main(int argc, char **argv); , but that wouldn't give you a syntax error, besides, that alone is just a function definition, nothing says it is "THE MAIN" entry point method. Besides, i think nowadays most compilers will accep that as the main entry point anyways.
-the "%f" in printf will expect a floating point value rather than an integer, but then again, not a syntax error
-you didn't specify any return type for the method, am not sure how compilers handle that but VC++ selfrigthously will take it as int, and might call you names for not returning anything from that method. But again, that is not a syntax error.
Hmm...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
I don't agree. the synopsis of the main() function (as an application entry point), there are several syntaxes allowed, and int main(int argc, char **argv) is definitely not *THE* ultimate one.
in C, the returned type is not mandatory. if not provided, int is assumed.
and under windows, main can accept a third parameter which is an array containing the environment variables...
|
|
|
|
|
See the Besides, i think nowadays most compilers will accep that as the main entry point anyways. part in my post, but you are right, sorry for the confusement.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
normally, a C++ compiler would not accept a not typed function ; so the minimal main should be int main() at least...
|
|
|
|
|
toxcct wrote: and under windows, main can accept a third parameter which is an array containing the environment variables...
Windows it's not alone, UNIX main has the above feature too.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: Windows it's not alone
and you say this to me ?!
when you're not sure, don't talk about something you don't know... that's what I did
|
|
|
|
|
toxcct wrote: and you say this to me ?!
Shouldn't I?
Why?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|