Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "WinAPI";
Текущий архив: 2002.01.31;
Скачать: [xml.tar.bz2];

Вниз

надо отключить ScreenSaver помогите плз...   Найти похожие ветки 

 
vov1   (2001-12-04 19:59) [0]

начал писать под API совсем недавно
(сами мы не местные, языкам не обучены...)


 
Holms   (2001-12-04 22:35) [1]

Попробуй

Starting
The method for starting a screen saver is simple, but surprising. You post your
own window a message ! Post yourself the WM_SYSCOMMAND message with the
SC_SCREE
NSAVE parameter :

// Uses MFC CWnd::PostMessage
PostMessage (WM_SYSCOMMAND, SC_SCREENSAVE);


Stopping
Stopping a screen saver is somewhat more complex. The Microsoft-documented
way of doing this is to look for the special screen-saver desktop, enumerate
all windows on that desktop, and close them, as follows:

hdesk = OpenDesktop(TEXT("Screen-saver"),
0,
FALSE,
DESKTOP_READOBJECTS | DESKTOP_WRITEOBJECTS);
if (hdesk)
{
EnumDesktopWindows (hdesk, (WNDENUMPROC)KillScreenSaverFunc, 0);
CloseDesktop (hdesk);
}
// ----------------------------------------------------------------

BOOL CALLBACK KillScreenSaverFunc (HWND hwnd, LPARAM lParam)
{
PostMessage(hwnd, WM_CLOSE, 0, 0);
return TRUE;
}


However, I can"t recommend this approach. I have found when using this code,
NT4 very occasionally seems to get confused and pass you back the normal
desktop handle, in which case you end up trying to close all the normal
application windows. Note, in MS" defence, that the code above for closing
32 bit savers is derived from a sample that is only marked as valid for
NT3.51 - there is no mention of NT4 in the sample. Unfortunately, there is
also nothing to indicate that it doesn"t work properly.

I have subsequently performed some tests, and found that the stock screen
savers supplied with NT4 will in any case get a hit on the window class search
normally used for 16 bit savers ("WindowsScreenSaverClass"). I don"t believe
for a moment that the OpenGL savers (for example) are 16 bit, so maybe MS are
supplying a saver window class that will give the necessary hit. So anyway, you
can use this route :

HWND hSaver = FindWindow ("WindowsScreenSaverClass", NULL);
if (hSaver)
PostMessage (hSaver, WM_CLOSE, 0, 0);

Yet another alternative is now available, which depends upon new functionality
in SystemParametersInfo. This should be even more general :

BOOL bSaver;
if (::SystemParametersInfo (SPI_GETSCREENSAVEACTIVE,0,&bSaver,0))
{
if (bSaver)
{
::PostMessage (::GetForegroundWindow(), WM_CLOSE, 0L, 0L);
}
}



Страницы: 1 вся ветка

Форум: "WinAPI";
Текущий архив: 2002.01.31;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.45 MB
Время: 0.004 c
1-99942
boriska
2002-01-13 02:47
2002.01.31
обращение к именам


3-99918
ЕвгенийА
2001-12-30 19:06
2002.01.31
Запись в поле...


3-99837
RID
2001-12-20 15:46
2002.01.31
Обновление данных в БД Interbase 6.0


4-100116
Miwa
2001-11-30 16:25
2002.01.31
Вывод сообщения


14-100051
fliz
2001-12-07 11:37
2002.01.31
что лучше - сисадминство или прогерство?





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский