// this should only be executed once per Form public static API_WebScarab syncGuiPositionWithControl(this API_WebScarab webScarab, Control control) { Action moveToControl = ()=>{ webScarab.alwaysOnTop(true); var xPos = control.PointToScreen(System.Drawing.Point.Empty).X; var yPos = control.PointToScreen(System.Drawing.Point.Empty).Y; var width = control.width(); var height = control.height(); webScarab.moveWindow(xPos, yPos, width, height); }; control.parentForm().Move += (sender,e)=> moveToControl(); control.Resize += (sender,e)=> moveToControl(); moveToControl(); return webScarab; }
public static IntPtr resizeWindowToControlSize(this IntPtr handle, Control controlToSync, int x, int y) { if (handle != IntPtr.Zero) { var width = controlToSync.width(); var height = controlToSync.height(); handle.window_Move(x, y, width,height); "Setting window with handle {0} to {0}x{1} : {2}x{3}".info(handle, x, y, width, height); } return handle; }