1)How to change a text of a button in runtime?

Answers were Sorted based on User's Feedback



1)How to change a text of a button in runtime?..

Answer / jp

1. Only required to know the Control Resource ID

((CButton*)GetDlgItem(IDOK))->SetWindowText(_T("Hello"));

Is This Answer Correct ?    1 Yes 0 No

1)How to change a text of a button in runtime?..

Answer / ps

1. make a control variable of button with the Cbutton class;
2. where you want to change the text then call only setwindowtext();

in header file;
Cbutton mButton;.
IN RESOURCE.H...
#DEFINE BUTTON_ID 249;// CONTROLL ID NUMBER 249 ANY YOU WNT OR SYSTEM GENRATED.
in cpp file.
'''''''mesage map
ABC::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, BUTTON_ID, mButton);
}
BOOL ABC::OnInitDialog()
{
// IF USER CHANGE ON INIT METHOD THEN CAN DO OR CHANGE IN ANY METHOD WITH THE SAME CLASS
mButton.setwindowText(_T"hello");


}

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More MFC Interview Questions

what is the difference between SDI and MDI

15 Answers   CMC, HCL, Siemens,


What is the range of intensity of RGB

1 Answers  


Does the application have more than one object? If no, then what is the reason?

5 Answers  


what are the feauters of CObject

4 Answers   Siemens, Wipro,


Explain in sort What is CTargetObject?

2 Answers  






2.create for 10 batch: Employee_Number Employee_name Employee_Dateofjoining Employee_address Employee_salary 1.select the employee name who deriving more than 10 thousand salary and joined before august 08. use structure and pointers

0 Answers   TCS,


What is serialization ?which function is responsible for serializing data ?

5 Answers  


How can update edit control data of an executing application from other application?

3 Answers   HP,


How WM_PAINT message gets called in MFC,please explain it . a)Who calls the WM_PAINT message? b)When it gets called? c)how it comes to message queue? Please Explain it

8 Answers  


Explain about MDI and CMultiDocTemplate ?

2 Answers  


What is the difference between regular dlls and extended dlls?

2 Answers  


is it possible to display a window .without using windowclass

1 Answers   E Logic,


Categories