Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Retrieve.NET datagrid cell value font color
#2
Function FindElmWithColor.
The example script finds the selected item in a folder window.

Code:
Copy      Help
var w1 = wnd.find(1, "Test - File Explorer", "CabinetWClass");
w1.Activate();
var list = w1.Elm["LIST", "Items View", "class=DirectUIHWND"].Find(1);
var a = list.Elm["LISTITEM"].FindAll();

int i = C.FindElmWithColor(a, list, 0xCDE8FF);
if (i < 0) { print.it("not found"); return; }
print.it(i, a[i]);

class C {
    /// <summary>
    ///
In elm array finds elm that contains given color or image.
    /// </summary>
    ///
<param name="a"></param>
    ///
<param name="area">wnd, elm or RECT that contains all elms.</param>
    ///
<param name="color">Color or image.</param>
    ///
<returns>0-based index, or -1 if not found.</returns>
    ///
<remarks>
    ///
Most parameters are the same as with <see cref="uiimage.find"/>.
    /// </remarks>
    public static int FindElmWithColor(elm[] a, IFArea area, IFImage color, IFFlags flags = IFFlags.WindowDC, int diff = 0) {
        //in area find pixel with color. To create code can be used tool "Find image".
        var im1 = uiimage.find(area, color, flags, diff);
        if (im1 == null) return -1; //color not found
        var rect = im1.RectInScreen;
        
        //in array find elm whose rectangle contains rect
        for (int i = 0; i < a.Length; i++) {
            if (a[i].Rect.Contains(rect)) return i;
        }

        
        return -1;
    }
}


Messages In This Thread
RE: Retrieve.NET datagrid cell value font color - by Gintaras - 11-22-2024, 04:33 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)