Thread: c and MFC problem

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    38

    c and MFC problem

    Dear All,
    1. Can I use c code in MFC?
    2. What is the code if i create an "open" button and click it to open files in windows?
    3. How can I recall other person's function in MFC?

    Thank you
    Last edited by lwong; 10-29-2003 at 06:45 AM.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    If you want to learn MFC, I suggest you get a good book. Perhaps even learning raw Win32 programming first.

    Since MFC is a C++ library, and C++ is a superset of C, you can use C code within an MFC based application.

    gg

  3. #3
    King of the Internet Fahrenheit's Avatar
    Join Date
    Oct 2001
    Posts
    128

    Re: c and MFC problem

    Of course you can call C from MFC- MFC is just a class based interface to the WinAPI.

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    >>you can use C code within an MFC based application.

    in most cases you have to prefix the function with :: to use the WIN32 API C version of the function.
    Code:
    //MFC Messagebox
    AfxGetMainWnd()->MessageBox( "Some Error occured" , "MyApps Error" , MB_OK | MB_ICONERROR);
    
    //WIN32 API Messagebox in a MFC app
    ::MessageBox(hWnd,"Some Error occured" , "MyApps Error" , MB_OK | MB_ICONERROR);
    >>2. What is the code if i create an "open" button and click it to open files in windows?

    Too many variations to tell you. Try, post if you have problems.

    >>3. How can I recall other person's function in MFC?

    If the function is not a standard MFC function;
    Got the other persons code, a library or DLL?

    Else AFAIK no way to do so.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed