Click here to Skip to main content
15,887,214 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Enabling a button after previous button click. Pin
CodingLover9-Oct-07 23:25
CodingLover9-Oct-07 23:25 
GeneralRe: Enabling a button after previous button click. Pin
Lakshmi_p9-Oct-07 23:39
Lakshmi_p9-Oct-07 23:39 
GeneralRe: Enabling a button after previous button click. Pin
CodingLover9-Oct-07 23:53
CodingLover9-Oct-07 23:53 
GeneralRe: Enabling a button after previous button click. Pin
chandu00410-Oct-07 0:46
chandu00410-Oct-07 0:46 
GeneralRe: Enabling a button after previous button click. Pin
CodingLover10-Oct-07 0:50
CodingLover10-Oct-07 0:50 
GeneralRe: Enabling a button after previous button click. Pin
chandu00410-Oct-07 2:48
chandu00410-Oct-07 2:48 
GeneralRe: Enabling a button after previous button click. Pin
CodingLover10-Oct-07 19:04
CodingLover10-Oct-07 19:04 
GeneralRe: Enabling a button after previous button click. Pin
Nelek10-Oct-07 0:47
protectorNelek10-Oct-07 0:47 
mmm, ok, let see...

You stablish your form or your dialog in the resource editor, then you drag a button from the toolbar and drop it on your form. If you select the button and press enter, you get a properties window where as default comes IDC_BUTTON1 this is the ID of the button (you may always change it to you names, i.e. IDC_BUTTON_OPEN), you have the caption and so on...

once you have the buttons with the correct names, you can press CTRL + W and comes the class wizard assistant. When it opens you have the "Message order table" property sheet opened, the second is "Member variables", the third "Automation" and so on...

In the second one "Member variables" you will have a list with all the IDs of the form, in this case the two buttons, click on add variable and complete the "m_ " field with a name to reference the button in your code.

Create the second button and uncheck the property "Enabled" in the properties window of the button (at the bottom)

If you do it in that way, you can always use this name directly to access or modify the button.

You will have something like that in your CDialog.cpp
void CMyView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSPSMonitorView)
	DDX_Control(pDX, IDC_BUTTON_OPEN, m_cbOpen);
	DDX_Control(pDX, IDC_BUTTON_CLOSE, m_cbClose);
	//}}AFX_DATA_MAP
}


one that is done...

you can use another time the class assistant (this time in the first sheet "Messages Table") to look for the name of your button in the left listbox and include a function of the right listbox. In this case your OnButtonOpenClick
void CMyView::OnButtonOpenClick()
{
//do your things to open the file

m_cbClose.EnableWindow (TRUE);
}


and to reset the enable
void CMyView::OnButtonCloseClick()
{
//do your things to close the file

m_cbClose.EnableWindow (FALSE);
}


The other way to make it is without using member variables, taking a pointer to the control using the ID and the GetDlgControl () function as the other answer already explains.

Greetings.

--------
M.D.V.

If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?

Help me to understand what I'm saying, and I'll explain it better to you

Wink | ;)

GeneralRe: Enabling a button after previous button click. Pin
CodingLover10-Oct-07 0:56
CodingLover10-Oct-07 0:56 
GeneralRe: Enabling a button after previous button click. Pin
Nelek10-Oct-07 1:07
protectorNelek10-Oct-07 1:07 
GeneralRe: Enabling a button after previous button click. Pin
CodingLover10-Oct-07 1:10
CodingLover10-Oct-07 1:10 
AnswerRe: Enabling a button after previous button click. Pin
Hamid_RT9-Oct-07 23:38
Hamid_RT9-Oct-07 23:38 
QuestionFlickering Pin
saisp9-Oct-07 22:58
saisp9-Oct-07 22:58 
AnswerRe: Flickering Pin
chandu00410-Oct-07 0:29
chandu00410-Oct-07 0:29 
QuestionNon-rectangular client area Pin
Nishad S9-Oct-07 22:53
Nishad S9-Oct-07 22:53 
AnswerRe: Non-rectangular client area Pin
Nelek9-Oct-07 23:14
protectorNelek9-Oct-07 23:14 
GeneralRe: Non-rectangular client area Pin
Nishad S9-Oct-07 23:29
Nishad S9-Oct-07 23:29 
GeneralRe: Non-rectangular client area Pin
Nelek10-Oct-07 0:30
protectorNelek10-Oct-07 0:30 
GeneralRe: Non-rectangular client area Pin
Nishad S10-Oct-07 2:27
Nishad S10-Oct-07 2:27 
GeneralRe: Non-rectangular client area Pin
Nelek10-Oct-07 20:39
protectorNelek10-Oct-07 20:39 
AnswerRe: Non-rectangular client area Pin
eli1502197910-Oct-07 0:02
eli1502197910-Oct-07 0:02 
GeneralRe: Non-rectangular client area Pin
Nishad S10-Oct-07 0:10
Nishad S10-Oct-07 0:10 
AnswerRe: Non-rectangular client area Pin
Mark Salsbery10-Oct-07 6:14
Mark Salsbery10-Oct-07 6:14 
GeneralRe: Non-rectangular client area Pin
Nishad S10-Oct-07 17:45
Nishad S10-Oct-07 17:45 
AnswerRe: Non-rectangular client area Pin
David Crow11-Oct-07 2:58
David Crow11-Oct-07 2:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.