<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet href="/templates/default/atom.css" type="text/css" ?>

<feed 
   xmlns="http://www.w3.org/2005/Atom"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/">
    <link href="http://johnkoerner.net/index.php?/feeds/atom.xml" rel="self" title="John Koerner's Page" type="application/atom+xml" />
    <link href="http://johnkoerner.net/"                        rel="alternate"    title="John Koerner's Page" type="text/html" />
    <link href="http://johnkoerner.net/rss.php?version=2.0"     rel="alternate"    title="John Koerner's Page" type="application/rss+xml" />
    <title type="html">John Koerner's Page</title>
    <subtitle type="html">Programming, Computers, etc...</subtitle>
    <icon>http://johnkoerner.net/templates/default/img/s9y_banner_small.png</icon>
    <id>http://johnkoerner.net/</id>
    <updated>2009-12-22T03:44:35Z</updated>
    <generator uri="http://www.s9y.org/" version="1.2">Serendipity 1.2 - http://www.s9y.org/</generator>
    <dc:language>en</dc:language>

    <entry>
        <link href="http://johnkoerner.net/index.php?/archives/49-Creating-a-Firewall-Exception-in-VB.Net.html" rel="alternate" title="Creating a Firewall Exception in VB.Net" />
        <author>
            <name>JohnKoer</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2009-12-22T03:30:46Z</published>
        <updated>2009-12-22T03:44:35Z</updated>
        <wfw:comment>http://johnkoerner.net/wfwcomment.php?cid=49</wfw:comment>
    
        <slash:comments>1</slash:comments>
        <wfw:commentRss>http://johnkoerner.net/rss.php?version=atom1.0&amp;type=comments&amp;cid=49</wfw:commentRss>
    
    
        <id>http://johnkoerner.net/index.php?/archives/49-guid.html</id>
        <title type="html">Creating a Firewall Exception in VB.Net</title>
        <content type="xhtml" xml:base="http://johnkoerner.net/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                	<style>
		.code {
			word-wrap:break-word;
			margin:10px;
			padding:10px;
			border:2px ridge white;
			background-color:#eeeeee;
			font-family:Courier New;
			font-size:10pt;
			}
	</style>
Windows Vista and 7 provide a rather robust firewall API that can be used to add exceptions to the firewall.  The code below will add an exception to the windows firewall for the specified application, provided that the code is run with administrator privileges. Add a reference to <b>%systemroot%\system32\FirewallAPI.dll</b> to your application.<br /><br /><div class='code'>
<font color='blue'>Imports&#160;</font><font color='black'>NetFwTypeLib<br />
</font><font color='blue'>Public&#160;Class&#160;</font><font color='black'>Form1<br />
<br />
<br />
&#160;&#160;&#160;&#160;</font><font color='blue'>Private&#160;Sub&#160;</font><font color='black'>Button1_Click(</font><font color='blue'>ByVal&#160;</font><font color='black'>sender&#160;</font><font color='blue'>As&#160;</font><font color='black'>System.</font><font color='blue'>Object</font><font color='black'>,&#160;</font><font color='blue'>ByVal&#160;</font><font color='black'>e&#160;</font><font color='blue'>As&#160;</font><font color='black'>System.EventArgs)&#160;</font><font color='blue'>Handles&#160;</font><font color='black'>Button1.Click<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='darkgreen'>'&#160;Create&#160;the&#160;Application&#160;we&#160;want&#160;to&#160;add&#160;to&#160;the&#160;exception&#160;list<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>Dim&#160;</font><font color='black'>appType&#160;</font><font color='blue'>As&#160;Type&#160;=&#160;Type</font><font color='black'>.GetTypeFromProgID(</font><font color='#808080'>"HnetCfg.FwAuthorizedApplication"</font><font color='black'>)<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>Dim&#160;</font><font color='black'>app&#160;</font><font color='blue'>As&#160;</font><font color='black'>INetFwAuthorizedApplication<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;app&#160;</font><font color='blue'>=&#160;</font><font color='black'>DirectCast(Activator.CreateInstance(appType),&#160;INetFwAuthorizedApplication)<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='darkgreen'>'&#160;Set&#160;the&#160;application&#160;properties<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='black'>app.Name&#160;</font><font color='blue'>=&#160;</font><font color='#808080'>"Negative0's&#160;Sandbox"<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='black'>app.ProcessImageFileName&#160;</font><font color='blue'>=&#160;</font><font color='#808080'>"C:\Users\Negative0\vbsandbox2.exe"<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='black'>app.Enabled&#160;</font><font color='blue'>=&#160;True<br />
<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='darkgreen'>'&#160;Get&#160;the&#160;firewall&#160;manager,&#160;so&#160;we&#160;can&#160;get&#160;the&#160;list&#160;of&#160;authorized&#160;apps<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>Dim&#160;</font><font color='black'>fwMgrType&#160;</font><font color='blue'>As&#160;Type&#160;=&#160;Type</font><font color='black'>.GetTypeFromProgID(</font><font color='#808080'>"HnetCfg.FwMgr"</font><font color='black'>)<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>Dim&#160;</font><font color='black'>fwMgr&#160;</font><font color='blue'>As&#160;</font><font color='black'>INetFwMgr<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;fwMgr&#160;</font><font color='blue'>=&#160;</font><font color='black'>DirectCast(Activator.CreateInstance(fwMgrType),&#160;INetFwMgr)<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='darkgreen'>'&#160;Get&#160;the&#160;list&#160;of&#160;authorized&#160;applications&#160;from&#160;the&#160;Firewall&#160;Manager,&#160;so&#160;we&#160;can&#160;add&#160;our&#160;app&#160;to&#160;that&#160;list<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>Dim&#160;</font><font color='black'>apps&#160;</font><font color='blue'>As&#160;</font><font color='black'>INetFwAuthorizedApplications<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;apps&#160;</font><font color='blue'>=&#160;</font><font color='black'>fwMgr.LocalPolicy.CurrentProfile.AuthorizedApplications<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;apps.Add(app)<br />
<br />
&#160;&#160;&#160;&#160;</font><font color='blue'>End&#160;Sub<br />
<br />
End&#160;Class</font>
	</div>
	<hr style='height:1px;background-color:#808080' />
	<span style='font-family:tahoma;font-size:8pt;color:#808080'>Colorized by: <a style='color:#808080' href="http://johnkoerner.net/exit.php?url_id=91&amp;entry_id=49" title="http://www.CarlosAg.net/Tools/CodeColorizer/"  onmouseover="window.status='http://www.CarlosAg.net/Tools/CodeColorizer/';return true;" onmouseout="window.status='';return true;">CarlosAg.CodeColorizer</a></span>

 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://johnkoerner.net/index.php?/archives/48-Find-Pixels-on-the-screen-by-color-without-using-GetPixel-API..html" rel="alternate" title="Find Pixels on the screen by color without using GetPixel API." />
        <author>
            <name>JohnKoer</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2009-11-30T03:27:00Z</published>
        <updated>2009-12-22T03:38:08Z</updated>
        <wfw:comment>http://johnkoerner.net/wfwcomment.php?cid=48</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://johnkoerner.net/rss.php?version=atom1.0&amp;type=comments&amp;cid=48</wfw:commentRss>
    
    
        <id>http://johnkoerner.net/index.php?/archives/48-guid.html</id>
        <title type="html">Find Pixels on the screen by color without using GetPixel API.</title>
        <content type="xhtml" xml:base="http://johnkoerner.net/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                Occasionally I need to write an app that reads pixels from the screen.  When searching small chunks of the screen, the windows GetPixel API works fine, but if I need to search the whole screen, that gets too slow.  One way that I have found that is about twice as fast as GetPixel is copying the screen to a bitmap and using the Bitmap's GetPixel method.  Below is an extension method that works with the Screen class to find pixels.
<br />
	<style>
		.code {
			word-wrap:break-word;
			margin:10px;
			padding:10px;
			border:2px ridge white;
			background-color:#eeeeee;
			font-family:Courier New;
			font-size:10pt;
			}
	</style>
<div class='code'>
<font color='blue'>Module&#160;</font><font color='black'>ScreenExtensions<br />
&#160;&#160;&#160;&#160;&lt;Extension()&gt;&#160;_<br />
&#160;&#160;&#160;&#160;</font><font color='blue'>Public&#160;Function&#160;</font><font color='black'>FindPixelsByColor(</font><font color='blue'>ByVal&#160;</font><font color='black'>CurrentScreen&#160;</font><font color='blue'>As&#160;</font><font color='black'>Screen,&#160;</font><font color='blue'>ByVal&#160;</font><font color='black'>SearchColor&#160;</font><font color='blue'>As&#160;</font><font color='black'>Color)&#160;</font><font color='blue'>As&#160;</font><font color='black'>List(Of&#160;Point)<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>Dim&#160;</font><font color='black'>ScreenBitmap&#160;</font><font color='blue'>As&#160;</font><font color='black'>Bitmap&#160;</font><font color='blue'>=&#160;</font><font color='black'>Nothing<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>Dim&#160;</font><font color='black'>ScreenCopier&#160;</font><font color='blue'>As&#160;</font><font color='black'>Graphics&#160;</font><font color='blue'>=&#160;</font><font color='black'>Nothing<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>If&#160;</font><font color='black'>CurrentScreen&#160;</font><font color='blue'>Is&#160;</font><font color='black'>Nothing&#160;</font><font color='blue'>Then&#160;Throw&#160;New&#160;</font><font color='black'>ArgumentException(</font><font color='#808080'>"The&#160;screen&#160;object&#160;is&#160;nothing."</font><font color='black'>)<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>If&#160;</font><font color='black'>SearchColor&#160;</font><font color='blue'>=&#160;</font><font color='black'>Color.Empty&#160;</font><font color='blue'>Then&#160;Throw&#160;New&#160;</font><font color='black'>ArgumentException(</font><font color='#808080'>"The&#160;search&#160;color&#160;is&#160;empty."</font><font color='black'>)<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>Try<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='darkgreen'>'&#160;Initialize&#160;our&#160;output&#160;of&#160;points.<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>Dim&#160;</font><font color='black'>OutputPoints&#160;</font><font color='blue'>As&#160;New&#160;</font><font color='black'>List(Of&#160;Point)<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='darkgreen'>'&#160;Create&#160;the&#160;bitmap&#160;object&#160;that&#160;will&#160;be&#160;used&#160;to&#160;store&#160;the&#160;image&#160;of&#160;the&#160;screen.<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='black'>ScreenBitmap&#160;</font><font color='blue'>=&#160;New&#160;</font><font color='black'>Bitmap(CurrentScreen.WorkingArea.Width,&#160;CurrentScreen.WorkingArea.Height,&#160;_<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Imaging.PixelFormat.Format32bppArgb)<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='darkgreen'>'&#160;Create&#160;the&#160;graphics&#160;object&#160;that&#160;will&#160;be&#160;used&#160;to&#160;copy&#160;the&#160;screen&#160;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='black'>ScreenCopier&#160;</font><font color='blue'>=&#160;</font><font color='black'>Graphics.FromImage(ScreenBitmap)<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='darkgreen'>'&#160;Copy&#160;from&#160;the&#160;screen&#160;to&#160;the&#160;bitmap,&#160;so&#160;we&#160;can&#160;search&#160;for&#160;the&#160;pixels&#160;we&#160;are&#160;looking&#160;for<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='black'>ScreenCopier.CopyFromScreen(</font><font color='blue'>New&#160;</font><font color='black'>Point(</font><font color='maroon'>0</font><font color='black'>,&#160;</font><font color='maroon'>0</font><font color='black'>),&#160;</font><font color='blue'>New&#160;</font><font color='black'>Point(</font><font color='maroon'>0</font><font color='black'>,&#160;</font><font color='maroon'>0</font><font color='black'>),&#160;_<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>New&#160;</font><font color='black'>Size(CurrentScreen.WorkingArea.Width,&#160;CurrentScreen.WorkingArea.Height))<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>Dim&#160;</font><font color='black'>ScreenColor&#160;</font><font color='blue'>As&#160;</font><font color='black'>Color<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='darkgreen'>'&#160;Loop&#160;through&#160;all&#160;of&#160;the&#160;pixels&#160;in&#160;the&#160;bitmap<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>For&#160;</font><font color='black'>x&#160;</font><font color='blue'>As&#160;Integer&#160;=&#160;</font><font color='maroon'>0&#160;</font><font color='blue'>To&#160;</font><font color='black'>CurrentScreen.WorkingArea.Width&#160;-&#160;</font><font color='maroon'>1<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>For&#160;</font><font color='black'>y&#160;</font><font color='blue'>As&#160;Integer&#160;=&#160;</font><font color='maroon'>0&#160;</font><font color='blue'>To&#160;</font><font color='black'>CurrentScreen.WorkingArea.Height&#160;-&#160;</font><font color='maroon'>1<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='darkgreen'>'&#160;Get&#160;the&#160;color&#160;at&#160;the&#160;current&#160;pixel&#160;from&#160;the&#160;screenshot.<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='black'>ScreenColor&#160;</font><font color='blue'>=&#160;</font><font color='black'>ScreenBitmap.GetPixel(x,&#160;y)<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='darkgreen'>'&#160;Compare&#160;the&#160;color&#160;from&#160;the&#160;screenshot&#160;with&#160;the&#160;desired&#160;color.&#160;&#160;We&#160;need&#160;to&#160;level&#160;off&#160;the&#160;alpha&#160;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;'&#160;for&#160;this&#160;compare&#160;to&#160;work&#160;properly.&#160;&#160;All&#160;colors&#160;from&#160;the&#160;screenshot&#160;have&#160;an&#160;alpha&#160;of&#160;255.<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>If&#160;</font><font color='black'>ScreenColor&#160;</font><font color='blue'>=&#160;</font><font color='black'>Color.FromArgb(</font><font color='maroon'>255</font><font color='black'>,&#160;SearchColor)&#160;</font><font color='blue'>Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='darkgreen'>'&#160;If&#160;we&#160;have&#160;a&#160;match,&#160;then&#160;add&#160;the&#160;current&#160;x,y&#160;to&#160;our&#160;output.<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='black'>OutputPoints.Add(</font><font color='blue'>New&#160;</font><font color='black'>Point(x,&#160;y))<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>End&#160;If<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Next<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Next<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Return&#160;</font><font color='black'>OutputPoints<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>Catch&#160;</font><font color='black'>ex&#160;</font><font color='blue'>As&#160;Exception<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Throw&#160;New&#160;Exception</font><font color='black'>(</font><font color='#808080'>"Unable&#160;to&#160;perform&#160;pixel&#160;search."</font><font color='black'>,&#160;ex)<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>Finally<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;If&#160;</font><font color='black'>ScreenBitmap&#160;IsNot&#160;Nothing&#160;</font><font color='blue'>Then&#160;</font><font color='black'>ScreenBitmap.Dispose()<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>If&#160;</font><font color='black'>ScreenCopier&#160;IsNot&#160;Nothing&#160;</font><font color='blue'>Then&#160;</font><font color='black'>ScreenCopier.Dispose()<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>End&#160;Try<br />
&#160;&#160;&#160;&#160;End&#160;Function<br />
End&#160;Module</font>
	</div>
	<hr style='height:1px;background-color:#808080' />
	<span style='font-family:tahoma;font-size:8pt;color:#808080'>Colorized by: <a style='color:#808080' href="http://johnkoerner.net/exit.php?url_id=90&amp;entry_id=48" title="http://www.CarlosAg.net/Tools/CodeColorizer/"  onmouseover="window.status='http://www.CarlosAg.net/Tools/CodeColorizer/';return true;" onmouseout="window.status='';return true;">CarlosAg.CodeColorizer</a></span>

	<hr style='height:1px;background-color:#808080' />

<br /><br />To use this class. You can simply call it from any screen object.  For example:
<br /><br /><div class='code'>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<font color='blue'>Dim&#160;</font><font color='black'>l&#160;</font><font color='blue'>As&#160;</font><font color='black'>List(Of&#160;Point)<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;l&#160;</font><font color='blue'>=&#160;</font><font color='black'>Screen.PrimaryScreen.FindPixelsByColor(Color.FromArgb(</font><font color='maroon'>128</font><font color='black'>,&#160;</font><font color='maroon'>128</font><font color='black'>,&#160;</font><font color='maroon'>128</font><font color='black'>))<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;MessageBox.Show(l.Count.ToString())</font>
	</div>
	<hr style='height:1px;background-color:#808080' />
	<span style='font-family:tahoma;font-size:8pt;color:#808080'>Colorized by: <a style='color:#808080' href="http://johnkoerner.net/exit.php?url_id=90&amp;entry_id=48" title="http://www.CarlosAg.net/Tools/CodeColorizer/"  onmouseover="window.status='http://www.CarlosAg.net/Tools/CodeColorizer/';return true;" onmouseout="window.status='';return true;">CarlosAg.CodeColorizer</a></span>

<br />	 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://johnkoerner.net/index.php?/archives/47-Taking-a-screenshot-in-VB.Net.html" rel="alternate" title="Taking a screenshot in VB.Net" />
        <author>
            <name>JohnKoer</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2009-03-14T17:24:00Z</published>
        <updated>2009-12-22T03:42:52Z</updated>
        <wfw:comment>http://johnkoerner.net/wfwcomment.php?cid=47</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://johnkoerner.net/rss.php?version=atom1.0&amp;type=comments&amp;cid=47</wfw:commentRss>
    
    
        <id>http://johnkoerner.net/index.php?/archives/47-guid.html</id>
        <title type="html">Taking a screenshot in VB.Net</title>
        <content type="xhtml" xml:base="http://johnkoerner.net/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                Taking a screenshot from a .Net app is very easy.  The function to use is the CopyFromScreen function from the Graphics class.
<br /><br />
	<style>
		.code {
			word-wrap:break-word;
			margin:10px;
			padding:10px;
			border:2px ridge white;
			background-color:#eeeeee;
			font-family:Courier New;
			font-size:10pt;
			}
	</style><div class='code'>
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<font color='blue'>Dim&#160;</font><font color='black'>b&#160;</font><font color='blue'>As&#160;</font><font color='black'>Bitmap<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='darkgreen'>'Hide&#160;the&#160;form,&#160;so&#160;it&#160;doesn't&#160;show&#160;in&#160;the&#160;screenshot<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>Me</font><font color='black'>.Hide()<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;b&#160;</font><font color='blue'>=&#160;New&#160;</font><font color='black'>Bitmap(My.Computer.Screen.WorkingArea.Width,&#160;_<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;My.Computer.Screen.WorkingArea.Height,&#160;_<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Imaging.PixelFormat.Format32bppArgb)<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>Dim&#160;</font><font color='black'>g&#160;</font><font color='blue'>As&#160;</font><font color='black'>Graphics&#160;</font><font color='blue'>=&#160;</font><font color='black'>Graphics.FromImage(b)<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;g.CopyFromScreen(</font><font color='blue'>New&#160;</font><font color='black'>Point(</font><font color='maroon'>0</font><font color='black'>,&#160;</font><font color='maroon'>0</font><font color='black'>),&#160;</font><font color='blue'>New&#160;</font><font color='black'>Point(</font><font color='maroon'>0</font><font color='black'>,&#160;</font><font color='maroon'>0</font><font color='black'>),&#160;_<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>New&#160;</font><font color='black'>Size(My.Computer.Screen.WorkingArea.Width,&#160;_<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;My.Computer.Screen.WorkingArea.Height))<br />
<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='darkgreen'>'Show&#160;the&#160;form&#160;again<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>Me</font><font color='black'>.Show()<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='darkgreen'>'Save&#160;the&#160;file<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>Dim&#160;</font><font color='black'>ofd&#160;</font><font color='blue'>As&#160;New&#160;</font><font color='black'>SaveFileDialog&#160;()<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ofd.Filter&#160;</font><font color='blue'>=&#160;</font><font color='#808080'>"(*.bmp)|*.bmp"<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>If&#160;</font><font color='black'>ofd.ShowDialog()&#160;</font><font color='blue'>=&#160;</font><font color='black'>Windows.Forms.DialogResult.OK&#160;</font><font color='blue'>Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='black'>b.Save(ofd.FileName)<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>End&#160;If&#160;</font>
	</div>
	<hr style='height:1px;background-color:#808080' />
	<span style='font-family:tahoma;font-size:8pt;color:#808080'>Colorized by: <a style='color:#808080' href="http://johnkoerner.net/exit.php?url_id=92&amp;entry_id=47" title="http://www.CarlosAg.net/Tools/CodeColorizer/"  onmouseover="window.status='http://www.CarlosAg.net/Tools/CodeColorizer/';return true;" onmouseout="window.status='';return true;">CarlosAg.CodeColorizer</a></span>
 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://johnkoerner.net/index.php?/archives/46-Using-the-ShowWindow-API-on-a-VB6-App-from-.Net.html" rel="alternate" title="Using the ShowWindow API on a VB6 App from .Net" />
        <author>
            <name>JohnKoer</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2009-02-13T03:14:00Z</published>
        <updated>2009-02-13T03:14:00Z</updated>
        <wfw:comment>http://johnkoerner.net/wfwcomment.php?cid=46</wfw:comment>
    
        <slash:comments>1</slash:comments>
        <wfw:commentRss>http://johnkoerner.net/rss.php?version=atom1.0&amp;type=comments&amp;cid=46</wfw:commentRss>
    
    
        <id>http://johnkoerner.net/index.php?/archives/46-guid.html</id>
        <title type="html">Using the ShowWindow API on a VB6 App from .Net</title>
        <content type="xhtml" xml:base="http://johnkoerner.net/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                I was helping someone with an issue <a href="http://johnkoerner.net/exit.php?url_id=88&amp;entry_id=46" title="http://www.vbforums.com/showthread.php?t=557314"  onmouseover="window.status='http://www.vbforums.com/showthread.php?t=557314';return true;" onmouseout="window.status='';return true;">restoring </a> vb6 windows from a .Net application over on <a href="http://johnkoerner.net/exit.php?url_id=89&amp;entry_id=46" title="http://www.vbforums.com"  onmouseover="window.status='http://www.vbforums.com';return true;" onmouseout="window.status='';return true;">VBForums</a>.  The issue ended up being that the MainWindowHandle of the process was returning the window handle for the ThunderRT6Main window.  The ThunderRT6Main is a hidden window that all VB6 apps have that is used for message processing.  When we called ShowWindow against this window handle, nothing would happen.  To get around this, I ended up calling the GetWindow API with a GW_HWNDPREV to get the window handle of the form window and then called ShowWindow on that.<br /><br />
	<div class='code'>
&#160;<font color='blue'>Private&#160;</font><font color='black'>SW_SHOWNORMAL&#160;</font><font color='blue'>As&#160;Integer&#160;=&#160;</font><font color='black'>&H1<br />
&#160;&#160;&#160;&#160;&lt;Runtime.InteropServices.DllImport(</font><font color='#808080'>"user32"</font><font color='black'>,&#160;EntryPoint:</font><font color='blue'>=</font><font color='#808080'>"ShowWindow"</font><font color='black'>)&gt;&#160;_<br />
&#160;&#160;&#160;&#160;</font><font color='blue'>Private&#160;Shared&#160;Function&#160;</font><font color='black'>ShowWindow(</font><font color='blue'>ByVal&#160;</font><font color='black'>hwnd&#160;</font><font color='blue'>As&#160;</font><font color='black'>IntPtr,&#160;</font><font color='blue'>ByVal&#160;</font><font color='black'>nCmdShow&#160;</font><font color='blue'>As&#160;Integer</font><font color='black'>)&#160;</font><font color='blue'>As&#160;Integer<br />
&#160;&#160;&#160;&#160;End&#160;Function<br />
<br />
&#160;&#160;&#160;&#160;</font><font color='black'>Declare&#160;Auto&#160;</font><font color='blue'>Function&#160;</font><font color='black'>GetWindow&#160;Lib&#160;</font><font color='#808080'>"user32.dll"&#160;</font><font color='black'>(&#160;_<br />
</font><font color='blue'>ByVal&#160;</font><font color='black'>hWnd&#160;</font><font color='blue'>As&#160;</font><font color='black'>IntPtr,&#160;</font><font color='blue'>ByVal&#160;</font><font color='black'>uCmd&#160;</font><font color='blue'>As&#160;</font><font color='black'>UInt32)&#160;</font><font color='blue'>As&#160;</font><font color='black'>IntPtr<br />
<br />
&#160;&#160;&#160;&#160;</font><font color='blue'>Const&#160;</font><font color='black'>GW_HWNDPREV&#160;</font><font color='blue'>As&#160;Integer&#160;=&#160;</font><font color='maroon'>3<br />
<br />
&#160;&#160;&#160;&#160;</font><font color='blue'>Dim&#160;</font><font color='black'>proc&#160;</font><font color='blue'>As&#160;New&#160;</font><font color='black'>Process<br />
<br />
&#160;&#160;&#160;&#160;</font><font color='blue'>Private&#160;Sub&#160;</font><font color='black'>Button1_Click(</font><font color='blue'>ByVal&#160;</font><font color='black'>sender&#160;</font><font color='blue'>As&#160;</font><font color='black'>System.</font><font color='blue'>Object</font><font color='black'>,&#160;</font><font color='blue'>ByVal&#160;</font><font color='black'>e&#160;</font><font color='blue'>As&#160;</font><font color='black'>System.EventArgs)&#160;</font><font color='blue'>Handles&#160;</font><font color='black'>Button1.Click<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='darkgreen'>'&#160;Start&#160;the&#160;process<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>With&#160;</font><font color='black'>proc<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.StartInfo.FileName&#160;</font><font color='blue'>=&#160;</font><font color='#808080'>"c:\temp\project1.exe"<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='black'>.Start()<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>End&#160;With<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='darkgreen'>'&#160;Wait&#160;for&#160;it&#160;to&#160;finish&#160;loading&#160;and&#160;put&#160;the&#160;window&#160;handle&#160;into&#160;the&#160;form&#160;caption<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='black'>proc.WaitForInputIdle(</font><font color='maroon'>10000</font><font color='black'>)<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>Me</font><font color='black'>.Text&#160;</font><font color='blue'>=&#160;</font><font color='black'>proc.MainWindowHandle.ToString(</font><font color='#808080'>"x8"</font><font color='black'>)<br />
<br />
&#160;&#160;&#160;&#160;</font><font color='blue'>End&#160;Sub<br />
<br />
<br />
&#160;&#160;&#160;&#160;Private&#160;Sub&#160;</font><font color='black'>Button2_Click(</font><font color='blue'>ByVal&#160;</font><font color='black'>sender&#160;</font><font color='blue'>As&#160;</font><font color='black'>System.</font><font color='blue'>Object</font><font color='black'>,&#160;</font><font color='blue'>ByVal&#160;</font><font color='black'>e&#160;</font><font color='blue'>As&#160;</font><font color='black'>System.EventArgs)&#160;</font><font color='blue'>Handles&#160;</font><font color='black'>Button2.Click<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='darkgreen'>'&#160;Call&#160;GetWindow&#160;with&#160;GW_HWNDPREV&#160;to&#160;get&#160;the&#160;form&#160;from&#160;the&#160;ThunderRT6Main&#160;window<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='blue'>Dim&#160;</font><font color='black'>vb6Window&#160;</font><font color='blue'>As&#160;</font><font color='black'>IntPtr&#160;</font><font color='blue'>=&#160;</font><font color='black'>GetWindow(proc.MainWindowHandle,&#160;GW_HWNDPREV)<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='darkgreen'>'&#160;Call&#160;ShowWindow&#160;on&#160;the&#160;window&#160;we&#160;got&#160;back&#160;from&#160;the&#160;last&#160;call,&#160;which&#160;should&#160;be&#160;the&#160;ThunderRT6FormDC&#160;window<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</font><font color='black'>ShowWindow(vb6Window,&#160;SW_SHOWNORMAL)<br />
<br />
&#160;&#160;&#160;&#160;</font><font color='blue'>End&#160;Sub</font>
	</div> 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://johnkoerner.net/index.php?/archives/45-Keyboard-Listener.html" rel="alternate" title="Keyboard Listener" />
        <author>
            <name>JohnKoer</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2008-11-24T20:30:28Z</published>
        <updated>2008-11-24T20:45:20Z</updated>
        <wfw:comment>http://johnkoerner.net/wfwcomment.php?cid=45</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://johnkoerner.net/rss.php?version=atom1.0&amp;type=comments&amp;cid=45</wfw:commentRss>
    
    
        <id>http://johnkoerner.net/index.php?/archives/45-guid.html</id>
        <title type="html">Keyboard Listener</title>
        <content type="xhtml" xml:base="http://johnkoerner.net/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                Whenever I need to write a keyboard listener, I always have to go back and search through old code to get the exact syntax.  I then end up copying and pasting a whole bunch of code.  I decided it was time to create a DLL that will handle all of this work for me.  I also decided that I will post the DLL up here for anyone to use as they see fit.
<br /><br />
The DLL is copyrighted, however, it is free for distribution with personal or commercial applications.
<br /><br />
The setup package, which includes a help file, a sample app, and the DLL, can be downloaded from the downloads page, or from the link below.
<br /><br />

Download: <a href="http://johnkoerner.net/exit.php?url_id=87&amp;entry_id=45" title="http://johnkoerner.com/dl/KeyboardListener.msi"  onmouseover="window.status='http://johnkoerner.com/dl/KeyboardListener.msi';return true;" onmouseout="window.status='';return true;">KeyboardListener.msi</a>
<br /><br />
The sample app shows off the basic functionality of listening for one particular key, a set number of keys, or all key presses on a system.  Below is a screenshot of the sample application.  This dll works system wide, not just within the application that is using it.
<br /><br />
<img src="http://www.johnkoerner.com/images/KeyboardListenerForm.png" alt="" /> 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://johnkoerner.net/index.php?/archives/43-Creating-a-Plugin-Architecture-in-C.html" rel="alternate" title="Creating a Plugin Architecture in C#" />
        <author>
            <name>JohnKoer</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2008-07-21T23:22:00Z</published>
        <updated>2008-07-27T22:40:10Z</updated>
        <wfw:comment>http://johnkoerner.net/wfwcomment.php?cid=43</wfw:comment>
    
        <slash:comments>13</slash:comments>
        <wfw:commentRss>http://johnkoerner.net/rss.php?version=atom1.0&amp;type=comments&amp;cid=43</wfw:commentRss>
    
            <category scheme="http://johnkoerner.net/index.php?/categories/3-C" label="C#" term="C#" />
            <category scheme="http://johnkoerner.net/index.php?/categories/1-Programming" label="Programming" term="Programming" />
    
        <id>http://johnkoerner.net/index.php?/archives/43-guid.html</id>
        <title type="html">Creating a Plugin Architecture in C#</title>
        <content type="xhtml" xml:base="http://johnkoerner.net/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                Creating a plugin architecture in a C# application is a fairly easy task.  The video below will walk you through the process of setting up the plugin architecture and it will implement a simple plugin.
<br /><br />
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="800" height="618"> <param name="movie" value="http://content.screencast.com/bootstrap.swf"></param> <param name="quality" value="high"></param> <param name="bgcolor" value="#FFFFFF"></param> <param name="flashVars" value="thumb=http://content.screencast.com/media/b304898a-52aa-42a9-8fec-d08f3b8abad4_580137e2-a83d-47da-bd2e-169abe0ae4ba_static_0_0_Thumbnail.gif&content=http://content.screencast.com/media/89d0bc8f-67b9-4087-a0a5-02d5fd684aa0_580137e2-a83d-47da-bd2e-169abe0ae4ba_static_0_0_2008-07-19_2228%20Creating%20a%20plugin%20interface%20in%20C#.swf&width=800&height=618"></param> <param name="allowFullScreen" value="true"></param> <param name="scale" value="showall"></param> <param name="allowScriptAccess" value="always"></param>  <embed src="http://content.screencast.com/bootstrap.swf" quality="high" bgcolor="#FFFFFF" width="800" height="618" type="application/x-shockwave-flash" allowScriptAccess="always" flashVars="thumb=http://content.screencast.com/media/b304898a-52aa-42a9-8fec-d08f3b8abad4_580137e2-a83d-47da-bd2e-169abe0ae4ba_static_0_0_Thumbnail.gif&content=http://content.screencast.com/media/89d0bc8f-67b9-4087-a0a5-02d5fd684aa0_580137e2-a83d-47da-bd2e-169abe0ae4ba_static_0_0_2008-07-19_2228%20Creating%20a%20plugin%20interface%20in%20C#.swf&width=800&height=618" allowFullScreen="true" scale="showall"></embed> </object>
<br /><br />
The source for the project can be downloaded <a href="http://johnkoerner.net/uploads/PulginExample-ImageViewer.zip" title="PulginExample-ImageViewer.zip" target="_blank">Here</a>. 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://johnkoerner.net/index.php?/archives/42-Conditionally-Formatting-ComboBox-Items-in-C.html" rel="alternate" title="Conditionally Formatting ComboBox Items in C#" />
        <author>
            <name>JohnKoer</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2008-07-09T02:54:41Z</published>
        <updated>2008-07-09T03:08:35Z</updated>
        <wfw:comment>http://johnkoerner.net/wfwcomment.php?cid=42</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://johnkoerner.net/rss.php?version=atom1.0&amp;type=comments&amp;cid=42</wfw:commentRss>
    
            <category scheme="http://johnkoerner.net/index.php?/categories/3-C" label="C#" term="C#" />
            <category scheme="http://johnkoerner.net/index.php?/categories/1-Programming" label="Programming" term="Programming" />
            <category scheme="http://johnkoerner.net/index.php?/categories/2-Windows" label="Windows" term="Windows" />
    
        <id>http://johnkoerner.net/index.php?/archives/42-guid.html</id>
        <title type="html">Conditionally Formatting ComboBox Items in C#</title>
        <content type="xhtml" xml:base="http://johnkoerner.net/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                The video below gives an overview of creating a ComboBox that does conditional formatting.  The code uses regular expressions to determine if an item in a combobox should have special formatting.  The code is nowhere near production ready, but it should give you an idea of how to do formatting of items in a combobox drop down list.  See the full post if you want to copy the code.<br /><br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="800" height="618"> <param name="movie" value="http://content.screencast.com/bootstrap.swf"></param> <param name="quality" value="high"></param> <param name="bgcolor" value="#FFFFFF"></param> <param name="flashVars" value="thumb=http://content.screencast.com/media/96f49c69-a937-4937-9b1b-cf8aa0fd9f9c_580137e2-a83d-47da-bd2e-169abe0ae4ba_static_0_0_Thumbnail.gif&content=http://content.screencast.com/media/bb11c7d8-d9f2-433d-87b1-e0054d19eb09_580137e2-a83d-47da-bd2e-169abe0ae4ba_static_0_0_2008-07-08_2232%20-%20Combobox%20Drawing.swf&width=800&height=618"></param> <param name="allowFullScreen" value="true"></param> <param name="scale" value="showall"></param> <param name="allowScriptAccess" value="always"></param>  <embed src="http://content.screencast.com/bootstrap.swf" quality="high" bgcolor="#FFFFFF" width="800" height="618" type="application/x-shockwave-flash" allowScriptAccess="always" flashVars="thumb=http://content.screencast.com/media/96f49c69-a937-4937-9b1b-cf8aa0fd9f9c_580137e2-a83d-47da-bd2e-169abe0ae4ba_static_0_0_Thumbnail.gif&content=http://content.screencast.com/media/bb11c7d8-d9f2-433d-87b1-e0054d19eb09_580137e2-a83d-47da-bd2e-169abe0ae4ba_static_0_0_2008-07-08_2232%20-%20Combobox%20Drawing.swf&width=800&height=618" allowFullScreen="true" scale="showall"></embed> </object><br /><br />
 <br /><a href="http://johnkoerner.net/index.php?/archives/42-Conditionally-Formatting-ComboBox-Items-in-C.html#extended">Continue reading "Conditionally Formatting ComboBox Items in C#"</a>
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://johnkoerner.net/index.php?/archives/41-New-Download-Available.html" rel="alternate" title="New Download Available" />
        <author>
            <name>JohnKoer</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2008-06-12T03:55:08Z</published>
        <updated>2008-06-12T03:55:08Z</updated>
        <wfw:comment>http://johnkoerner.net/wfwcomment.php?cid=41</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://johnkoerner.net/rss.php?version=atom1.0&amp;type=comments&amp;cid=41</wfw:commentRss>
    
    
        <id>http://johnkoerner.net/index.php?/archives/41-guid.html</id>
        <title type="html">New Download Available</title>
        <content type="xhtml" xml:base="http://johnkoerner.net/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                I have added a SCORM compliant version of the <a href="index.php?/archives/40-Creating-Content-for-the-SharePoint-Learning-Kit.html#extended">Creating Content for the SharePoint Learning Kit</a> video to the <a href=index.php?/archives/23-Downloads.html>downloads</a> page if you would like to have a copy of it in your own SharePoint site. 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://johnkoerner.net/index.php?/archives/40-Creating-Content-for-the-SharePoint-Learning-Kit.html" rel="alternate" title="Creating Content for the SharePoint Learning Kit" />
        <author>
            <name>JohnKoer</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2008-06-10T03:36:15Z</published>
        <updated>2008-07-09T03:09:22Z</updated>
        <wfw:comment>http://johnkoerner.net/wfwcomment.php?cid=40</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://johnkoerner.net/rss.php?version=atom1.0&amp;type=comments&amp;cid=40</wfw:commentRss>
    
            <category scheme="http://johnkoerner.net/index.php?/categories/10-SharePoint" label="SharePoint" term="SharePoint" />
            <category scheme="http://johnkoerner.net/index.php?/categories/12-SLK" label="SLK" term="SLK" />
    
        <id>http://johnkoerner.net/index.php?/archives/40-guid.html</id>
        <title type="html">Creating Content for the SharePoint Learning Kit</title>
        <content type="xhtml" xml:base="http://johnkoerner.net/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                Here is a new video demonstrating how to create SCORM content for the SharePoint Learning Kit.<br /><br />
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="800" height="618"> <param name="movie" value="http://content.screencast.com/bootstrap.swf"></param> <param name="quality" value="high"></param> <param name="bgcolor" value="#FFFFFF"></param> <param name="flashVars" value="thumb=http://content.screencast.com/media/e36ac792-8b0e-4b3d-a9ea-ddc8c33b96f3_580137e2-a83d-47da-bd2e-169abe0ae4ba_static_0_0_Thumbnail.gif&content=http://content.screencast.com/media/8a0452c4-c0bf-44e8-9663-0c5cf8a8fbdb_580137e2-a83d-47da-bd2e-169abe0ae4ba_static_0_0_Creating%20Content%20for%20the%20Sharepoint%20Learning%20Kit.swf&width=800&height=618"></param> <param name="allowFullScreen" value="true"></param> <param name="scale" value="showall"></param> <param name="allowScriptAccess" value="always"></param>  <embed src="http://content.screencast.com/bootstrap.swf" quality="high" bgcolor="#FFFFFF" width="800" height="618" type="application/x-shockwave-flash" allowScriptAccess="always" flashVars="thumb=http://content.screencast.com/media/e36ac792-8b0e-4b3d-a9ea-ddc8c33b96f3_580137e2-a83d-47da-bd2e-169abe0ae4ba_static_0_0_Thumbnail.gif&content=http://content.screencast.com/media/8a0452c4-c0bf-44e8-9663-0c5cf8a8fbdb_580137e2-a83d-47da-bd2e-169abe0ae4ba_static_0_0_Creating%20Content%20for%20the%20Sharepoint%20Learning%20Kit.swf&width=800&height=618" allowFullScreen="true" scale="showall"></embed> </object><br /><br />


Resources:<br />
	<a href=http://www.scorm.com/products/scormdriverauthoring.aspx>SCORM Simple Content API </a> <br />
	<a href=http://www.jingproject.com>Jing Project </a><br />
	<a href=http://www.codeplex.com/SLK>SharePoint Learning Kit</a><br />
 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://johnkoerner.net/index.php?/archives/39-MOSS-Adding-sub-navigation.html" rel="alternate" title="MOSS: Adding sub navigation" />
        <author>
            <name>JohnKoer</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2008-05-17T20:42:59Z</published>
        <updated>2008-06-12T03:34:44Z</updated>
        <wfw:comment>http://johnkoerner.net/wfwcomment.php?cid=39</wfw:comment>
    
        <slash:comments>2</slash:comments>
        <wfw:commentRss>http://johnkoerner.net/rss.php?version=atom1.0&amp;type=comments&amp;cid=39</wfw:commentRss>
    
            <category scheme="http://johnkoerner.net/index.php?/categories/10-SharePoint" label="SharePoint" term="SharePoint" />
    
        <id>http://johnkoerner.net/index.php?/archives/39-guid.html</id>
        <title type="html">MOSS: Adding sub navigation</title>
        <content type="xhtml" xml:base="http://johnkoerner.net/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                I found a nice little <a href=http://www.heathersolomon.com/blog/archive/2007/05/15/SharePoint-Tip--How-to-Activate-the-Drop-Down-Menu.aspx>post</a> from Heather Solomon on allowing SharePoint to have multiple levels of sub navigation.  It works really well, but the navigation editor in MOSS does not let you nest sub-menus by default.  I wrote a quick little C# app that allowed me to add navigation as needed.  Here is the meat of the code.<br />
<br />
            SPNavigationNode oNewNode = new SPNavigationNode("My New Tab3","");<br />
            oWeb.Navigation.TopNavigationBar.AddAsLast(oNewNode);<br />
            oNewNode.Properties.Add("NodeType","Heading");<br />
            oNewNode.Update();<br />
<br />
            SPNavigationNode oChild1 = new SPNavigationNode("C1","/");<br />
            oNewNode.Children.AddAsFirst(oChild1);<br />
            oChild1.Properties.Add("NodeType","Heading");<br />
            oChild1.Update();<br />
<br />
            SPNavigationNode oChild2 = new SPNavigationNode("C2","/");<br />
            oChild1.Children.AddAsFirst(oChild2);<br />
<br />
Note: I have only tested this on MOSS 2007 and it did some weird things to my tab highlighting that I haven't figured out yet. 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://johnkoerner.net/index.php?/archives/38-Visual-Studio-Extensions-for-Sharepoint-ListDefinition1.html" rel="alternate" title="Visual Studio Extensions for Sharepoint - ListDefinition1" />
        <author>
            <name>JohnKoer</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2008-04-20T15:46:03Z</published>
        <updated>2008-06-12T03:34:59Z</updated>
        <wfw:comment>http://johnkoerner.net/wfwcomment.php?cid=38</wfw:comment>
    
        <slash:comments>1</slash:comments>
        <wfw:commentRss>http://johnkoerner.net/rss.php?version=atom1.0&amp;type=comments&amp;cid=38</wfw:commentRss>
    
            <category scheme="http://johnkoerner.net/index.php?/categories/3-C" label="C#" term="C#" />
            <category scheme="http://johnkoerner.net/index.php?/categories/10-SharePoint" label="SharePoint" term="SharePoint" />
    
        <id>http://johnkoerner.net/index.php?/archives/38-guid.html</id>
        <title type="html">Visual Studio Extensions for Sharepoint - ListDefinition1</title>
        <content type="xhtml" xml:base="http://johnkoerner.net/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                If you have used the Visual Studio Extensions for Sharepoint to create more than one list, then you will probably be familiar with the problem of all custom List Definitions are given the name ListDefinition1.  This causes problems when you activate the feature, because SharePoint already thinks ListDefinition1 exists.
<br /><br />
To fix this problem, there are a few things that need to be changed in your project.
<br /><br />
1.) Rename the ListDefinition1 folder in your solution.
<br />2.) Change the URL in the Instance.XML.  You'll probably want to change the display name as well, but that is not necessary.
<br />3.) Change the Name in the ListDefinition.xml.  Again, you'll probably want to change the display name as well.
<br /><br />
Some things to keep in mind are that the display name column is used in one of the folder names that is created by the extensions, so if you use a character that SharePoint doesn't like (i.e. an apostrophe) you will get an error.
<br /><br />
If you get an error when deploying, your best bet is to fix the error in VS, delete the PKG folder, and then rebuild and deploy your solution. 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://johnkoerner.net/index.php?/archives/37-MOSS-XSL-for-ItemStyles.html" rel="alternate" title="MOSS XSL for ItemStyles" />
        <author>
            <name>JohnKoer</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2008-04-17T16:33:13Z</published>
        <updated>2008-06-12T03:35:16Z</updated>
        <wfw:comment>http://johnkoerner.net/wfwcomment.php?cid=37</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://johnkoerner.net/rss.php?version=atom1.0&amp;type=comments&amp;cid=37</wfw:commentRss>
    
            <category scheme="http://johnkoerner.net/index.php?/categories/10-SharePoint" label="SharePoint" term="SharePoint" />
            <category scheme="http://johnkoerner.net/index.php?/categories/11-SharePoint-Designer" label="SharePoint Designer" term="SharePoint Designer" />
    
        <id>http://johnkoerner.net/index.php?/archives/37-guid.html</id>
        <title type="html">MOSS XSL for ItemStyles</title>
        <content type="xhtml" xml:base="http://johnkoerner.net/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                I found a nice little snippet on <a href=http://www.heathersolomon.com/blog/articles/customitemstyle.aspx>Heather Solomon's site</a> for  customizing the CQWP.  She had a nice little debugging XSL style for items to see what properties were available. <br /><br />
After doing a little digging with the XSL, I enhanced it just a bit, so I could get both the parameter name and the value:<br /><br />
	<div class='code'>
<font color='blue'>&lt;</font><font color='maroon'>xsl:template</font><font color='red'>&#160;name</font><font color='blue'>="Debug"</font><font color='red'>&#160;match</font><font color='blue'>="Row[@Style='Debug']"</font><font color='red'>&#160;mode</font><font color='blue'>="itemstyle"&gt;</font><font color='black'><br />
</font><font color='blue'>&lt;</font><font color='maroon'>xsl:for-each</font><font color='red'>&#160;select</font><font color='blue'>="@*"&gt;</font><font color='black'><br />
&#160;&#160;&#160;&#160;P:</font><font color='blue'>&lt;</font><font color='maroon'>xsl:value-of</font><font color='red'>&#160;select</font><font color='blue'>="name()"</font><font color='red'>&#160;</font><font color='blue'>/>=&lt;</font><font color='maroon'>xsl:value-of</font><font color='red'>&#160;&#160;select</font><font color='blue'>="."/>&#160;&lt;</font><font color='maroon'>br</font><font color='red'>&#160;</font><font color='blue'>/><br />
&lt;/</font><font color='maroon'>xsl:for-each</font><font color='blue'>&gt;</font><font color='black'><br />
</font><font color='blue'>&lt;/</font><font color='maroon'>xsl:template</font><font color='blue'>&gt;</font><font color='black'></font>
	</div><br /><br />

The output then looks like:<br /><br />

P:ListId=FF486727-3DD6-4FFB-A5F5-B9A922366E9E
<br />P:WebId=FF7C38FA-BBAA-4240-9A2B-63B8F508C780
<br />P:ID=1
<br />P:<u>x007B_ff564e0f_x002D_0c70_x002D_4ab9_x002D_b863_x002D_0177e6ddd247_x007D</u>=Welcome to your Project Diary!
<br />P:FileRef=Customers/Customer1/CustomerProject/Lists/Posts/1_.000
<br />P:<u>x007B_ff22ea11_x002D_1e32_x002D_424e_x002D_89ab_x002D_9fedbadb6ce1_x007D</u>=1
<br />P:Modified=2008-03-25 12:50:55
<br />P:Author=System Account
<br />P:Editor=System Account
<br />P:Created=2008-03-25 12:42:02
<br />P:PublishingRollupImage= 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://johnkoerner.net/index.php?/archives/36-Showing-Items-Without-Folders-in-the-DataView-Web-Part.html" rel="alternate" title="Showing Items Without Folders in the DataView Web Part" />
        <author>
            <name>JohnKoer</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2008-04-04T00:09:00Z</published>
        <updated>2008-06-12T03:35:31Z</updated>
        <wfw:comment>http://johnkoerner.net/wfwcomment.php?cid=36</wfw:comment>
    
        <slash:comments>1</slash:comments>
        <wfw:commentRss>http://johnkoerner.net/rss.php?version=atom1.0&amp;type=comments&amp;cid=36</wfw:commentRss>
    
            <category scheme="http://johnkoerner.net/index.php?/categories/10-SharePoint" label="SharePoint" term="SharePoint" />
            <category scheme="http://johnkoerner.net/index.php?/categories/11-SharePoint-Designer" label="SharePoint Designer" term="SharePoint Designer" />
    
        <id>http://johnkoerner.net/index.php?/archives/36-guid.html</id>
        <title type="html">Showing Items Without Folders in the DataView Web Part</title>
        <content type="xhtml" xml:base="http://johnkoerner.net/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                I have a dataview web part (aka dataform web part) pointed to a list with items that are all in sub folders.  By default the web part displays just the items from the root folder.  I did some searching on the net and found people had this problem with CAML queries and that they had to set the Scope property of the query to Recursive.  Since I was doing this through the SharePoint designer, I had to figure out where to set the property.  To save everyone else (and myself in the future) some time, here is how I did it:
<br /><br />
Open up the page in split or code view.  Scroll to the SharePoint:SPDataSource object inside of your DataFormWebPart.
<br /><br />
<!-- s9ymdb:5 --><img width="618" height="71" style="border: 0px; padding-left: 5px; padding-right: 5px;" src="http://johnkoerner.net/uploads/SPD-CodeView.PNG" alt="" />
<br /><br />
Click somewhere inside the SPDataSource tag.  This will bring up the tag properties window on the left.  From here you can set your scope property.
<br /><br />
<!-- s9ymdb:6 --><img width="386" height="335" style="border: 0px; padding-left: 5px; padding-right: 5px;" src="http://johnkoerner.net/uploads/SPDRecursive.png" alt="" />
<br /><br />
The four properties are documented in the MSDN library in the <a href=http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.spviewscope.aspx>SPViewScope</a> enumeration.

 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://johnkoerner.net/index.php?/archives/35-MOSS-The-specified-account-name-is-invalid.html" rel="alternate" title="MOSS - The specified account name is invalid" />
        <author>
            <name>JohnKoer</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2007-12-20T18:35:02Z</published>
        <updated>2008-06-12T03:35:53Z</updated>
        <wfw:comment>http://johnkoerner.net/wfwcomment.php?cid=35</wfw:comment>
    
        <slash:comments>2</slash:comments>
        <wfw:commentRss>http://johnkoerner.net/rss.php?version=atom1.0&amp;type=comments&amp;cid=35</wfw:commentRss>
    
            <category scheme="http://johnkoerner.net/index.php?/categories/10-SharePoint" label="SharePoint" term="SharePoint" />
    
        <id>http://johnkoerner.net/index.php?/archives/35-guid.html</id>
        <title type="html">MOSS - The specified account name is invalid</title>
        <content type="xhtml" xml:base="http://johnkoerner.net/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                I have been building a Virtual Machine for my MOSS development and testing.  I had not configured active directory on the machine, but one piece of software required it for me to continue.   So I setup my machine as a domain controller and created a domain called VMDomain.  This worked and everything seemed fine.  I then went to do some work in sharepoint and noticed that some features were erroring out.  I checked the event viewer and had quite a few messages in there stating "The specified account name is invalid."  I also had other errors about usernames not mapping to security IDs.  I was positive that this was something that had been broken because of the domain change.  I changed accounts on services, application pools, and anything else I could find, but I was still getting those errors every few minutes.<br /><br />I googled the errors I was getting, but didn't really get any good results.  Finally, I was messing around in central admin, when I noticed one screen that I had not been in yet.  Under the operations tab, under the Security Configurations group, the Service Accounts item.  I selected Web Application Pool and then selected the Sharepoint - 80 app pool and modified the ID and password.  After making the update, all of my event viewer errors seemed to go away.  
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://johnkoerner.net/index.php?/archives/34-Powershell-Stopwatch.html" rel="alternate" title="Powershell Stopwatch" />
        <author>
            <name>JohnKoer</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2007-12-04T01:14:26Z</published>
        <updated>2007-12-06T15:56:03Z</updated>
        <wfw:comment>http://johnkoerner.net/wfwcomment.php?cid=34</wfw:comment>
    
        <slash:comments>1</slash:comments>
        <wfw:commentRss>http://johnkoerner.net/rss.php?version=atom1.0&amp;type=comments&amp;cid=34</wfw:commentRss>
    
            <category scheme="http://johnkoerner.net/index.php?/categories/9-Powershell" label="Powershell" term="Powershell" />
    
        <id>http://johnkoerner.net/index.php?/archives/34-guid.html</id>
        <title type="html">Powershell Stopwatch</title>
        <content type="xhtml" xml:base="http://johnkoerner.net/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                So I needed a stopwatch today to time a project I was working on, so I decided to write a quick PS script to do it for me:
<br />
<br />
	<style>
		.code {
			word-wrap:break-word;
			margin:10px;
			padding:10px;
			border:2px ridge white;
			background-color:#eeeeee;
			font-family:Courier New;
			font-size:10pt;
			}
	</style>

	<div class='code'>
<font color='black'>function&#160;global:StopWatch()<br />
{<br />
&#160;&#160;</font><font color='blue'>#&#160;</font><font color='black'>Create&#160;the&#160;stopwatch<br />
&#160;&#160;[System.Diagnostics.Stopwatch]&#160;$sw</font><font color='blue'>;<br />
&#160;&#160;</font><font color='black'>$sw&#160;</font><font color='blue'>=&#160;</font><font color='black'>New-Object&#160;System.Diagnostics.StopWatch<br />
&#160;&#160;$sw.Start()<br />
&#160;&#160;write-host&#160;</font><font color='#808080'>"Press&#160;enter&#160;to&#160;stop..."<br />
&#160;&#160;</font><font color='blue'>#&#160;</font><font color='black'>Wait&#160;</font><font color='blue'>for&#160;</font><font color='black'>input,&#160;and&#160;we&#160;will&#160;just&#160;disregard&#160;anything&#160;they&#160;type<br />
&#160;&#160;$blah&#160;</font><font color='blue'>=&#160;</font><font color='black'>read-host<br />
&#160;&#160;$sw.Stop()<br /><br />
&#160;&#160;</font><font color='blue'>#&#160;</font><font color='black'>Write&#160;the&#160;compact&#160;output&#160;to&#160;the&#160;screen<br />
&#160;&#160;write-host&#160;$sw.Elapsed.ToString()<br />
<br />
&#160;&#160;</font><font color='blue'>#&#160;</font><font color='black'>Write&#160;verbose&#160;output&#160;to&#160;screen<br />
&#160;&#160;</font><font color='blue'>#</font><font color='black'>write-host&#160;</font><font color='#808080'>"Days:"&#160;</font><font color='black'>$sw.Elapsed.Days.ToString()<br />
&#160;&#160;</font><font color='blue'>#</font><font color='black'>write-host&#160;</font><font color='#808080'>"Hours:"&#160;</font><font color='black'>$sw.Elapsed.Hours.ToString()<br />
&#160;&#160;</font><font color='blue'>#</font><font color='black'>write-host&#160;</font><font color='#808080'>"Minutes:"&#160;</font><font color='black'>$sw.Elapsed.Minutes.ToString()<br />
&#160;&#160;</font><font color='blue'>#</font><font color='black'>write-host&#160;</font><font color='#808080'>"Seconds:"&#160;</font><font color='black'>$sw.Elapsed.Seconds.ToString()<br />
&#160;&#160;</font><font color='blue'>#</font><font color='black'>write-host&#160;</font><font color='#808080'>"Milliseconds:"&#160;</font><font color='black'>$sw.Elapsed.Milliseconds.ToString()<br />
}</font>
	</div> 
            </div>
        </content>
        
    </entry>

</feed>