<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Desktop disabel - aber wie ?]]></title><description><![CDATA[<p>Hallo,<br />
ich will die Rechnerverwendung während eines Programmvorgangs verhindern. Wie z.B. wenn man den &quot;Herunterfahren&quot; Dialog bei WinXP öffnet und bestimmt jeder auch kennt. Da wird der kmpl. Desktop grau und nur der Dialog ist aktiv.<br />
Leider weiß ich nicht welche Funktion oder welches Vorgehen dazu nötig ist...</p>
<p>Hat jemand eine Idee oder ein Tip...</p>
<p>Besten Dank,<br />
mit freundlichem Gruß<br />
Marcus</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/179051/desktop-disabel-aber-wie</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 17:07:25 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/179051.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 18 Apr 2007 06:30:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Desktop disabel - aber wie ? on Wed, 18 Apr 2007 06:30:25 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich will die Rechnerverwendung während eines Programmvorgangs verhindern. Wie z.B. wenn man den &quot;Herunterfahren&quot; Dialog bei WinXP öffnet und bestimmt jeder auch kennt. Da wird der kmpl. Desktop grau und nur der Dialog ist aktiv.<br />
Leider weiß ich nicht welche Funktion oder welches Vorgehen dazu nötig ist...</p>
<p>Hat jemand eine Idee oder ein Tip...</p>
<p>Besten Dank,<br />
mit freundlichem Gruß<br />
Marcus</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1268112</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1268112</guid><dc:creator><![CDATA[UserMarcus]]></dc:creator><pubDate>Wed, 18 Apr 2007 06:30:25 GMT</pubDate></item><item><title><![CDATA[Reply to Desktop disabel - aber wie ? on Wed, 18 Apr 2007 10:01:37 GMT]]></title><description><![CDATA[<p>Versuch es doch mit BlockInput. Ist nur schlecht wenn dann nach dem<br />
BlockInput dein Programm abschmieren sollte. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1268248</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1268248</guid><dc:creator><![CDATA[Dito]]></dc:creator><pubDate>Wed, 18 Apr 2007 10:01:37 GMT</pubDate></item><item><title><![CDATA[Reply to Desktop disabel - aber wie ? on Wed, 18 Apr 2007 11:37:55 GMT]]></title><description><![CDATA[<p>Dabei wird ein zusätzliches Fenster über den Desktio gelegt. ALT+Tab und Konsorten musst Du abfagen. Es wird Dir nur nicht nmit Strg+Alt+Entf gelingen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1268341</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1268341</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Wed, 18 Apr 2007 11:37:55 GMT</pubDate></item><item><title><![CDATA[Reply to Desktop disabel - aber wie ? on Mon, 23 Apr 2007 08:30:00 GMT]]></title><description><![CDATA[<p>Okay besten Dank für die Antowrten,<br />
hab mir mal ein Beispiel Programm angesehen, leider eine Mischung auf managed und unmanaged Code.</p>
<p>Es ist sind nicht viel Zeilen, hier der Source Code</p>
<pre><code class="language-cpp">/***
	DimmerDialog - A .NET class to show a modal dialog that dims the background.

	Author	:	Nishant Sivakumar
	Email	:	voidnish@gmail.com	
	Blog	:	http://blog.voidnish.com
	Web		:	http://www.voidnish.com 	

	You may freely use this class as long as you include
	this copyright. 

	You may freely modify and use this class as long
	as you include this copyright in your modified version. 

	This code is provided &quot;as is&quot; without express or implied warranty. 

	Copyright © Nishant Sivakumar, 2006.
	All Rights Reserved.
***/

#pragma once

#include &lt;windows.h&gt;
#include &lt;tchar.h&gt;

using namespace System;
using namespace System::Threading;
using namespace System::Windows::Forms;
using namespace System::Drawing;
using namespace System::Drawing::Imaging;
using namespace System::Timers;

LPCTSTR g_desktopname = _T(&quot;{F375AF67-22ED-4ba2-928E-B9DB633AA79C}&quot;);

public ref class DimmerDialog
{
private:
	HDESK m_hOrigDesktop;
	HDESK m_hDimmerDesktop;
	Bitmap^ m_Image;	
	System::Timers::Timer^ m_Timer;
	Form^ m_BackgroundForm;
	Form^ m_MainForm;
	bool m_bShowForm;
	String^ m_text;
	String^ m_title;
	MessageBoxIcon m_icon;
	int m_ColorReductionStep;

	void OnTimer(Object^ source, ElapsedEventArgs^ e)
	{
		if(++m_ColorReductionStep &gt; 4)
			m_Timer-&gt;Enabled = false;
		else
		{
			m_Timer-&gt;Enabled = false;
			((PictureBox^)m_BackgroundForm-&gt;Controls[0])-&gt;Image = DimBitmap();
			m_BackgroundForm-&gt;Controls[0]-&gt;Invalidate();
			m_BackgroundForm-&gt;Controls[0]-&gt;Update();
			m_Timer-&gt;Enabled = true;
		}
	}

	void SwitchToDimmerDesktop()
	{
		m_hOrigDesktop = GetThreadDesktop(GetCurrentThreadId());
		m_hDimmerDesktop = CreateDesktop(g_desktopname,
			NULL,NULL,0,GENERIC_ALL,NULL);
		if(m_hDimmerDesktop)
		{
			if(SetThreadDesktop(m_hDimmerDesktop))
			{
				SwitchDesktop(m_hDimmerDesktop);

				m_ColorReductionStep = 0;
				m_Timer = gcnew System::Timers::Timer;
				m_Timer-&gt;Elapsed += gcnew ElapsedEventHandler(this, &amp;DimmerDialog::OnTimer );
				m_Timer-&gt;Interval = 100;				

				m_BackgroundForm = gcnew Form();
				m_BackgroundForm-&gt;FormBorderStyle = FormBorderStyle::None;
				m_BackgroundForm-&gt;WindowState = FormWindowState::Maximized;
				PictureBox picbox;
				picbox.Dock = DockStyle::Fill;
				picbox.Image = DimBitmap();
				m_BackgroundForm-&gt;Controls-&gt;Add(%picbox);
				m_BackgroundForm-&gt;Show();

				m_Timer-&gt;Enabled = true;
				if(m_bShowForm)
				{
					m_MainForm-&gt;StartPosition = FormStartPosition::CenterParent;
					m_MainForm-&gt;ShowDialog();
				}
				else
				{
					MessageBox::Show(m_text, m_title,
						MessageBoxButtons::OK, m_icon);
				}

				SwitchDesktop(m_hOrigDesktop);
				SetThreadDesktop(m_hOrigDesktop);
			}			
		}
		CloseDesktop(m_hDimmerDesktop);
	}

	void Show()
	{
		HDC hDC = GetDC(NULL); 
		HDC hMemDC = CreateCompatibleDC(hDC);
		SIZE size;
		size.cx = GetSystemMetrics(SM_CXSCREEN);
		size.cy = GetSystemMetrics(SM_CYSCREEN);
		HBITMAP hBitmap = CreateCompatibleBitmap(hDC, size.cx, size.cy);
		if (hBitmap)
		{
			HBITMAP hOld = (HBITMAP) SelectObject(hMemDC, hBitmap);
			BitBlt(hMemDC, 0, 0, size.cx, size.cy, hDC, 0, 0, SRCCOPY);
			SelectObject(hMemDC, hOld);
			DeleteDC(hMemDC);
			ReleaseDC(NULL, hDC);	
			m_Image = Image::FromHbitmap((IntPtr)hBitmap); 
			DeleteObject(hBitmap);
		}
		Thread^ switchthread = gcnew Thread(
			gcnew ThreadStart(this,&amp;DimmerDialog::SwitchToDimmerDesktop));
		switchthread-&gt;Start();		
	}

	Bitmap^ DimBitmap()
	{
		if(m_ColorReductionStep == 0)
			return m_Image;
		Bitmap^ imagecopy = (Bitmap^)m_Image-&gt;Clone();
		BitmapData^ bmData = imagecopy-&gt;LockBits(
			System::Drawing::Rectangle(0, 0, imagecopy-&gt;Width, imagecopy-&gt;Height), 
			ImageLockMode::ReadWrite, PixelFormat::Format24bppRgb); 
		BYTE* p = (BYTE*)bmData-&gt;Scan0.ToPointer();
		int nOffset = bmData-&gt;Stride - imagecopy-&gt;Width * 3; 
		BYTE red, green, blue;
		for(int y=0; y &lt; imagecopy-&gt;Height; y++)
		{
			for(int x=0; x &lt; imagecopy-&gt;Width; x++)
			{
				blue = p[0];
				green = p[1];
				red = p[2];

				switch(m_ColorReductionStep)
				{
				case 1:
					p[0]  = (BYTE)(.001 * red + .286 * green + .713 * blue);
					p[1]  = (BYTE)(.001 * red + .986 * green + .013 * blue);
					p[2]  = (BYTE)(.899 * red + .087 * green + .013 * blue);
					break;
				case 2:
					p[0]  = (BYTE)(.099 * red + .387 * green + .514 * blue);
					p[1]  = (BYTE)(.099 * red + .887 * green + .014 * blue);
					p[2]  = (BYTE)(.699 * red + .287 * green + .013 * blue);
					break;
				case 3:
					p[0]  = (BYTE)(.199 * red + .487 * green + .314 * blue);
					p[1]  = (BYTE)(.199 * red + .787 * green + .014 * blue);
					p[2]  = (BYTE)(.499 * red + .487 * green + .014 * blue);
					break;
				case 4:
					p[0] = p[1] = p[2] = (BYTE)(.299 * red + .587 * green + .114 * blue);
					break;
				}				
				p += 3;
			}
			p += nOffset;
		}
		imagecopy-&gt;UnlockBits(bmData);
		return imagecopy;
	}
public:
	DimmerDialog()
	{
		m_hOrigDesktop = nullptr;
		m_hDimmerDesktop = nullptr;
	}

	void ShowForm(Form^ form)
	{
		m_bShowForm = true;
		m_MainForm = form;
		Show();
	}

	void ShowMessageBox(String^ text, String^ title, MessageBoxIcon icon)
	{
		m_bShowForm = false;
		m_MainForm = nullptr;
		m_text = text;
		m_title = title;
		m_icon = icon;
		Show();
	}
};
</code></pre>
<p>Leider steig ich da nicht ganz durch, ich brauch das ganze in einem reinen VC6 Projekt mit einem Dialog Basierenden Programm.<br />
Hab schon mal etwas mit dem &quot;SetThreadDesktop&quot;, &quot;SwitchDesktop&quot; experimientiert, bekomm ab immer den Fehler &quot;170 The requested resource is in use.&quot;. Hier mein Testcode, jemand eine Idee wie ich weiter komme, soweit ich das verstehe kann man damit eine zusätzlichen Desktop anlegen und den Desktop Thread darauf setzen, somit ist der vorherige Desktop &quot;disabled&quot;...</p>
<pre><code class="language-cpp">_AFX_THREAD_STATE *pState = AfxGetThreadState();

    bool blUnhookOk = UnhookWindowsHookEx(pState-&gt;m_hHookOldMsgFilter);
    pState-&gt;m_hHookOldMsgFilter = NULL;

    LPTSTR g_desktopname = _T(&quot;{F375AF67-22ED-4ba2-928E-B9sdfasdfasdfasdf3AA79C}&quot;);
	HDESK m_hOrigDesktop;
	HDESK m_hDimmerDesktop;
	m_hOrigDesktop = GetThreadDesktop(GetCurrentThreadId());
	m_hDimmerDesktop = CreateDesktop(g_desktopname,
		NULL,NULL,0,GENERIC_ALL,NULL);
	if(m_hDimmerDesktop)
	{
		if(SetThreadDesktop(m_hDimmerDesktop))
		{
			SwitchDesktop(m_hDimmerDesktop);
            AfxMessageBox(_T(&quot;Anderer Desktop&quot;));

			SwitchDesktop(m_hOrigDesktop);
			SetThreadDesktop(m_hOrigDesktop);
        }
        else {
            DWORD dwError = GetLastError();
            CString sOut;
            sOut.Format(_T(&quot;%d&quot;),dwError);
            AfxMessageBox(sOut);
        }
    }
</code></pre>
<p>Besten Dank,<br />
gruss<br />
Marcus</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1271535</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1271535</guid><dc:creator><![CDATA[UserMarcus]]></dc:creator><pubDate>Mon, 23 Apr 2007 08:30:00 GMT</pubDate></item><item><title><![CDATA[Reply to Desktop disabel - aber wie ? on Tue, 24 Apr 2007 01:52:15 GMT]]></title><description><![CDATA[<p>Könnte vielleicht daran liegen:</p>
<p>MSDN schrieb:</p>
<blockquote>
<p>The SetThreadDesktop function will fail if the calling thread has any windows or hooks on its current desktop (unless the hDesktop parameter is a handle to the current desktop).</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1272111</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1272111</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Tue, 24 Apr 2007 01:52:15 GMT</pubDate></item><item><title><![CDATA[Reply to Desktop disabel - aber wie ? on Tue, 24 Apr 2007 07:00:45 GMT]]></title><description><![CDATA[<p>Hab ich auch schon gesehen, deshalb hab ich dieses Zeilen eingefügt :</p>
<pre><code class="language-cpp">_AFX_THREAD_STATE *pState = AfxGetThreadState();

    bool blUnhookOk = UnhookWindowsHookEx(pState-&gt;m_hHookOldMsgFilter);
    pState-&gt;m_hHookOldMsgFilter = NULL;
</code></pre>
<p>Aber scheint keine Verbesserung zu bringen.</p>
<p>gruss<br />
Marcus</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1272155</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1272155</guid><dc:creator><![CDATA[UserMarcus]]></dc:creator><pubDate>Tue, 24 Apr 2007 07:00:45 GMT</pubDate></item></channel></rss>