Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. GetSystemMetrics(SM_CXVIRTUALSCREEN)

GetSystemMetrics(SM_CXVIRTUALSCREEN)

Scheduled Pinned Locked Moved C / C++ / MFC
csharpvisual-studiohelpquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    IlanTal
    wrote on last edited by
    #1

    I use both Visual Studio 6 and 7. I want to detect and use dual monitors. For this I use GetSystemMetrics(SM_CXVIRTUALSCREEN), which works fine under vs7. Under vs6 SM_CXVIRTUALSCREEN is unknown and it returns zero (after putting in the integer value of the constant). Apparently one way to solve the problem is with the SDK. I would like to know if there is a lighter weight option? Also if I give the software to a friend, does he too need the SDK? My gut feeling is there must be an easier solution. Any suggestions? Thanks, Ilan

    J U 2 Replies Last reply
    0
    • I IlanTal

      I use both Visual Studio 6 and 7. I want to detect and use dual monitors. For this I use GetSystemMetrics(SM_CXVIRTUALSCREEN), which works fine under vs7. Under vs6 SM_CXVIRTUALSCREEN is unknown and it returns zero (after putting in the integer value of the constant). Apparently one way to solve the problem is with the SDK. I would like to know if there is a lighter weight option? Also if I give the software to a friend, does he too need the SDK? My gut feeling is there must be an easier solution. Any suggestions? Thanks, Ilan

      J Offline
      J Offline
      James R Twine
      wrote on last edited by
      #2

      If you want to detect multiple monitors acting in/as a virtual screen, you might want to use SM_CMONITORS.  Note that that value, as well as the SM_C?VIRTUALSCREEN values are dependent on the OS your application is running on; they will return an incorrect value (0) on Windows 95 and Windows NT.    The updated SDK only gives you the files required to compile and link your code that uses the updated/new identifiers, it does not guarantee that the resulting application will work on any OS.    Peace! -=- James


      If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
      Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
      DeleteFXPFiles & CheckFavorites (Please rate this post!)

      I 1 Reply Last reply
      0
      • J James R Twine

        If you want to detect multiple monitors acting in/as a virtual screen, you might want to use SM_CMONITORS.  Note that that value, as well as the SM_C?VIRTUALSCREEN values are dependent on the OS your application is running on; they will return an incorrect value (0) on Windows 95 and Windows NT.    The updated SDK only gives you the files required to compile and link your code that uses the updated/new identifiers, it does not guarantee that the resulting application will work on any OS.    Peace! -=- James


        If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
        Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
        DeleteFXPFiles & CheckFavorites (Please rate this post!)

        I Offline
        I Offline
        IlanTal
        wrote on last edited by
        #3

        Thanks Jim, I am using SM_MONITORS and that doesn't work either. The OS is XP so that is no problem but it returns zero. Can you explain this?? Ilan

        J 1 Reply Last reply
        0
        • I IlanTal

          Thanks Jim, I am using SM_MONITORS and that doesn't work either. The OS is XP so that is no problem but it returns zero. Can you explain this?? Ilan

          J Offline
          J Offline
          James R Twine
          wrote on last edited by
          #4

          Nope, I cannot explain that.  You do not have any of the Application Compatability settings turned on for your app, do you?    Look into EnumDisplayMonitors and see if that works for you.    Peace! -=- James


          If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
          Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
          DeleteFXPFiles & CheckFavorites (Please rate this post!)

          I 1 Reply Last reply
          0
          • J James R Twine

            Nope, I cannot explain that.  You do not have any of the Application Compatability settings turned on for your app, do you?    Look into EnumDisplayMonitors and see if that works for you.    Peace! -=- James


            If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
            Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
            DeleteFXPFiles & CheckFavorites (Please rate this post!)

            I Offline
            I Offline
            IlanTal
            wrote on last edited by
            #5

            Jim shalom, Thanks for your trouble to answer my question. This morning I finally solved the mystery. I've got 2 different machines, one with 2 monitors and vs7 and the second with 1 monitor and vs6. (Change 2 variables at the same time and you've got problems.) The documentation about the SDK managed to confuse me as well. Yesterday I went and looked with the debugger in assembly mode at the 2 monitor system. I saw it went into user32.dll with the integer value. Clearly user32.dll depends only on the operating system and has no connection to vs6 or vs7 (or any SDK for that matter). Thus I manually defined SM_C?VIRTUALSCREEN and SM_MONITORS for vs6 only. Now I call SM_C?VIRTUALSCREEN if and only if SM_MONITORS returns > 1. I initially expected SM_C?VIRTUALSCREEN to return the same value as SM_C?SCREEN (the bounding rectangle of 1 screen), but this is a mistake and it returns zero for 1 monitor. Thus I have to complicate my code a bit and use: if( GetSystemMetrics( SM_CMONITORS) > 1) { m_screen.x = GetSystemMetrics( SM_CXVIRTUALSCREEN); m_screen.y = GetSystemMetrics( SM_CYVIRTUALSCREEN); } else { m_screen.x = GetSystemMetrics( SM_CXSCREEN); m_screen.y = GetSystemMetrics( SM_CYSCREEN); } The bottom line is that it works and I don't need the SDK. It is still operating system dependent, but if I want 2 monitors, that is the price. Thanks again for your help. Shalom, Ilan

            1 Reply Last reply
            0
            • I IlanTal

              I use both Visual Studio 6 and 7. I want to detect and use dual monitors. For this I use GetSystemMetrics(SM_CXVIRTUALSCREEN), which works fine under vs7. Under vs6 SM_CXVIRTUALSCREEN is unknown and it returns zero (after putting in the integer value of the constant). Apparently one way to solve the problem is with the SDK. I would like to know if there is a lighter weight option? Also if I give the software to a friend, does he too need the SDK? My gut feeling is there must be an easier solution. Any suggestions? Thanks, Ilan

              U Offline
              U Offline
              ucc801
              wrote on last edited by
              #6

              Try the following codes: CRect rectFrame, rectView, rectChild, rcScreen; MONITORINFO mi; mi.cbSize = sizeof (MONITORINFO); if (GetMonitorInfo (MonitorFromPoint (CPoint(0,0), MONITOR_DEFAULTTONEAREST), &mi)) { rcScreen = mi.rcMonitor; } else { ::SystemParametersInfo (SPI_GETWORKAREA, 0, &rcScreen, 0); } ...... Jack --------------------------------------------------------------------------------- XD++ MFC/C++ Flow/Diagram Library -- http://www.ucancode.net

              U 1 Reply Last reply
              0
              • U ucc801

                Try the following codes: CRect rectFrame, rectView, rectChild, rcScreen; MONITORINFO mi; mi.cbSize = sizeof (MONITORINFO); if (GetMonitorInfo (MonitorFromPoint (CPoint(0,0), MONITOR_DEFAULTTONEAREST), &mi)) { rcScreen = mi.rcMonitor; } else { ::SystemParametersInfo (SPI_GETWORKAREA, 0, &rcScreen, 0); } ...... Jack --------------------------------------------------------------------------------- XD++ MFC/C++ Flow/Diagram Library -- http://www.ucancode.net

                U Offline
                U Offline
                ucc801
                wrote on last edited by
                #7

                Don't forget to include the following codes: #ifdef _AFXDLL #define COMPILE_MULTIMON_STUBS #endif // _AFXDLL #include "multimon.h" #pragma warning (default : 4706) Jack --------------------------------------------------------------------------------- XD++ MFC/C++ Flow/Diagram Library -- http://www.ucancode.net

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups