2007年10月22日 星期一

To check CheckBox is checked or not in Visual Studio 6

目的 : 檢查YourCheckBoxIDC是否有check

if (SendDlgItemMessage( YourCheckBoxIDC, BM_GETCHECK,0,0)==BST_CHECKED)
{
// yes, user check this checkbox
}
else
{
// no, user doesn't check this checkbox.
}

SendDlgItemMessage

Syntax

LRESULT SendDlgItemMessage(
HWND hDlg,
int nIDDlgItem,
UINT Msg,
WPARAM wParam,
LPARAM lParam
);

SendDlgItemMessage會呼叫 SendMessage

SendMessage

Syntax

LRESULT SendMessage(
HWND hWnd,
UINT Msg,
WPARAM wParam,
LPARAM lParam
);

YourCheckBoxIDC 就是你拉到UI的CheckBox's ID

BM_GETCHECK (from http://msdn2.microsoft.com/en-us/library/aa452891.aspx)
This message is sent by an application to retrieve the check state of a radio button or check box

Msg(BST_CHECKED意義 (from http://msdn2.microsoft.com/en-us/library/8tba1y6f(VS.80).aspx)

BST_UNCHECKED Button state is unchecked.

BST_CHECKED Button state is checked.

透過Facebook分享

沒有留言: