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 updated verssion in vc++

3 Answers   Aspect,


What is the difference between regular dlls and extended dlls?

2 Answers  


What is the use of CObject::Dump function ?

4 Answers  


Which MFC function is used to display output?

9 Answers   TCS,


Name the Synchronization objects?

2 Answers  


What is socket?

3 Answers  


I want recent paper pattern for HP company?

0 Answers   HP,


Whats is DDX & DDV in MFC?

1 Answers   HCL,


What is stack size in win32 program?

1 Answers   HCL,


What is difference between the TCP/IP and UDP socket

5 Answers   Invensys,


How to access document object from view ?

1 Answers  


Tell me about different kinds of synchranization objects ?

6 Answers  


Categories