|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
Legend: function = function; program = program; SS = Screen Saver; var = variable; Win = Windows; WinMgr (Windows Manager) This program does the following:
Peruse the This is an enhanced version of my second Win32 program, also only my second program in C++/VC++. When I last programmed, I was using Pascal on a 386 SX-16 w/ MS-DOS 5.0 & Win 3.1! You may use this code in any manner you wish, but I request an email notifying me of the use of the code and a return email address so I can reply to you. I simply want to know how often it is being used by others. Please send any improvements, bug reports, complaints or modifications you may have...as I am a beginner. My name is Marc and my email is: mehowe@yahoo.com. You will be credited if I use the modifications in any program I write. This program was written because I burn CD-R's and the SS should be disabled while doing so to avoid transfer interruptions. I didn't want to have to go to my desktop and right-click to open the display properties or open the Control Panel from the start menu. Really, I just wanted to see if I could write a little utility to do various useful Windows tasks. I did not find an article already on CodeProject dealing with this issue, so here is the code. This code should work under UNICODE as well. I have only tested it on two separate machines running Win '98. According to MSDN documentation, this code will work on NT 4.0. Since NT 4.0 doesn't support USB, I am still using Win '98...waiting for Win 2000 Professional, as I understand it, it is the Win 2000 version of NT. This code was written in the MSVC++ 6.0 Pro Edition (w/SR-3 update). Overview of code:NOTE: In WinMgr's project settings, I used MFC as a Statically Linked Library. This causes the compiler to give the following two warnings when set to the Level 4 error checking state: LINK : warning LNK4089: all references to "SHELL32.dll" discarded by /OPT:REF LINK : warning LNK4089: all references to "comdlg32.dll" discarded by /OPT:REF If you receive either of these warnings, you can ignore them (according to documentation). This is just letting you know that the MFC is being used as a Statically Linked Library. Now, the real stuff. First, the InitDialog function calls the Next, if the Enable button is pressed, it calls the The Disable button calls the Onbuttondisable function and works
in the same manner as the The void CWinMgrDlg::OnButtonenabless() { // TODO: Add your control notification handler code here // NOTE: The following code was corrected by Kunz Dieter...Thanks! //declare local bool variable for the SystemParametersInfo func() BOOL pvParam; BOOL l_RetVal_b = SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, &pvParam, 0); // the function call was ok - only in this case the pvParam holds // valid data if(l_RetVal_b) { if (pvParam != FALSE){ //If SS already enabled, do nothing } //end if //If SS disabled, enable it else if (pvParam == FALSE){ //Enable screen saving capability for the current user session SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, TRUE, 0, 0); //Call CheckSSStatus() function to check performance of // SystemParameterInfo() function & update the dialog's // display with current SS status CheckSSStatus(); } //end else if } //end top if } //end OnButtonenabless() void CWinMgrDlg::CheckSSStatus(void) { BOOL pvParam; //declare local bool variable for the //SystemParametersInfo func() BOOL l_RetVal_b = SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, &pvParam, 0); // the function call was ok - only in this case the pvParam // holds valid data if(l_RetVal_b) { if (pvParam == FALSE){ //If SS disabled, send "DISABLED" to read-only // edit control and update the display //m_EditSSStatus is a member Cstring var for the dialog's // edit box m_strEditSSStatus = "DISABLED"; UpdateData(FALSE); } //end if //NOTE: also tried pvParam here as test value else if (pvParam != FALSE) { //If SS enabled, send "ENABLED" to read-only edit control and // update the display m_strEditSSStatus = "ENABLED"; //m_EditSSStatus is a member // Cstring var for the dialog's // edit box UpdateData(FALSE); } //end else if } //end top if } //end CheckSSStatus() void CWinMgrDlg::OnButtonactivatess() { // TODO: Add your control notification handler code here //Add code to check the state of the two check boxes for //ActivateSS options //if() int ActSSVal; ActSSVal = m_dConfigDlg.m_iSSValue; switch(ActSSVal) { case 0: //Exit radio button ActivateSS(); OnOK(); //Now Exit WinMgr break; case 1: //Minimize radio button ShowWindow(SW_MINIMIZE); ActivateSS(); break; } } //End OnButtonactivatess() void CWinMgrDlg::ActivateSS(void) { /*** Code contributed by anonymous source on CodeGuru discussion board...Thank You!***/ CDialog dlg; //Create temp modal dialog //Create temp dialog using IDD_LAUNCHSS_DLG dlg dlg.Create(IDD_LAUNCHSS_DLG); //send SysCommand message calling SS dlg.SendMessage(WM_SYSCOMMAND, SC_SCREENSAVE); dlg.DestroyWindow(); //destroy temporary dialog window //**Notice no call to DoModal()...therefore no window is shown** //Other way to activate SS...doesn't work here //OnSysCommand(SC_SCREENSAVE, SC_SCREENSAVE); } LAST NOTES:LIMITATIONS:
SYSTEM REQUIREMENTS: Appears to use about 200K RAM when running.
May run on any Win'9x or Win NT system...see "Tested On"
below. LEGAL/WARRANTY:This software is (C) Copyrighted 1999 by Marc E. Howe, All Rights Reserved. The author makes no warranties, either expressed or implied regarding the use of any of the WinMgr software. The user is wholly responsible for any and all damages resulting from the use of this software. The author is fully free from all liability regarding the use of this software by the consumer. You may use this code in any manner you wish, but the author requests an email notifying him of the use of the code and a return email address so the author can reply. By using this software, you agree to all of the terms in the above legal / warranty statements. email to Marc at: mehowe@yahoo.com Peace, Honor & Respect,
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||