GIDForums  

Go Back   GIDForums > Computer Programming Forums > MS Visual C++ / MFC Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 02-Nov-2005, 08:06
Dominic Dominic is offline
Member
 
Join Date: Aug 2005
Posts: 123
Dominic will become famous soon enough

A question about CButton.SetState()


It would appear on my dialog that I can set the state of a CButton to the Pressed in state using SetState() member function of the CButton MFC. However if I select any other CButton on the dialog, the orriginal one (set via SetState()) becomes unset again.

Is this supposed to happen? That is, can only one CButton on a dialog show the Set condition?

Regards
  #2  
Old 03-Nov-2005, 02:09
Janakiraman Janakiraman is offline
Junior Member
 
Join Date: Apr 2005
Location: Chennai - India
Posts: 47
Janakiraman is on a distinguished road

Re: A question about CButton.SetState()


Hi,

It is not only one should be in the pushed stage...

Create a function named PushStage() in that set the SetStage() of each button to TRUE as declared below.

MFC code:
CPP / C++ / C Code:
void CButtonDlg::PushStage()
{
m_ButtonSample1.SetState(TRUE);//m_ButtonSample1 is the member variable of CButton
m_ButtonSample2.SetState(TRUE);//m_ButtonSample2 is the member variable of CButton
}

now call PushStage() function in all the button clicks... like below

void CButtonDlg::OnButtonSample1() // Event of Button 1
{
	// TODO: Add your control notification handler code here
	PushStage();
	
}

void CButtonDlg::OnButtonSample2() // Event of Button 2
{
	// TODO: Add your control notification handler code here
	PushStage();
	
}

am i clear....?

Best Regards,
Janakiraman
  #3  
Old 03-Nov-2005, 03:14
Dominic Dominic is offline
Member
 
Join Date: Aug 2005
Posts: 123
Dominic will become famous soon enough

Re: A question about CButton.SetState()


Thanks,
Seems to work ok in a test dialog, if I use the Resource Editor to place the buttons onto the Dialog. Now I must further investigate why its not working when I dynamically create buttons.
  #4  
Old 03-Nov-2005, 05:38
Dominic Dominic is offline
Member
 
Join Date: Aug 2005
Posts: 123
Dominic will become famous soon enough

Re: A question about CButton.SetState()


Thanks for your help.
It turns out the SetState was working, but I was reading the pushed in state of the button incorrectly. I was reading CButton::GetState() == 0x04 (according to the MSDN help). The function CButton::GetState() also returns 0x0C when not actually being pressed and then 0x08 when still in focus. I should have been reading CButton::GetState() == 0x6C to show that the button is actually BEING pressed. I then latch it and SetState() acordingly.
Thanks for the help though.
 
 

Recent GIDBlogR for statistics by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
non-member function question crq C++ Forum 1 03-Feb-2005 21:59
Simple question on arrays--please help! brookeville C++ Forum 16 17-Nov-2004 23:23
Repetition structure problem and question brookeville C++ Forum 17 29-Oct-2004 17:48
question of practice magiccreative C++ Forum 1 06-Feb-2004 07:17
a C input question tmike C Programming Language 1 16-Sep-2003 02:31

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 18:41.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.