버튼

CMy111View

~cpp 
public:

CButton myButton1, myButton2, myButton3, myButton4;

~cpp 
protected:
//{{AFX_MSG(CMy111View)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);

~cpp 
BEGIN_MESSAGE_MAP(CMy111View, CView)
	//{{AFX_MSG_MAP(CMy111View)
	ON_WM_CREATE()
	ON_BN_CLICKED(1,OnButton1Click)
~cpp 
// CMy111View message handlers
int CMy111View::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;


// Create a push button.
myButton1.Create(_T("푸시 버튼"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 
   CRect(10,10,200,30), this, 1);

// Create a radio button.
myButton2.Create(_T("라디오 버튼"), WS_CHILD|WS_VISIBLE|BS_RADIOBUTTON, 
   CRect(10,40,200,70), this, 2);

// Create an auto 3-state button.
myButton3.Create(_T("3상태 버튼"), WS_CHILD|WS_VISIBLE|BS_AUTO3STATE, 
   CRect(10,70,200,100), this, 3);

// Create an auto check box.
myButton4.Create(_T("체크박스"), WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX, 
   CRect(10,100,200,130), this, 4);
	return 0;
}

void CMy111View::OnButton1Click()
{
	MessageBox(_T("버튼이 눌려졌습니다."));
}



Value Meaning
BST_UNCHECKED Button state is unchecked.
BST_CHECKED Button state is checked.
BST_INDETERMINATE Button state is indeterminate (applies only if the button has the BS_3STATE or BS_AUTO3STATE style).

~cpp 
void CMy111View::OnButton1Click()
{
	check3=myButton3.GetCheck();
	if(check3==BST_CHECKED)
		MessageBox(_T("3버튼 체크되어 있음"));
	else if(check3==BST_UNCHECKED)
		MessageBox(_T("3버튼 체크 안되어 잇음"));
	else if(check3==BST_INDETERMINATE)
		MessageBox(_T("3버튼 희끄므리하게 체크되어 있음"));
}
~cpp 
myButton2.SetCheck( BST_CHECKED );
~cpp 
	check2=myButton2.GetCheck();
	if(check3==BST_CHECKED)
		MessageBox(_T("라디오버튼 체크되어 있음"));
	else if(check3==BST_UNCHECKED)
		MessageBox(_T("라이오버튼 체크 안되어 잇음"));


Retrieved from http://wiki.zeropage.org/wiki.php/5인용C++스터디/버튼과체크박스
last modified 2021-02-07 05:22:18