Re: Subject: How to get the name and status of the windows, programmatically?

2004-03-11 Thread Khalid . Ansari

  
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
  
  

  
  




Re: How to get the name and status of the windows, programmatically?

2004-03-10 Thread Paul F. Sullivan
Hamid,

You wrote:

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?
How can I find out which window is active?
It is not clear if you mean all the windows of all programs or just 
all LabVIEW VI panels. In the former case, I can't help  you.

The LabVIEW Application has a property called All VIs in Memory 
which provides the names of those VIs. In LabVIEW 7, each VI has a 
property called Front Panel Window State which has values including 
Standard, Minimized, and Maximized. In earlier versions, only 
the Front Panel Window Open property exists and there does not appear 
to be an easy way to determined minimized  or maximized windows. The 
Front Panel Window is Frontmost property will tell you which is 
active.

You can see examples of the use of these properties in Copy/Paste 
Boolean Attributes 
(http://www.openg.org/tiki/tiki-index.php?page=Copy-Paste+Boolean+Attributes) 
on the OpenG site and in Edit Panel Elements and Ghost Buster on my 
site (http://www.sullutions.com/LabVIEW.html), among others.

--
EnWirementally,
Paul F. Sullivan


SULLutions  (781)769-6869
when a single discipline is not enough
	visit http://www.SULLutions.com






Re: Subject: How to get the name and status of the windows, programmatically?

2004-03-10 Thread Hamid_Yazdi

John;
Thanks for the email. I still don't know which window has the focus. I almost did what you mentioned.
First I get the non-labview windows (names) save them in an array, then minimize them all
For Labview, you have to minimize a window called Labview and this minimizes all LV windows
then you show your alarm in a clean screen and after user acknowledge you do the reverse

Thanks again 
Hamid


+
Dr. Hamid R. Yazdi
Federal Mogul
Manufacturing technology
3935 Research park drive
Ann Arbor, MI 48108

Tel: 734 222 4108


How to get the name and status of the windows, programmatically?

2004-03-04 Thread Hamid_Yazdi

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
Federal Mogul
Manufacturing technology
3935 Research park drive
Ann Arbor, MI 48108

Tel: 734 222 4108