<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Did you know? #2</title>
	<atom:link href="http://blog.delphi-jedi.net/2008/05/10/did-you-know2/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.delphi-jedi.net/2008/05/10/did-you-know2/</link>
	<description>Joint Endeavor of Delphi Innovators of Windows Programming</description>
	<pubDate>Thu, 28 Aug 2008 08:10:50 +0000</pubDate>
	<generator>http://wordpress.org/?v=</generator>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: Christian Wimmer</title>
		<link>http://blog.delphi-jedi.net/2008/05/10/did-you-know2/#comment-620</link>
		<dc:creator>Christian Wimmer</dc:creator>
		<pubDate>Sun, 11 May 2008 14:28:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.delphi-jedi.net/?p=195#comment-620</guid>
		<description>The main reason would be: Desktop handling
You can only use SetThreadDesktops, if there aren't any window and hook handles on the current desktop. TApplication from Forms and SvcMgr creates such hooks on initialization.
Since the variable Application is created in the initialization section of the corresponding unit, we have to free it first and then recreate.

I also suspect, that it maybe a problem if Application should be used in a different thread than the main thread. I didn't test or prove it yet. 

However I experienced a problem with VCL that prevented me from switch the current thread back to the previous desktop (winsta0\default). Since there are no window handles (proved by process explorer), I consider a abandoned hook handle as the problem. 
That is the reason why I created a new thread that holds the VCL Application object. As soon as the 2nd thread exits, I can show other forms or messageboxes on the default desktop because the main thread was always connected to the original desktop (default).</description>
		<content:encoded><![CDATA[<p>The main reason would be: Desktop handling<br />
You can only use SetThreadDesktops, if there aren&#8217;t any window and hook handles on the current desktop. TApplication from Forms and SvcMgr creates such hooks on initialization.<br />
Since the variable Application is created in the initialization section of the corresponding unit, we have to free it first and then recreate.</p>
<p>I also suspect, that it maybe a problem if Application should be used in a different thread than the main thread. I didn&#8217;t test or prove it yet. </p>
<p>However I experienced a problem with VCL that prevented me from switch the current thread back to the previous desktop (winsta0\default). Since there are no window handles (proved by process explorer), I consider a abandoned hook handle as the problem.<br />
That is the reason why I created a new thread that holds the VCL Application object. As soon as the 2nd thread exits, I can show other forms or messageboxes on the default desktop because the main thread was always connected to the original desktop (default).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe White</title>
		<link>http://blog.delphi-jedi.net/2008/05/10/did-you-know2/#comment-619</link>
		<dc:creator>Joe White</dc:creator>
		<pubDate>Sun, 11 May 2008 14:16:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.delphi-jedi.net/?p=195#comment-619</guid>
		<description>Just curious... why would you explicitly free TApplication? I can't think of a circumstance where that would make sense (though obviously you know of one).</description>
		<content:encoded><![CDATA[<p>Just curious&#8230; why would you explicitly free TApplication? I can&#8217;t think of a circumstance where that would make sense (though obviously you know of one).</p>
]]></content:encoded>
	</item>
</channel>
</rss>
