[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 238
  • Last Modified:

Something before "void function ();"

Hello again Experts.

Hi... As many of yours know... I'm migrating from VB to VC++.

It is a simple question.
I will ask about my doubts here as they appear to me...
I reached the the first chapter about
MFC.
In the book I have this code.

class CMyDrawApp : public CWinApp
{
public:
      CMyDrawApp();


// Overrides
      // ClassWizard generated virtual function overrides
      //{{AFX_VIRTUAL(CMyDrawApp)
      public:
      virtual BOOL InitInstance();
      //}}AFX_VIRTUAL

// Implementation
      //{{AFX_MSG(CMyDrawApp)
      afx_msg void OnAppAbout();
            // NOTE - the ClassWizard will add and remove member functions here.
            //    DO NOT EDIT what you see in these blocks of generated code !
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()
};

The thing that doesn't let me sleep here is "afx_msg void OnAppAbout();"

What does "afx_msg" mean... It is before a function declared as void.

It is the firs time I see something like this...
The whole code was succefully compilated.

And by the way...
Should I declare the API calls if I want to use them... or the compiler assumes that they exist?.


Thanks.
0
Marsc
Asked:
Marsc
  • 2
1 Solution
 
gothickCommented:
afx_msg actually means nothing at all to the compiler -- it is #defined to nothing, so the compiler never sees it.  The reason it is there is so that Visual C++ can tell that it's a message-handling function which has been automatically generated by the ClassWizard.  You can verify that it's defined to nothing by right-clicking on it in the editor and choosing "go to definition" -- that should show you where it is defined.

That's also the reason for the "//{{AFX_MSG(CMyDrawApp)" and the other lines that look like that -- they're just there so that the ClassWizard doesn't get confused.

As for API calls, virtually all of them are defined in "windows.h", which will nomrally have been included for you automatically (somewhere along the line) with a AppWizard-generated windows application.
0
 
MarscAuthor Commented:
Well... I'm going to see it...

Thank's for your help.
0
 
MarscAuthor Commented:
I'm sorry...
I wanted to accept your answer... but
I forgot to select that :)

Thanks again.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now