GetSystemMetrics(SM_CXVIRTUALSCREEN)
-
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
-
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
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 theSM_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!) -
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 theSM_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!) -
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
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!) -
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!)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
-
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
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
-
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
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