/// <summary> /// 根据参数键值及控件句柄填写参数。 /// </summary> /// <param name="key"></param> /// <param name="fillControl"></param> /// <returns></returns> private bool FillValue(string key, object fillControl) { IntPtr current = IntPtr.Zero; List <IntPtr> list = fillControl as List <IntPtr>; if (list != null && list.Count == 0) { return(true); } if (string.IsNullOrEmpty(key)) { return(true); } FillParameter3C fillParameter = _fillParameters[key] as FillParameter3C; if (fillParameter == null) { fillParameter = new FillParameter3C() { Key = key, Separators = FillParameter3C.DefaultSeparators }; _fillParameters.Add(key, fillParameter); } FillValue3C fillValue = _pageData[key] as FillValue3C; if (fillValue == null) { Records.Add(new FillRecord(ElementType.Unknown, RecordType.Failed, "数据文件中未定义此参数", key)); return(true); } StringBuilder className = new StringBuilder(256); string name = ""; if (list != null) { current = list[0]; className = new StringBuilder(256); NativeApi.GetClassName(current, className, 255); name = className.ToString(); // 勾选是否适用复选框 if (name.StartsWith(CCCFillManager.ButtonClassName)) { if (fillValue.Value == "N/A") { if (ApiSetter.IsDisabled(current) == false) { ApiSetter.SetCheck(current, this.Hwnd); //ApiSetter.ClickButton(current, this.Hwnd, null, null); return(true); } } current = list.Count > 1 ? list[list.Count - 1] : current; } } else { current = (IntPtr)fillControl; } if (fillParameter.Type == "5" || fillParameter.Type == "7") { return(FillCheckBox(fillParameter, current)); } className.Clear(); NativeApi.GetClassName(current, className, 255); name = className.ToString(); if (name.StartsWith(CCCFillManager.StaticClassName)) { return(true); } else if (name.StartsWith(CCCFillManager.EditClassName)) { return(FillValue(CCCFillManager.EditClassName, current, fillValue)); } else if (name.StartsWith(CCCFillManager.ButtonClassName)) { return(FillValue(CCCFillManager.ButtonClassName, current, fillValue)); } else if (name.StartsWith(CCCFillManager.ComboBoxClassName)) { #if export sheet.WriteNextRow(); sheet.WriteTextCell(1, writer.AddSharedString(key)); #endif return(FillValue(CCCFillManager.ComboBoxClassName, current, fillValue)); } else { // 多值填报 List <IntPtr> sortedControl = ControlSorter.SortContainer(current); if (sortedControl == null) { return(false); } else if (sortedControl.Count == 1) { return(FillValue(key, sortedControl[0])); } int valueIndex = 0; for (int i = 0; i < sortedControl.Count; i++, valueIndex++) { className.Clear(); NativeApi.GetClassName(sortedControl[i], className, 255); if (className.ToString().StartsWith(CCCFillManager.ButtonClassName)) { FillValue(CCCFillManager.ButtonClassName, ref valueIndex, sortedControl[i], fillValue); } else if (className.ToString().StartsWith(CCCFillManager.ComboBoxClassName)) { #if export sheet.WriteNextRow(); sheet.WriteTextCell(1, writer.AddSharedString(key)); #endif FillValue(CCCFillManager.ComboBoxClassName, ref valueIndex, sortedControl[i], fillValue); } else if (className.ToString().StartsWith(CCCFillManager.EditClassName)) { FillValue(CCCFillManager.EditClassName, ref valueIndex, sortedControl[i], fillValue); } } } return(true); }