On Thu, 15 Jul 2004, Duncan Murdoch wrote: > You'll need to read Windows documentation. > Currently R has no way to get the list of MDI document windows. I > think the function you want is EnumChildWindows, but you might need to > use EnumWindows. I can't remember whether MDI documents are child > windows or top level windows.
Hi Dr. Murdoch, Thanks for you advice. I checked WIN32API documents and write the following codes. So far, the call just gives all the hwnd's of child windows. Many window widgets are treated as child windows, such as tool bar, shortcut buttons, workspace, and so on. Therefore, the output can be a long list. Probably, I need to redefine the maximum number of handles. Moreover, it does not make sense to give a list of hwnd's only. I will add more information to the output later. Cheers! Peng /*************************C codes begin*************************/ #define MAXNCHILDWINS 100 struct hwndlst { HWND childhwndlst[MAXNCHILDWINS]; int p; }; BOOL CALLBACK EnumChildProc(HWND hwndChild, struct hwndlst * lParam) { struct hwndlst * plist=lParam; plist->childhwndlst[(plist->p)++] = hwndChild; return TRUE; } struct hwndlst getMDIChildHandle(void) { HWND hwnd; struct hwndlst hwndlst; hwndlst.p = 0; hwnd = GetForegroundWindow(); EnumChildWindows(hwnd, EnumChildProc, &hwndlst); return(hwndlst); } SEXP getMDIChildhandles() { SEXP result; int i; struct hwndlst lst; result = R_NilValue; /* to avoid warnings */ lst = getMDIChildHandle(); PROTECT(result = allocVector(INTSXP, MAXNCHILDWINS+1)); INTEGER(result)[0]=(int)(lst.p); for (i=1; i<MAXNCHILDWINS+1; i++) { INTEGER(result)[i] = ((int)(lst.childhwndlst)[i-1]); } UNPROTECT(1); return result; } /**********************C codes end.************************/ ####################R codes begin########################### getMDIChildhandles <- function() { a <- .Call("getMDIChildhandles") a <- a[2:(a[1])] return(a) } ##################R codes end.############################# ------------------------------------- Peng Liu Department of Statistics NC State University Raleigh, NC 27695, USA E-mail: [EMAIL PROTECTED] URL: http://www4.ncsu.edu/~pliu3 ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-devel