| 4693 | |
| 4694 | |
| 4695 | GuiIndexType GuiType::FindControl(char *aControlID) |
| 4696 | // Find the index of the control that matches the string, which can be either: |
| 4697 | // 1) The name of a control's associated output variable. |
| 4698 | // 2) Class+NN |
| 4699 | // 3) Control's title/caption. |
| 4700 | // Returns -1 if not found. |
| 4701 | { |
| 4702 | // To keep things simple, the first search method is always conducted: It looks for a |
| 4703 | // matching variable name, but only among the variables used by this particular window's |
| 4704 | // controls (i.e. avoid ambiguity by NOT having earlier matched up aControlID against |
| 4705 | // all variable names in the entire script, perhaps in PreparseBlocks() or something): |
| 4706 | GuiIndexType u; |
| 4707 | for (u = 0; u < mControlCount; ++u) |
| 4708 | if (mControl[u].output_var && !stricmp(mControl[u].output_var->mName, aControlID)) // Relies on short-circuit boolean order. |
| 4709 | return u; // Match found. |
| 4710 | // Otherwise: No match found, so fall back to standard control class and/or text finding method. |
| 4711 | HWND control_hwnd = ControlExist(mHwnd, aControlID); |
| 4712 | if (!control_hwnd) |
| 4713 | return -1; // No match found. |
| 4714 | for (u = 0; u < mControlCount; ++u) |
| 4715 | if (mControl[u].hwnd == control_hwnd) |
| 4716 | return u; // Match found. |
| 4717 | // Otherwise: No match found. At this stage, should be impossible if design is correct. |
| 4718 | return -1; |
| 4719 | } |
| 4720 | |
| 4721 | |
| 4722 |
no test coverage detected