don't allow changing the allow and deny checkbox state to checked at the same time

svn path=/trunk/; revision=16569
This commit is contained in:
Thomas Bluemel 2005-07-14 21:57:57 +00:00
parent f0300f5044
commit a8f77a38bd
3 changed files with 131 additions and 27 deletions

View file

@ -581,11 +581,11 @@ SecurityPageProc(IN HWND hwndDlg,
case WM_NOTIFY: case WM_NOTIFY:
{ {
NMHDR *pnmh = (NMHDR*)lParam; NMHDR *pnmh = (NMHDR*)lParam;
if (pnmh->idFrom == IDC_ACELIST) sp = (PSECURITY_PAGE)GetWindowLongPtr(hwndDlg,
DWL_USER);
if (sp != NULL)
{ {
sp = (PSECURITY_PAGE)GetWindowLongPtr(hwndDlg, if (pnmh->hwndFrom == sp->hWndAceList)
DWL_USER);
if (sp != NULL)
{ {
switch(pnmh->code) switch(pnmh->code)
{ {
@ -603,6 +603,24 @@ SecurityPageProc(IN HWND hwndDlg,
} }
} }
} }
else if (pnmh->hwndFrom == sp->hAceCheckList)
{
switch(pnmh->code)
{
case CLN_CHANGINGITEMCHECKBOX:
{
PNMCHANGEITEMCHECKBOX pcicb = (PNMCHANGEITEMCHECKBOX)lParam;
/* make sure only one of both checkboxes is only checked
at the same time */
if (pcicb->Checked)
{
pcicb->NewState &= ~((pcicb->CheckBox != CLB_DENY) ? CIS_DENY : CIS_ALLOW);
}
break;
}
}
}
} }
break; break;
} }

View file

@ -106,6 +106,17 @@ ListViewSelectItem(IN HWND hwnd,
#define CLM_SETQUICKSEARCH_TIMEOUT_RESET (WM_USER + 10) #define CLM_SETQUICKSEARCH_TIMEOUT_RESET (WM_USER + 10)
#define CLM_SETQUICKSEARCH_TIMEOUT_SETFOCUS (WM_USER + 11) #define CLM_SETQUICKSEARCH_TIMEOUT_SETFOCUS (WM_USER + 11)
#define CLN_CHANGINGITEMCHECKBOX (101)
typedef struct _NMCHANGEITEMCHECKBOX
{
NMHDR nmhdr;
DWORD OldState;
DWORD NewState;
DWORD CheckBox;
BOOL Checked;
} NMCHANGEITEMCHECKBOX, *PNMCHANGEITEMCHECKBOX;
BOOL BOOL
RegisterCheckListControl(HINSTANCE hInstance); RegisterCheckListControl(HINSTANCE hInstance);

View file

@ -95,6 +95,31 @@ static VOID ChangeCheckItemFocus(IN PCHECKLISTWND infoPtr,
/******************************************************************************/ /******************************************************************************/
static LRESULT
NotifyControlParent(IN PCHECKLISTWND infoPtr,
IN UINT code,
IN OUT PVOID data)
{
LRESULT Ret = 0;
if (infoPtr->hNotify != NULL)
{
LPNMHDR pnmh = (LPNMHDR)data;
pnmh->hwndFrom = infoPtr->hSelf;
pnmh->idFrom = GetWindowLongPtr(infoPtr->hSelf,
GWLP_ID);
pnmh->code = code;
Ret = SendMessage(infoPtr->hNotify,
WM_NOTIFY,
(WPARAM)pnmh->idFrom,
(LPARAM)pnmh);
}
return Ret;
}
static PCHECKITEM static PCHECKITEM
FindCheckItemByIndex(IN PCHECKLISTWND infoPtr, FindCheckItemByIndex(IN PCHECKLISTWND infoPtr,
IN UINT Index) IN UINT Index)
@ -1181,20 +1206,29 @@ ChangeCheckItemHotTrack(IN PCHECKLISTWND infoPtr,
} }
#endif #endif
static VOID static BOOL
ChangeCheckBox(IN PCHECKLISTWND infoPtr, ChangeCheckBox(IN PCHECKLISTWND infoPtr,
IN PCHECKITEM CheckItem, IN PCHECKITEM CheckItem,
IN UINT CheckItemBox) IN UINT CheckItemBox)
{ {
DWORD NewState, OldState = CheckItem->State; NMCHANGEITEMCHECKBOX CheckData;
DWORD OldState = CheckItem->State;
DWORD CheckedBit = ((infoPtr->FocusedCheckItemBox == CLB_DENY) ? CIS_DENY : CIS_ALLOW); DWORD CheckedBit = ((infoPtr->FocusedCheckItemBox == CLB_DENY) ? CIS_DENY : CIS_ALLOW);
BOOL Checked = (CheckItem->State & CheckedBit) != 0; BOOL Checked = (CheckItem->State & CheckedBit) != 0;
NewState = (Checked ? OldState & ~CheckedBit : OldState | CheckedBit); CheckData.OldState = OldState;
CheckData.NewState = (Checked ? OldState & ~CheckedBit : OldState | CheckedBit);
CheckData.CheckBox = infoPtr->FocusedCheckItemBox;
CheckData.Checked = !Checked;
/* FIXME - send a notification message */ if (NotifyControlParent(infoPtr,
CLN_CHANGINGITEMCHECKBOX,
CheckItem->State = NewState; &CheckData) != (LRESULT)-1)
{
CheckItem->State = CheckData.NewState;
}
return (CheckItem->State != OldState);
} }
static VOID static VOID
@ -2118,9 +2152,20 @@ CheckListWndProc(IN HWND hwnd,
if (PtItem == infoPtr->FocusedCheckItem && InCheckBox && if (PtItem == infoPtr->FocusedCheckItem && InCheckBox &&
PtItemBox == infoPtr->FocusedCheckItemBox) PtItemBox == infoPtr->FocusedCheckItemBox)
{ {
ChangeCheckBox(infoPtr, UINT OtherBox = ((PtItemBox == CLB_ALLOW) ? CLB_DENY : CLB_ALLOW);
PtItem, DWORD OtherStateMask = ((OtherBox == CLB_ALLOW) ?
PtItemBox); (CIS_ALLOW | CIS_ALLOWDISABLED) :
(CIS_DENY | CIS_DENYDISABLED));
DWORD OtherStateOld = PtItem->State & OtherStateMask;
if (ChangeCheckBox(infoPtr,
PtItem,
PtItemBox) &&
((PtItem->State & OtherStateMask) != OtherStateOld))
{
UpdateCheckItemBox(infoPtr,
infoPtr->FocusedCheckItem,
OtherBox);
}
} }
UpdateCheckItemBox(infoPtr, UpdateCheckItemBox(infoPtr,
@ -2173,16 +2218,32 @@ CheckListWndProc(IN HWND hwnd,
if (infoPtr->FocusedCheckItem != NULL && if (infoPtr->FocusedCheckItem != NULL &&
infoPtr->QuickSearchHitItem == NULL) infoPtr->QuickSearchHitItem == NULL)
{ {
UINT OtherBox;
DWORD OtherStateMask;
DWORD OtherStateOld;
MakeCheckItemVisible(infoPtr, MakeCheckItemVisible(infoPtr,
infoPtr->FocusedCheckItem); infoPtr->FocusedCheckItem);
ChangeCheckBox(infoPtr, OtherBox = ((infoPtr->FocusedCheckItemBox == CLB_ALLOW) ? CLB_DENY : CLB_ALLOW);
infoPtr->FocusedCheckItem, OtherStateMask = ((OtherBox == CLB_ALLOW) ?
infoPtr->FocusedCheckItemBox); (CIS_ALLOW | CIS_ALLOWDISABLED) :
(CIS_DENY | CIS_DENYDISABLED));
UpdateCheckItemBox(infoPtr, OtherStateOld = infoPtr->FocusedCheckItem->State & OtherStateMask;
if (ChangeCheckBox(infoPtr,
infoPtr->FocusedCheckItem, infoPtr->FocusedCheckItem,
infoPtr->FocusedCheckItemBox); infoPtr->FocusedCheckItemBox))
{
UpdateCheckItemBox(infoPtr,
infoPtr->FocusedCheckItem,
infoPtr->FocusedCheckItemBox);
if ((infoPtr->FocusedCheckItem->State & OtherStateMask) != OtherStateOld)
{
UpdateCheckItemBox(infoPtr,
infoPtr->FocusedCheckItem,
OtherBox);
}
}
} }
} }
break; break;
@ -2236,15 +2297,29 @@ CheckListWndProc(IN HWND hwnd,
infoPtr->FocusedCheckItem != NULL && infoPtr->FocusedCheckItem != NULL &&
infoPtr->FocusedPushed) infoPtr->FocusedPushed)
{ {
UINT OtherBox = ((infoPtr->FocusedCheckItemBox == CLB_ALLOW) ? CLB_DENY : CLB_ALLOW);
DWORD OtherStateMask = ((OtherBox == CLB_ALLOW) ?
(CIS_ALLOW | CIS_ALLOWDISABLED) :
(CIS_DENY | CIS_DENYDISABLED));
DWORD OtherStateOld = infoPtr->FocusedCheckItem->State & OtherStateMask;
infoPtr->FocusedPushed = FALSE; infoPtr->FocusedPushed = FALSE;
ChangeCheckBox(infoPtr, if (ChangeCheckBox(infoPtr,
infoPtr->FocusedCheckItem,
infoPtr->FocusedCheckItemBox);
UpdateCheckItemBox(infoPtr,
infoPtr->FocusedCheckItem, infoPtr->FocusedCheckItem,
infoPtr->FocusedCheckItemBox); infoPtr->FocusedCheckItemBox))
{
UpdateCheckItemBox(infoPtr,
infoPtr->FocusedCheckItem,
infoPtr->FocusedCheckItemBox);
if ((infoPtr->FocusedCheckItem->State & OtherStateMask) != OtherStateOld)
{
UpdateCheckItemBox(infoPtr,
infoPtr->FocusedCheckItem,
OtherBox);
}
}
} }
break; break;
} }
@ -2566,15 +2641,15 @@ RegisterCheckListControl(HINSTANCE hInstance)
{ {
WNDCLASS wc; WNDCLASS wc;
ZeroMemory(&wc, sizeof(WNDCLASS));
wc.style = CS_DBLCLKS; wc.style = CS_DBLCLKS;
wc.lpfnWndProc = CheckListWndProc; wc.lpfnWndProc = CheckListWndProc;
wc.cbClsExtra = 0; wc.cbClsExtra = 0;
wc.cbWndExtra = sizeof(PCHECKLISTWND); wc.cbWndExtra = sizeof(PCHECKLISTWND);
wc.hInstance = hInstance; wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(0, (LPWSTR)IDC_ARROW); wc.hCursor = LoadCursor(0, (LPWSTR)IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wc.lpszMenuName = NULL;
wc.lpszClassName = L"CHECKLIST_ACLUI"; wc.lpszClassName = L"CHECKLIST_ACLUI";
return RegisterClass(&wc) != 0; return RegisterClass(&wc) != 0;