| 202 | } |
| 203 | |
| 204 | std::string Alert::GetStandardDialogText() { |
| 205 | LOG(TRACE) << "Entering Alert::GetStandardDialogText"; |
| 206 | TextLabelFindInfo info; |
| 207 | info.label_handle = NULL; |
| 208 | info.control_id_found = 0; |
| 209 | info.excluded_control_id = 0; |
| 210 | |
| 211 | // Alert present, find the OK button. |
| 212 | // Retry up to 10 times to find the dialog. |
| 213 | int max_wait = 10; |
| 214 | while ((info.label_handle == NULL) && --max_wait) { |
| 215 | ::EnumChildWindows(this->alert_handle_, |
| 216 | &Alert::FindTextLabel, |
| 217 | reinterpret_cast<LPARAM>(&info)); |
| 218 | if (info.label_handle == NULL) { |
| 219 | ::Sleep(50); |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | // BIG ASSUMPTION HERE! If we found the text label, assume that |
| 224 | // all other controls on the alert are fully drawn too. |
| 225 | TextBoxFindInfo textbox_find_info; |
| 226 | textbox_find_info.textbox_handle = NULL; |
| 227 | textbox_find_info.match_proc = &Alert::IsSimpleEdit; |
| 228 | ::EnumChildWindows(this->alert_handle_, |
| 229 | &Alert::FindTextBox, |
| 230 | reinterpret_cast<LPARAM>(&textbox_find_info)); |
| 231 | if (textbox_find_info.textbox_handle) { |
| 232 | // There's a text box on the alert. That means the first |
| 233 | // label found is the system-provided label. Ignore that |
| 234 | // one and return the next one. |
| 235 | info.label_handle = NULL; |
| 236 | info.excluded_control_id = info.control_id_found; |
| 237 | info.control_id_found = 0; |
| 238 | ::EnumChildWindows(this->alert_handle_, |
| 239 | &Alert::FindTextLabel, |
| 240 | reinterpret_cast<LPARAM>(&info)); |
| 241 | } |
| 242 | |
| 243 | std::string alert_text_value; |
| 244 | if (info.label_handle == NULL) { |
| 245 | alert_text_value = ""; |
| 246 | } else { |
| 247 | int text_length = ::GetWindowTextLength(info.label_handle); |
| 248 | std::vector<wchar_t> text_buffer(text_length + 1); |
| 249 | ::GetWindowText(info.label_handle, &text_buffer[0], text_length + 1); |
| 250 | std::wstring alert_text = &text_buffer[0]; |
| 251 | alert_text_value = StringUtilities::ToString(alert_text); |
| 252 | } |
| 253 | return alert_text_value; |
| 254 | } |
| 255 | |
| 256 | std::string Alert::GetDirectUIDialogText() { |
| 257 | LOG(TRACE) << "Entering Alert::GetDirectUIDialogText"; |