/** * Oct-file to align the current Ocatve figure windows (if any) * so they are all at the same position on the screen: * * alignwindows() */ #include #include #include using namespace std; struct Position { bool isSet; // have we determined a position? RECT rect; // this is it }; BOOL CALLBACK enumWindowsProc(HWND hwnd, LPARAM lParam) { Position* pos = (Position*) lParam; char title[100]; GetWindowText(hwnd, title, sizeof(title)); int handle; char dash[1000]; char word[1000]; int fields = sscanf(title, "%d %s %s", &handle, dash, word); if (fields == 3 && handle < 100 && dash[0] == '-' && dash[1] == '\0') { //octave_stdout << title << endl; if (!pos->isSet) { GetWindowRect(hwnd, &pos->rect); pos->isSet = true; } else { SetWindowPos(hwnd, 0, pos->rect.left, pos->rect.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE ); } // maximise them as well //ShowWindow(hwnd, SW_MAXIMIZE); } return true; } DEFUN_DLD(alignwindows, args, nargout, "Aligns all the figure windows") { int nargin = args.length(); octave_value retval; if (nargin != 0 && nargin != 2) print_usage(); Position pos; pos.isSet = false; EnumWindows(enumWindowsProc, (LPARAM) &pos); return retval; }