Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reorder and resize "COLUMNHEADER" elements
#1
Question 
Hello All,

I am trying to figure out if it is possible to reorder and resize "COLUMHEADER" elements


I am able to find all of the "COLUMHEADER" elements and store them in an array with the following code
Code:
Copy      Help
 
{
var w = wnd.find(1, "Network Signal Paths", "Afx:*");
elm[] header = (w.Elm["COLUMNHEADER", "*", "class=SysHeader32"].FindAll());
print.it(header);
}

which returns 
Code:
Copy      Help
 
  COLUMNHEADER,  n="SDP A",  s=(READONLY, FOCUSABLE, SELECTABLE),  a="Click",  r={L=910 T=170 W=112 H=24},  e=1,  w="SysHeader32"
  COLUMNHEADER,  n="Signal Path Name",  s=(READONLY, FOCUSABLE, SELECTABLE),  a="Click",  r={L=1022 T=170 W=218 H=24},  e=2,  w="SysHeader32"
  COLUMNHEADER,  n="VM",  s=(READONLY, FOCUSABLE, SELECTABLE),  a="Click",  r={L=1240 T=170 W=64 H=24},  e=3,  w="SysHeader32"
  COLUMNHEADER,  n="Layer",  s=(READONLY, FOCUSABLE, SELECTABLE),  a="Click",  r={L=1304 T=170 W=123 H=24},  e=4,  w="SysHeader32"
  COLUMNHEADER,  n="Moor",  s=(READONLY, FOCUSABLE, SELECTABLE),  a="Click",  r={L=1427 T=170 W=58 H=24},  e=5,  w="SysHeader32"
  COLUMNHEADER,  n="Label",  s=(READONLY, FOCUSABLE, SELECTABLE),  a="Click",  r={L=1485 T=170 W=100 H=24},  e=6,  w="SysHeader32"
  COLUMNHEADER,  n="Bandwidth",  s=(READONLY, FOCUSABLE, SELECTABLE),  a="Click",  r={L=1585 T=170 W=72 H=24},  e=7,  w="SysHeader32"
  COLUMNHEADER,  n="Host A",  s=(READONLY, FOCUSABLE, SELECTABLE),  a="Click",  r={L=1657 T=170 W=97 H=24},  e=8,  w="SysHeader32"
  COLUMNHEADER,  n="Multicast A",  s=(READONLY, FOCUSABLE, SELECTABLE),  a="Click",  r={L=1754 T=170 W=136 H=24},  e=9,  w="SysHeader32"
  COLUMNHEADER,  n="Interface A",  s=(READONLY, FOCUSABLE, SELECTABLE),  a="Click",  r={L=1890 T=170 W=275 H=24},  e=10,  w="SysHeader32"
  COLUMNHEADER,  n="SDP B",  s=(READONLY, INVISIBLE, OFFSCREEN, FOCUSABLE, SELECTABLE),  a="Click",  r={L=2165 T=170 W=112 H=24},  e=11,  w="SysHeader32"
  COLUMNHEADER,  n="Host B",  s=(READONLY, INVISIBLE, OFFSCREEN, FOCUSABLE, SELECTABLE),  a="Click",  r={L=2277 T=170 W=97 H=24},  e=12,  w="SysHeader32"

But I am not sure how I can reorder and resize these elements within the window. My guess is that it would be achieved with a command similar to the code below but I am not sure.
Code:
Copy      Help
findlayer.WndContainer.Send(0x1013, findlayer.Item-1); //LVM_ENSUREVISIBLE

Does anyone know how this could be achieved?

Thank you 

P.S the "Cookbook/Recipe" feature in the new version is a great help for me!
#2
If it's a classic header control (class name SysHeader32), probably can be used message HDM_SETITEM. But it's not easy, because need to use process memory, know indices, use different code for 64 and 32 bit process, maybe DPI-scale.

Maybe better to use drag-and-drop. Can record it, or get column rectangles and write mouse-drag code.
#3
Hello Gintaras,

Thank you very much for your response. understood, 

The solution that I came up with is similar to what you mention with a drag-and-drop. 
Code:
Copy      Help
 
var sdpa = w1.Elm["COLUMNHEADER", "SDP A", "class=SysHeader32"].Find(1); 
elm[] header = (w1.Elm["COLUMNHEADER", "*", "class=SysHeader32"].FindAll());
var a = sdpa.Name;
var b = header[0].Name;

if(a != b) {
print.it("move spd a colum");
mouse.drag(sdpa,header[0]);
}
#4
Example with listview control in Computer Management -> Task Scheduler. Orders and resizes column headers using drag-and-drop. All column headers must be completely visible (no horizontal scrollbar).

C# code:
//var order = new string[] { "Author", "Created", "Last Run Result", "Last Run Time", "Name", "Next Run Time", "Status", "Triggers" };
var order = new (string name, int width)[] { ("Author", 80), ("Created", 120), ("Last Run Result", 160), ("Last Run Time", 80), ("Name", 120), ("Next Run Time", 160), ("Status", 80), ("Triggers", 120) };

var w = wnd.find(1, "Computer Management", "MMCMainFrame").Activate();
if (!w.IsMaximized) {
    w.ShowMaximized(noAnimation: true);
    500.ms();
}
var ctrl = w.Child(1, "***elmName Header Control", "SysHeader32");
for (int i = order.Length; --i >= 0; ) {
    //move
    var e = ctrl.Elm["COLUMNHEADER", order[i].name].Find(0);
    mouse.drag(e, ctrl, x2: 1, y2: 8, speed: 0);
    //resize
    e = ctrl.Elm["COLUMNHEADER", order[i].name].Find(0); //find again because Rect of the old element may be not updated after moving
    int dx = order[i].width - e.Rect.Width;
    if (dx != 0) mouse.drag(e, ^0, .5f, dx, 0, speed: 0);
}
#5
Wow! this is pretty fancy!  Thank you very much!


Forum Jump:


Users browsing this thread: 1 Guest(s)