| |

VerySource

 Forgot password?
 Register
Search
View: 681|Reply: 7

How to add your own function in MFC

[Copy link]

2

Threads

6

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-2-19 03:00:01
| Show all posts |Read mode
I wrote a program in C language, but the teacher asked us to use MFC to integrate the interface display, but I know very little about MFC, and my program itself has many functions to jump around, I do n’t know how to change Add your own program to MFC. . .
So please enlighten me masters, I am very anxious for your reply ....
Reply

Use magic Report

0

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-4-28 18:30:01
| Show all posts
The declaration is placed in the .h file, and the function body is placed in .cpp
Reply

Use magic Report

2

Threads

6

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-4-30 20:15:01
| Show all posts
Can you be more specific? For example, I have the following function:
#include <stdio.h>
int a, b;
int add ()
{
  int ss;
  ss = a + b;
  return ss;
}

void main ()
{
  a = 1;
  b = 2;
  s = add ();
  printf ("% d", s);
}

So now I use the project named ADD, based on the dialog MFC interface, which a.b should be placed in a. Which .cpp is the function body? Can you make it clear?
Reply

Use magic Report

0

Threads

12

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-5-1 12:45:01
| Show all posts
MFC is C ++,
You are using C,
Don't force it, forget it, it is recommended to learn C ++ first, and then see << MFC
Reply

Use magic Report

2

Threads

6

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-5-3 22:30:02
| Show all posts
In fact, I also know that it is a bit reluctant, but the teacher asked for the MFC integrated interface to display it. There is no way ~~ And now the time is very tight, where is the time to look at C ++ ~
But I only need to display the results of my own program operation, should I not delve into it? Ha ha. . .
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-5-5 23:15:01
| Show all posts
This is not easy, just look for a simple example on the Internet and see
Reply

Use magic Report

0

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-5-28 08:45:02
| Show all posts
One build one Single documnet (single document project)
2. Put the add (int a, int b) function in the view cpp (don't forget to declare)
int add (int a, int b)
{
  int ss;
  ss = a + b;
  return ss;
}
Three call it in void CDrawTextView :: OnDraw (CDC * pDC) function
void CDrawTextView :: OnDraw (CDC * pDC)
{
CDrawTextDoc * pDoc = GetDocument ();
ASSERT_VALID (pDoc);
    
CString str;
str.Format ("% d", add (2,4));
pDC-> TextOut (1,1, str);
// TODO: add draw code for native data here
}
Reply

Use magic Report

2

Threads

6

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-5-31 13:00:01
| Show all posts
Oh, ah, it seems a bit understandable, thank you ...
But what if I want it to update every ten seconds
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list