Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

CButton states

Posted on 2003-02-22
7
Medium Priority
?
553 Views
Last Modified: 2013-11-20
Hi,
I have 8 CButton object on a sidebar dialog.
I would like to be able to synchronize them,which mean,when i push one button,and then another one, i
would like that the first pushed button will be released
and the second one will be pressed.
Just one button should be pressed each time.
I don't know how to realese CButton from its pressed
state.

Thanks a lot for any help.
0
Comment
Question by:dani333
  • 3
  • 2
  • 2
7 Comments
 
LVL 9

Expert Comment

by:Priyesh
ID: 8001992
try SetState(TRUE) to press and SetState(FALSE) to release

you could get the state of a button using GetState()

if(m_Btn1.GetState() & 0x0004)//if btn1 pressed
{
   m_Btn1.SetState(FALSE) ;//release btn1
   m_Btn2.SetState(TRUE) ;//press btn2
}
0
 

Author Comment

by:dani333
ID: 8002969
Hi Priyesh,
It dosen't work.
if(m_Btn1.GetState() & 0x0004)//if btn1 pressed
When I use Debug mode it dosen't get inside the condition.
So I tried :
if(m_Btn1.GetState()!=0 )
but it dosen't release the button
m_Btn1.SetState(FALSE) ;//this line dosen't work


0
 
LVL 9

Accepted Solution

by:
Priyesh earned 200 total points
ID: 8004843
okay dani333,

try this

void CTestdlgDlg::OnOK()
{
     CButton* pButton = (CButton*)GetDlgItem(IDC_BUTTON1) ;
     pButton->SetState(!(pButton->GetState()&0x0004)) ;
}

if you have a button with id IDC_BUTTON1, this code will toggle the button. works for me in VC6.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:mrbiggles
ID: 8018743
Hi try this...

Use the resource editor to place "radio buttons" in your dialog.  Then change the style properties on each button to "Push-like".

hope this helps.
0
 

Expert Comment

by:mrbiggles
ID: 8018881
Hi try this...

Use the resource editor to place "radio buttons" in your dialog.  Then change the style properties on each button to "Push-like".

hope this helps.
0
 

Author Comment

by:dani333
ID: 8021777
Hi,
Can you give me your e-mail please?
0
 
LVL 9

Expert Comment

by:Priyesh
ID: 8022326
padmavilas@hotmail.com
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question