Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

center window in current monitor

Posted on 2005-05-05
3
Medium Priority
?
609 Views
Last Modified: 2013-12-03
We are attempting to add minimal multi monitor support to our application. We have some windows that either are centered in our application, centered in the monitor, or take up the whole monitor.  I can get the position of our window in the secondary(or more) monitor, but I am not sure how to determine what offset to use for centering our window in the monitor.  I can fudge it by using GetWindowRect(GetDesktopWindow(),&rectDesktop); but that doesnt take into account different resolutions on different monitors.  Ideally there should be a way to get the the x,y of top left and bottom right of the monitor a window is in.  Our application needs to run on Win95,NT, and above although the multi monitor support does not need to function in 95/NT so I cannot imlicitly link with User32.lib and use GetMonitorInfor(), etc.
0
Comment
Question by:PhilC
3 Comments
 
LVL 13

Accepted Solution

by:
softplus earned 2000 total points
ID: 13934819
Why not just check the operating system and use GetMonitorInfo if it's available otherwise ignore it? I do this for lots of things (Printing, GDI, etc.). That way you have the best of both worlds - compatible + modern :)
John
0
 

Author Comment

by:PhilC
ID: 13935869
man was I wayyy over thinking this....example on MSDN "Positioning Objects on a Multiple Display Setup"...lol
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/monitor_9t0w.asp
thank you
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 13935905
Actually, you can link implicitly.  The link to the DLL is not created until the first call that needs it, so if you just make sure never to call the multi-monitor functions on Win95 then you will have no problems.  And yes, I do have a program that does just this.  Here's the function to tell if multimon is supported:

        OSVERSIONINFO version;
        version.dwOSVersionInfoSize = sizeof(version);
        GetVersionEx (&version);
        if ( // Check for NT
            ((version.dwPlatformId == VER_PLATFORM_WIN32_NT) &&
             (version.dwMajorVersion <= 4)) ||
            // Check for Win95
            ((version.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) &&
             (version.dwMajorVersion == 4) &&
             (version.dwMinorVersion == 0))
           )
            m_bMultimon = false;
        else
            m_bMultimon = true;

Hope this helps.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question