-1

I had to combine MFC and WinAPI: add WINAPI code to MFC, the following are MFC and WinAPI code:

MFC code

void MyMFCView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
......
}

WinAPI code

LRESULT CALLBACK Win32Fun(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 
{
......
}

Can I do like this:

void MyMFCView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
    Win32Fun(hwnd, msg, wParam, lParam);
}
Jabberwocky
  • 48,281
  • 17
  • 65
  • 115
  • There is not technical barrier that prevents C++ (MFC) code from calling into C (WinAPI) code. Since the signature of your WinAPI code very much looks like it is part of message handling, however, things are different. MFC implements a message handling framework, and if you sidestep it, all sorts of breakage will ensue. – IInspectable Oct 29 '14 at 16:01

1 Answers1

0

Yes. There's no magic involved. The fact that the base class of your class is taken from the MFC library doesn't change the fact that it's C++. The WINAPI is C code, and C++ can call C.

MSalters
  • 173,980
  • 10
  • 155
  • 350