This bounced back the first time.. sending again...
-------------------
Hamid,
You can use the EnumDesktopWindows function from windows API. This function
enumerates all open windows and passes their handles to a callback function. The
callback function can then check the state of the windows using the handles passed-in,
and in turn calling other windows functions like IsIconic, IsZoomed, etc., See MSDN
for more details on these functions.
You can implement the EnumDesktopWindows and the callback function in a dll. And call
the exported function from LabVIEW. Here's some code snippets.. it pops-up message
boxes with the windows' states:
// This is an exported function.. call this from LabVIEW
extern "C" WINFO_API int fnWinfo(void)
{
return EnumDesktopWindows(NULL, EnumWindowsProc, NULL);
}
// callback fn which EnumDesktopWindows calls
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
char wname[256] = "";
GetWindowText(hwnd, wname, 256);
if(!IsWindowVisible(hwnd) || strlen(wname) == 0)
{
//not a valid "window" -- do nothing
}
else
{
if(IsIconic(hwnd))
{
MessageBox(NULL, strcat(wname, " -- minimized"), "", MB_OK);
}
else if(IsZoomed(hwnd))
{
MessageBox(NULL, strcat(wname, " -- maximized"), "", MB_OK);
}
else if(GetActiveWindow() == hwnd)
{
MessageBox(NULL, strcat(wname, " -- active"), "", MB_OK);
}
else
{
MessageBox(NULL, strcat(wname, " -- restore/other"), "",
MB_OK);
}
}
return true;
}
Your LabVIEW dll node will look like:
unsigned long fnWinfo(void);
Caveat: The above code was put together in a jiffy for proof-of-concept only; it's not
perfect. You can easily modify this to return the info' to labVIEW (instead of the
msg boxes). Note that the EnumDesktopWindows actually returns a bunch of "windows"
without any names; we filter them out
above.
Hope this helps.
Regards,
Khalid Ansari
----- Forwarded by Khalid Ansari on 03/04/2004 11:29 PM -----
[EMAIL PROTECTED]
Sent by: <[EMAIL PROTECTED]>
03/03/2004 07:42 AM
To: [EMAIL PROTECTED]
cc:
Subject: How to get the name and status of the windows, programmatically?
Hi List
I need to get the name of all the windows that are open. Also, I need to
find out the status of the windows
i.e. Which one of them is maximized or minimized? (This is NOT limited to
Labview windows, any other window must be included)
How can I find out which window is "active"?
Any help is appreciated
Thanks
+++++++++++++++++++++
Dr. Hamid R. Yazdi