首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

cp说BS_AUTORADIOBUTTON 只能用在对话框下

2013-01-11 
cp说BS_AUTORADIOBUTTON 只能用在对话框上?windows 程序设计 9.1.6 节,page:294说这个风格这能用在对话框

cp说BS_AUTORADIOBUTTON 只能用在对话框上?

windows 程序设计 9.1.6 节,page:294

说这个风格这能用在对话框

我提供一个反例:用在窗口上的。

而且我把风格改成: BS_RADIOBUTTON 竟然不能选中了。

怎么回事?

struct
{
int     iStyle ;
TCHAR * szText ;
}
button[] =
{
   
BS_GROUPBOX,        TEXT ("性别选择"),
BS_AUTORADIOBUTTON,  TEXT ("男"),
BS_AUTORADIOBUTTON,   TEXT ("女")

} ;


switch (message)
{
case WM_CREATE :
cxChar = LOWORD (GetDialogBaseUnits ()) ;
cyChar = HIWORD (GetDialogBaseUnits ()) ;

hwndButton[0] = CreateWindow ( TEXT("button"), 
button[0].szText,
WS_CHILD | WS_VISIBLE | button[0].iStyle,

0,0,
100,200,
hwnd, (HMENU) 1000,
((LPCREATESTRUCT) lParam)->hInstance, NULL) ;



hwndButton[1] = CreateWindow ( TEXT("button"), 
button[1].szText,
WS_CHILD | WS_VISIBLE | button[1].iStyle,


0,20,
60,60,
hwndButton[0], (HMENU) 1001,
((LPCREATESTRUCT) lParam)->hInstance, NULL) ;


hwndButton[2] = CreateWindow ( TEXT("button"), 
button[2].szText,
WS_CHILD | WS_VISIBLE | button[2].iStyle,

0,100,
60,60,
hwndButton[0], (HMENU) 1002,
((LPCREATESTRUCT) lParam)->hInstance, NULL) ;

return 0 ;
case WM_COMMAND :

if(LOWORD(wParam)== 1001)
{

SendMessage(hwndButton[1], BM_SETCHECK,1,0);
SendMessage(hwndButton[2], BM_SETCHECK,0,0);

}
else
{
SendMessage(hwndButton[2], BM_SETCHECK,1,0);

SendMessage(hwndButton[1], BM_SETCHECK,0,0);



}

break ;

[解决办法]
1. 我没听说过BS_AUTORADIOBUTTON只能用在对话框上,尽信书不如无书
2. 你的WM_COMMAND里处理RadioButton的BN_CLICKED没效,因为你把GroupBox作为RadioButton的父窗口了

热点排行