Home > Software engineering >  MFC how to judge whether a button clicks
MFC how to judge whether a button clicks

Time:11-03

To define a n, click on the n=1, 2 n=2, how to do

CodePudding user response:

Define a static variable records, make its increment per click

CodePudding user response:

Inside the button of "click" event to do statistics,

CodePudding user response:

A member variable or a global variable you understand

CodePudding user response:

Global variable

CodePudding user response:

See you want to statistics button clicks is start form every time a recount or close the window, still can continue to statistics, the former can make a class member variable statistics, which need to be on the basis of the previous step to add a write files or registry action to record statistics

CodePudding user response:

Static variables, the member variable or a global variable can be, and then click the event since, if need to be on the outside of the function call, you don't define the static variables

CodePudding user response:

Header files define inside int clickNum;
Dialog box inside the constructor of the assignment=0;
Then click event inside LButtonDown clickNum++ inside;
And then to display
Cstrings STR="" '
STR. The Format (" % d ", clickNum);
MessageBox (STR);

Will definitely get the

CodePudding user response:

Add a counter where LButtonDown events directly

CodePudding user response:

Weak weak ask, how to realize the click button displays a text, and then point the same button shows another text

CodePudding user response:

Dialog box class, for example
1, in the header file CxxxxDlg. Add variable h
Int n;
2, in CxxxxDlg. CPP add initialization:
N=0;
In 3, double click on the button control, add
n++;
Cstrings STR.
STR. The Format (_T (" % d "), n);
SetDlgItemText (IDC_EDIT1, STR);
  • Related