• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2349
  • Last Modified:

Which window handle is returned on Windows 7 using findWindow("Progman", "Program Manager")

First,  I am surprised that this call works since Windows 7 doesn't use Program Manager.

Will this call return the correct virtual screen size in a multiple monitor setup on Windows 7?
0
pink1964
Asked:
pink1964
2 Solutions
 
JohnGabyCommented:
Are you trying to get the size of the various monitors attached to the system?  If so the following link might be useful:

http://msdn.microsoft.com/en-us/library/dd145072%28v=VS.85%29.aspx

If you are just looking for the handle to the desktop, try:

http://msdn.microsoft.com/en-us/library/ms633504%28VS.85%29.aspx
0
 
jcimarronCommented:
pink1964--I confess to not understanding the question.  None of the commands listed work in Win7. Progman.exe does not come with Win7.
So following on JohnGaby's post, what is it you want to do?
0
 
AndyAinscowCommented:
Hmm.

    HWND hWnd = ::FindWindow(_T("progman"), _T("Program Manager"));
    RECT rc;
    ::GetWindowRect(hWnd, &rc);


rc does contain the total size of a dual monitor system (on windows 7) BUT I don't know if I would trust it to do that reliably.
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
pink1964Author Commented:
Thanks Andy for confirming my test results.  

I posed my original question because I was hoping some of you might know if there was a legitimate reason Microsoft left this code in Windows 7;  it appears based on the responses I've gotten that this is not the case.  
I agree that using a reference to the Program Manager  is probably not reliable on Windows 7 and think it is likely an artifact that was overlooked and could go away at any time.

That said, there are many examples on the web which use the call to findWindow("Progman", "Program Manager");  a colleague of mine found one and used it to find the virtual screen size.  The call works fine on XP, but we need to support Windows 7 as well.
John Gaby posted a useful link.  

I tested GetDesktopWindow and it works fine for the primary monitor.  On a two monitor setup using XP,  the rectangle it returned was the one for the primary monitor only.  I have not tested a two monitor setup using this call on Windows 7.

I am currently using GetSystemMetrics, calling it 4 times to retrieve the virtual screen coordinates: SM_XVIRTUALSCREEN, SM_YVIRTUALSCREEN, SM_CXVIRTUALSCREEN, SM_CYVIRTUALSCREEN.  

Thanks again for your assistance!
0
 
AndyAinscowCommented:
JUST A GUESS:
It could be Microsoft left it in to stop apps breaking on Win 7.  (Feedback from beta testing for example)
0
 
pink1964Author Commented:
Very good and plausible guess Andy.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now