GNU Octave 3.6.4 (Windows)のFigure 1を前面に出すプログラム
以下のようなコード
#include <stdio.h>
#include <string.h>
#include <windows.h>
typedef struct _dataSet{
HWND hWnd;
char WindowName[256];
} DataSet;
#define true 1
#define false 0
BOOL CALLBACK EnumWndProc( HWND hWnd, LPARAM lParam )
{
char buff[256]="";
GetWindowText( hWnd,buff, sizeof(buff));
if(strcmp(buff,((DataSet*)lParam)->WindowName) == 0) {
((DataSet*)lParam)->hWnd = hWnd;
}
return true;
}
BOOL CALLBACK EnumChildProc( HWND hWnd, LPARAM lParam )
{
((DataSet*)lParam)->hWnd = hWnd;
return TRUE;
}
int main(int argc, char* argv[])
{
DataSet ds;
ds.hWnd =NULL;
if (argc == 1) {
strcpy(ds.WindowName, "Figure 1");
} else if (argc == 2) {
strcpy(ds.WindowName, argv[1]);
}
RECT rect1, rect2;
EnumWindows( EnumWndProc, (LPARAM)&ds);
if(ds.hWnd != NULL){
SetForegroundWindow(ds.hWnd);
SetFocus(ds.hWnd);
GetWindowRect(ds.hWnd, &rect1);
EnumChildWindows(ds.hWnd, EnumChildProc, (LPARAM)&ds);
GetWindowRect(ds.hWnd, &rect2);
printf( TEXT("%d %d %d %d"), rect2.left, rect2.top, rect2.right, rect2.bottom);
}
return 0;
}