C 语言 学习---复选框及列表框的使用


C 语言 学习---复选框及列表框的使用

 

void Main_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
    switch(id)
    {
        case IDC_OK:
		{
			HWND hwndCheck = GetDlgItem(hwnd,IDC_CHECK1);
			int checkState = Button_GetCheck(hwndCheck);
			if(BST_CHECKED == checkState)
			{
				MessageBox(hwnd,TEXT("选中"),TEXT(""),MB_OK);
			}
			if(BST_UNCHECKED == checkState)
			{
				MessageBox(hwnd,TEXT("未选中"),TEXT(""),MB_OK);
			}
		}
		break;
		case IDC_BUTTON1:
		{
			HWND hwndCheck = GetDlgItem(hwnd,IDC_CHECK1);
			int checkState = Button_GetCheck(hwndCheck);
			if(BST_CHECKED == checkState)
			{
				Button_SetCheck(hwndCheck,BST_UNCHECKED);
			}
			if(BST_UNCHECKED == checkState)
			{
				Button_SetCheck(hwndCheck,BST_CHECKED);
			}	
		}
		break;
		case IDC_BUTTON2:
		{
			HWND hwndList = GetDlgItem(hwnd,IDC_LIST1);
			ListBox_AddString(hwndList,TEXT("aaa"));
			ListBox_AddString(hwndList,TEXT("bbb"));
			ListBox_AddString(hwndList,TEXT("ccc"));
		}
        break;
        default:
	break;
    }
}
 

你可能感兴趣的:(复选框)