MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / FindGroup

Method FindGroup

source/script_gui.cpp:7920–7953  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7918
7919
7920int GuiType::FindGroup(GuiIndexType aControlIndex, GuiIndexType &aGroupStart, GuiIndexType &aGroupEnd)
7921// Caller must provide a valid aControlIndex for an existing control.
7922// Returns the number of radio buttons inside the group. In addition, it provides start and end
7923// values to the caller via aGroupStart/End, where Start is the index of the first control in
7924// the group and End is the index of the control *after* the last control in the group (if none,
7925// aGroupEnd is set to mControlCount).
7926// NOTE: This returns the range covering the entire group, and it is possible for the group
7927// to contain non-radio type controls. Thus, the caller should check each control inside the
7928// returned range to make sure it's a radio before operating upon it.
7929{
7930 // Work backwards in the control array until the first member of the group is found or the
7931 // first array index, whichever comes first (the first array index is the top control in the
7932 // Z-Order and thus treated by the OS as an implicit start of a new group):
7933 int group_radios = 0; // This and next are both init'd to 0 not 1 because the first loop checks aControlIndex itself.
7934 for (aGroupStart = aControlIndex;; --aGroupStart)
7935 {
7936 if (mControl[aGroupStart]->type == GUI_CONTROL_RADIO)
7937 ++group_radios;
7938 if (!aGroupStart || GetWindowLong(mControl[aGroupStart]->hwnd, GWL_STYLE) & WS_GROUP)
7939 break;
7940 }
7941 // Now find the control after the last control (or mControlCount if none). Must start at +1
7942 // because if aControlIndex's control has the WS_GROUP style, we don't want to count that
7943 // as the end of the group (because in fact that would be the beginning of the group).
7944 for (aGroupEnd = aControlIndex + 1; aGroupEnd < mControlCount; ++aGroupEnd)
7945 {
7946 // Unlike the previous loop, this one must do this check prior to the next one:
7947 if (GetWindowLong(mControl[aGroupEnd]->hwnd, GWL_STYLE) & WS_GROUP)
7948 break;
7949 if (mControl[aGroupEnd]->type == GUI_CONTROL_RADIO)
7950 ++group_radios;
7951 }
7952 return group_radios;
7953}
7954
7955
7956

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected