<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Peter Foot - NETCF</title>
    <link>http://peterfoot.net/</link>
    <description>Microsoft Device Application Development MVP</description>
    <image>
      <url>http://peterfoot.net/images/mugshot.jpg</url>
      <title>Peter Foot - NETCF</title>
      <link>http://peterfoot.net/</link>
    </image>
    <copyright>Peter Foot</copyright>
    <lastBuildDate>Fri, 13 Mar 2009 14:12:00 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.1.8102.813</generator>
    <managingEditor>peter.foot@appamundi.com</managingEditor>
    <webMaster>peter.foot@appamundi.com</webMaster>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=7964f26e-8308-4623-9f61-4b0810e0d8fa</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,7964f26e-8308-4623-9f61-4b0810e0d8fa.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I came across this useful list of breaking changes in the .NETCF 3.5 runtime and thought
I'd blog it here before I lose the URL:-
</p>
        <p>
          <a href="http://msdn.microsoft.com/en-us/netframework/bb986636.aspx">http://msdn.microsoft.com/en-us/netframework/bb986636.aspx</a>
        </p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=7964f26e-8308-4623-9f61-4b0810e0d8fa" />
      </body>
      <title>.NETCF 3.5 Breaking Changes</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,7964f26e-8308-4623-9f61-4b0810e0d8fa.aspx</guid>
      <link>http://peterfoot.net/NETCF35BreakingChanges.aspx</link>
      <pubDate>Fri, 13 Mar 2009 14:12:00 GMT</pubDate>
      <description>&lt;p&gt;
I came across this useful list of breaking changes in the .NETCF 3.5 runtime and thought
I'd blog it here before I lose the URL:-
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://msdn.microsoft.com/en-us/netframework/bb986636.aspx"&gt;http://msdn.microsoft.com/en-us/netframework/bb986636.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=7964f26e-8308-4623-9f61-4b0810e0d8fa" /&gt;</description>
      <category>NETCF</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=886f91ae-e583-4112-bee6-a812b301e851</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,886f91ae-e583-4112-bee6-a812b301e851.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
On the newsgroup, a developer asked if it was possible to use antialiasing on a Label
font. By default on Windows Mobile the text does not use antialiasing unless you turn
on the global ClearType option under Settings &gt; System &gt; Screen &gt; ClearType.
The platform has the capability to smooth fonts, we just need an easy way to specify
the quality from our code. The System.Drawing.Font class doesn't support this directly,
but Microsoft.WindowsCE.Forms contains a wrapper for the native LOGFONT structure
in the LogFont class. There is a static method on the Font class of FromLogFont(object
o) which when passed a Microsoft.WindowsCE.Forms.LogFont will draw the font with the
specified options. The following code shows setting three labels with default quality,
antialiasing and cleartype, the following screen grab shows the result from my device
screen:-<font size="2">Microsoft.WindowsCE.Forms.</font><font color="#2b91af" size="2"><font color="#2b91af" size="2">LogFont</font></font><font size="2"> lf
= </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">new</font></font><font size="2"> Microsoft.WindowsCE.Forms.</font><font color="#2b91af" size="2"><font color="#2b91af" size="2">LogFont</font></font><font size="2">();</font><font size="2">lf.FaceName
= </font><font color="#a31515" size="2"><font color="#a31515" size="2">"Tahoma"</font></font><font size="2">;</font><font size="2"></font></p>
        <p>
lf.Height = 48;
</p>
        <p>
lf.Quality = Microsoft.WindowsCE.Forms.<font color="#2b91af" size="2"><font color="#2b91af" size="2">LogFontQuality</font></font><font size="2">.Default;
</font></p>
        <p>
label1.Font = <font color="#2b91af" size="2"><font color="#2b91af" size="2">Font</font></font><font size="2">.FromLogFont(lf);</font><font size="2"></font></p>
        <p>
Microsoft.WindowsCE.Forms.<font color="#2b91af" size="2"><font color="#2b91af" size="2">LogFont</font></font><font size="2"> lf2
= </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">new</font></font><font size="2"> Microsoft.WindowsCE.Forms.</font><font color="#2b91af" size="2"><font color="#2b91af" size="2">LogFont</font></font><font size="2">();
</font></p>
        <p>
lf2.FaceName = <font color="#a31515" size="2"><font color="#a31515" size="2">"Tahoma"</font></font><font size="2">;</font><font size="2"></font></p>
        <p>
lf2.Height = 48;
</p>
        <p>
lf2.Quality = Microsoft.WindowsCE.Forms.<font color="#2b91af" size="2"><font color="#2b91af" size="2">LogFontQuality</font></font><font size="2">.AntiAliased;</font><font size="2"></font></p>
        <p>
label2.Font = <font color="#2b91af" size="2"><font color="#2b91af" size="2">Font</font></font><font size="2">.FromLogFont(lf2);
</font></p>
        <p>
Microsoft.WindowsCE.Forms.<font color="#2b91af" size="2"><font color="#2b91af" size="2">LogFont</font></font><font size="2"> lf3
= </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">new</font></font><font size="2"> Microsoft.WindowsCE.Forms.</font><font color="#2b91af" size="2"><font color="#2b91af" size="2">LogFont</font></font><font size="2">();</font><font size="2">lf3.FaceName
= </font><font color="#a31515" size="2"><font color="#a31515" size="2">"Tahoma"</font></font><font size="2">;</font><font size="2"></font></p>
        <p>
lf3.Height = 48;
</p>
        <p>
lf3.Quality = Microsoft.WindowsCE.Forms.<font color="#2b91af" size="2"><font color="#2b91af" size="2">LogFontQuality</font></font><font size="2">.ClearType;
</font></p>
        <p>
label3.Font = <font color="#2b91af" size="2"><font color="#2b91af" size="2">Font</font></font><font size="2">.FromLogFont(lf3);</font></p>
        <p>
          <font size="2">
            <img height="1" alt="" src="http://inthehand.com/blogs/peterfoot/antialiasing.png" width="1" border="0" />
            <img height="181" alt="" src="http://inthehand.com/blogs/peterfoot/antialiasing.png" width="136" border="0" />
          </font>
        </p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=886f91ae-e583-4112-bee6-a812b301e851" />
      </body>
      <title>Antialisasing and .NETCF</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,886f91ae-e583-4112-bee6-a812b301e851.aspx</guid>
      <link>http://peterfoot.net/AntialisasingAndNETCF.aspx</link>
      <pubDate>Wed, 02 Apr 2008 15:30:36 GMT</pubDate>
      <description>&lt;p&gt;
On the newsgroup, a developer asked if it was possible to use antialiasing on a Label
font. By default on Windows Mobile the text does not use antialiasing unless you turn
on the global ClearType option under Settings &amp;gt; System &amp;gt; Screen &amp;gt; ClearType.
The platform has the capability to smooth fonts, we just need an easy way to specify
the quality from our code. The System.Drawing.Font class doesn't support this directly,
but Microsoft.WindowsCE.Forms contains a wrapper for the native LOGFONT structure
in the LogFont class. There is a static method on the Font class of FromLogFont(object
o) which when passed a Microsoft.WindowsCE.Forms.LogFont will draw the font with the
specified options. The following code shows setting three labels with default quality,
antialiasing and cleartype, the following screen grab shows the result from my device
screen:-&lt;font size=2&gt;Microsoft.WindowsCE.Forms.&lt;/font&gt;&lt;font color=#2b91af size=2&gt;&lt;font color=#2b91af size=2&gt;LogFont&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt; lf
= &lt;/font&gt;&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt; Microsoft.WindowsCE.Forms.&lt;/font&gt;&lt;font color=#2b91af size=2&gt;&lt;font color=#2b91af size=2&gt;LogFont&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;();&lt;/font&gt;&gt;&lt;font size=2&gt;lf.FaceName
= &lt;/font&gt;&lt;font color=#a31515 size=2&gt;&lt;font color=#a31515 size=2&gt;"Tahoma"&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;;&lt;/font&gt;&gt;&lt;font size=2&gt; 
&lt;/p&gt;
&lt;p&gt;
lf.Height = 48;
&lt;/p&gt;
&lt;p&gt;
lf.Quality = Microsoft.WindowsCE.Forms.&gt;&lt;font color=#2b91af size=2&gt;&lt;font color=#2b91af size=2&gt;LogFontQuality&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;.Default;
&lt;/p&gt;
&lt;p&gt;
label1.Font = &gt;&lt;font color=#2b91af size=2&gt;&lt;font color=#2b91af size=2&gt;Font&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;.FromLogFont(lf);&lt;/font&gt;&gt;&lt;font size=2&gt; 
&lt;/p&gt;
&lt;p&gt;
Microsoft.WindowsCE.Forms.&gt;&lt;font color=#2b91af size=2&gt;&lt;font color=#2b91af size=2&gt;LogFont&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt; lf2
= &lt;/font&gt;&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt; Microsoft.WindowsCE.Forms.&lt;/font&gt;&lt;font color=#2b91af size=2&gt;&lt;font color=#2b91af size=2&gt;LogFont&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;();
&lt;/p&gt;
&lt;p&gt;
lf2.FaceName = &gt;&lt;font color=#a31515 size=2&gt;&lt;font color=#a31515 size=2&gt;"Tahoma"&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;;&lt;/font&gt;&gt;&lt;font size=2&gt; 
&lt;/p&gt;
&lt;p&gt;
lf2.Height = 48;
&lt;/p&gt;
&lt;p&gt;
lf2.Quality = Microsoft.WindowsCE.Forms.&gt;&lt;font color=#2b91af size=2&gt;&lt;font color=#2b91af size=2&gt;LogFontQuality&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;.AntiAliased;&lt;/font&gt;&gt;&lt;font size=2&gt; 
&lt;/p&gt;
&lt;p&gt;
label2.Font = &gt;&lt;font color=#2b91af size=2&gt;&lt;font color=#2b91af size=2&gt;Font&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;.FromLogFont(lf2);
&lt;/p&gt;
&lt;p&gt;
Microsoft.WindowsCE.Forms.&gt;&lt;font color=#2b91af size=2&gt;&lt;font color=#2b91af size=2&gt;LogFont&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt; lf3
= &lt;/font&gt;&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt; Microsoft.WindowsCE.Forms.&lt;/font&gt;&lt;font color=#2b91af size=2&gt;&lt;font color=#2b91af size=2&gt;LogFont&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;();&lt;/font&gt;&gt;&lt;font size=2&gt;lf3.FaceName
= &lt;/font&gt;&lt;font color=#a31515 size=2&gt;&lt;font color=#a31515 size=2&gt;"Tahoma"&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;;&lt;/font&gt;&gt;&lt;font size=2&gt; 
&lt;/p&gt;
&lt;p&gt;
lf3.Height = 48;
&lt;/p&gt;
&lt;p&gt;
lf3.Quality = Microsoft.WindowsCE.Forms.&gt;&lt;font color=#2b91af size=2&gt;&lt;font color=#2b91af size=2&gt;LogFontQuality&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;.ClearType;
&lt;/p&gt;
&lt;p&gt;
label3.Font = &gt;&lt;font color=#2b91af size=2&gt;&lt;font color=#2b91af size=2&gt;Font&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;.FromLogFont(lf3);&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=2&gt;&lt;img height=1 alt="" src="http://inthehand.com/blogs/peterfoot/antialiasing.png" width=1 border=0&gt;&lt;img height=181 alt="" src="http://inthehand.com/blogs/peterfoot/antialiasing.png" width=136 border=0&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=886f91ae-e583-4112-bee6-a812b301e851" /&gt;</description>
      <category>NETCF</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=5f4fbf24-e699-44e9-baf4-aab30417f7f9</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,5f4fbf24-e699-44e9-baf4-aab30417f7f9.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://blogs.msdn.com/martijnh/default.aspx">Martijn Hoogendoorn</a> provides
a description of how to avoid the message:-
</p>
        <p>
"<em minmax_bound="true">An error message is available for this exception but cannot
be displayed because these messages are optional and are not currently installed on
this device. Please install ‘NETCFv35.Messages.EN.wm.cab’ for Windows Mobile 5.0 and
above or  ‘NETCFv35.Messages.EN.cab’ for other platforms. Restart the application
to see the message.</em>"
</p>
        <p>
Even if you have installed the cab file with message resources. A useful link:-
</p>
        <p>
          <a href="http://blogs.msdn.com/martijnh/archive/2008/01/03/fixing-exception-messages-on-the-net-compact-framework-3-5.aspx">http://blogs.msdn.com/martijnh/archive/2008/01/03/fixing-exception-messages-on-the-net-compact-framework-3-5.aspx</a>
        </p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=5f4fbf24-e699-44e9-baf4-aab30417f7f9" />
      </body>
      <title>Exception Messages on .NETCF v3.5</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,5f4fbf24-e699-44e9-baf4-aab30417f7f9.aspx</guid>
      <link>http://peterfoot.net/ExceptionMessagesOnNETCFV35.aspx</link>
      <pubDate>Thu, 06 Mar 2008 14:48:58 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://blogs.msdn.com/martijnh/default.aspx"&gt;Martijn Hoogendoorn&lt;/a&gt; provides
a description of how to avoid the message:-
&lt;/p&gt;
&lt;p&gt;
"&lt;em minmax_bound="true"&gt;An error message is available for this exception but cannot
be displayed because these messages are optional and are not currently installed on
this device. Please install ‘NETCFv35.Messages.EN.wm.cab’ for Windows Mobile 5.0 and
above or&amp;nbsp; ‘NETCFv35.Messages.EN.cab’ for other platforms. Restart the application
to see the message.&lt;/em&gt;"
&lt;/p&gt;
&lt;p&gt;
Even if you have installed the cab file with message resources. A useful link:-
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blogs.msdn.com/martijnh/archive/2008/01/03/fixing-exception-messages-on-the-net-compact-framework-3-5.aspx"&gt;http://blogs.msdn.com/martijnh/archive/2008/01/03/fixing-exception-messages-on-the-net-compact-framework-3-5.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=5f4fbf24-e699-44e9-baf4-aab30417f7f9" /&gt;</description>
      <category>NETCF</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=2a3f81f6-58af-4a4b-bb29-a99b75e48db2</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,2a3f81f6-58af-4a4b-bb29-a99b75e48db2.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
A question came up on our forums and so I investigated writing a wrapper for the GetSystemPowerState
API function. This allows you to retrieve the power state name, and also a bitmask
of flags - Is the backlight on, is the device password protected etc. This is the
result in VB.NET. We will add it to the wish list for the next version of <a href="http://inthehand.com/content/Mobile.aspx">the
library</a>.
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">&lt;DllImport(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"coredll.dll"</span>)&gt;
_<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Shared</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Function</span> GetSystemPowerState(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> pBuffer <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> System.Text.StringBuilder, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> Length <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Integer</span>, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByRef</span> pFlags <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> PowerState) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Integer</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Function</span><br /><br />
&lt;Flags()&gt; _<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Enum</span> PowerState<br />
[On] <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> &amp;H10000 <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'//
on state</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><font color="#000000">Off</font></span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> &amp;H20000 <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
// no power, full off</span><br />
Critical <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> &amp;H40000 <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'//
critical off</span><br />
Boot <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> &amp;H80000 <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
// boot state</span><br />
Idle <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> &amp;H100000 <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
// idle state</span><br />
Suspend <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> &amp;H200000 <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
// suspend state</span><br />
Unattended <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> &amp;H400000 <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
// Unattended state.</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><font color="#000000">Reset</font></span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> &amp;H800000 <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
// reset state</span><br />
UserIdle <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> &amp;H1000000 <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
// user idle state</span><br />
BackLightOn <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> &amp;H2000000 <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
// device screen backlight on</span><br />
Password <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> &amp;H10000000 <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
// This state is password protected.</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Enum</span><br /><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span> Button1_Click(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> sender <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> System.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Object</span>, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> e <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> System.EventArgs) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Handles</span> Button1.Click<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> sb <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> System.Text.StringBuilder(260)<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> flags <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> PowerState <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 0<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Dim</span> ret <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Integer</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> GetSystemPowerState(sb,
sb.Capacity, flags)<br /><br />
TextBox1.Text <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> sb.ToString()<br />
TextBox2.Text <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> flags.ToString()<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span></span>
        </p>
        <p>
The last method is just a very simple example of calling the function and displaying
the result.
</p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=2a3f81f6-58af-4a4b-bb29-a99b75e48db2" />
      </body>
      <title>How To: Get System Power State Name and Flags</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,2a3f81f6-58af-4a4b-bb29-a99b75e48db2.aspx</guid>
      <link>http://peterfoot.net/HowToGetSystemPowerStateNameAndFlags.aspx</link>
      <pubDate>Sat, 23 Feb 2008 16:29:11 GMT</pubDate>
      <description>&lt;p&gt;
A question came up on our forums and so I investigated writing a wrapper for the GetSystemPowerState
API function. This allows you to retrieve the power state name, and also a bitmask
of flags - Is the backlight on, is the device password protected etc. This is the
result in VB.NET. We will add it to the wish list for the next version of &lt;a href="http://inthehand.com/content/Mobile.aspx"&gt;the
library&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;lt;DllImport(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"coredll.dll"&lt;/span&gt;)&amp;gt;
_&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Shared&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Function&lt;/span&gt; GetSystemPowerState(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; pBuffer &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; System.Text.StringBuilder, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; Length &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Integer&lt;/span&gt;, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByRef&lt;/span&gt; pFlags &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; PowerState) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Integer&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Function&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&amp;lt;Flags()&amp;gt; _&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Enum&lt;/span&gt; PowerState&lt;br&gt;
[On] &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &amp;amp;H10000 &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'//
on state&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font color=#000000&gt;Off&lt;/font&gt;&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &amp;amp;H20000 &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
// no power, full off&lt;/span&gt;
&lt;br&gt;
Critical &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &amp;amp;H40000 &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'//
critical off&lt;/span&gt;
&lt;br&gt;
Boot &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &amp;amp;H80000 &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
// boot state&lt;/span&gt;
&lt;br&gt;
Idle &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &amp;amp;H100000 &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
// idle state&lt;/span&gt;
&lt;br&gt;
Suspend &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &amp;amp;H200000 &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
// suspend state&lt;/span&gt;
&lt;br&gt;
Unattended &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &amp;amp;H400000 &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
// Unattended state.&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font color=#000000&gt;Reset&lt;/font&gt;&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &amp;amp;H800000 &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
// reset state&lt;/span&gt;
&lt;br&gt;
UserIdle &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &amp;amp;H1000000 &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
// user idle state&lt;/span&gt;
&lt;br&gt;
BackLightOn &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &amp;amp;H2000000 &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
// device screen backlight on&lt;/span&gt;
&lt;br&gt;
Password &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &amp;amp;H10000000 &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
// This state is password protected.&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Enum&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; Button1_Click(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; sender &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; System.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Object&lt;/span&gt;, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; e &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Handles&lt;/span&gt; Button1.Click&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; sb &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; System.Text.StringBuilder(260)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; flags &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; PowerState &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 0&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Dim&lt;/span&gt; ret &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Integer&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; GetSystemPowerState(sb,
sb.Capacity, flags)&lt;br&gt;
&lt;br&gt;
TextBox1.Text &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; sb.ToString()&lt;br&gt;
TextBox2.Text &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; flags.ToString()&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
The last method is just a very simple example of calling the function and displaying
the result.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=2a3f81f6-58af-4a4b-bb29-a99b75e48db2" /&gt;</description>
      <category>How To</category>
      <category>NETCF</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=769dafe3-f1a9-429d-bd03-a2872868dd8f</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,769dafe3-f1a9-429d-bd03-a2872868dd8f.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
A number of controls within .NETCF have built in ScrollBars. Occasionally you may
want to operate these programmatically on behalf of the user. When you do this you
want both the control to scroll and the scrollbars to correctly reflect the current
position. Faced with this requirement I found a solution in the WM_VSCROLL (and equivalent
HSCROLL) message. You can send this message to the native handle of your control along
with a number of present constants to offer hands-free scrolling. Along the way I
discovered that to work you must have the handle of the native control which implements
the scroll bars. In the case of the WebBrowser this is a grand-child of the outer
managed control so we have to use the native GetWindow API call to get down to the
right HWND. I wrapped this up in a class I've called ScrollBarHelper which allows
the user to move left, right, up and down. The code for the class is:-
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">///
&lt;summary&gt;</span>
            <br />
            <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">///
Helper class to programmatically operate scrollbars.</span>
            <br />
            <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">///
&lt;/summary&gt;</span>
            <br />
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">class</span> ScrollBarHelper<br />
{<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
private</span> IntPtr handle;<br /><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
public</span> ScrollBarHelper(Control c)<br />
  {<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   
if</span> (c <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">is</span> WebBrowser)<br />
    {<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">     
//special case for complex control</span><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">     
//get the inner IE control</span><br />
      IntPtr hInternetExplorer <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> NativeMethods.GetWindow(c.Handle,
NativeMethods.GW.CHILD);<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">     
//get the first child (status bar)</span><br />
      IntPtr hStatus <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> NativeMethods.GetWindow(hInternetExplorer,
NativeMethods.GW.CHILD);<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">    
 //get the html body area</span><br />
      handle <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> NativeMethods.GetWindow(hStatus,
NativeMethods.GW.HWNDNEXT);<br />
    }<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   
else</span><br />
    {<br />
      handle <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> c.Handle;<br />
    }<br />
  }<br /><br /><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> LineRight()<br />
{<br />
  SendMessage(NativeMethods.WM_HSCROLL, NativeMethods.SB_LINEDOWN);<br />
}<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> LineLeft()<br />
{<br />
  SendMessage(NativeMethods.WM_HSCROLL, NativeMethods.SB_LINEUP);<br />
}<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> PageRight()<br />
{<br />
  SendMessage(NativeMethods.WM_HSCROLL, NativeMethods.SB_PAGEDOWN);<br />
}<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> PageLeft()<br />
{<br />
  SendMessage(NativeMethods.WM_HSCROLL, NativeMethods.SB_PAGEUP);<br />
}<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> LineDown()<br />
{<br />
  SendMessage(NativeMethods.WM_VSCROLL, NativeMethods.SB_LINEDOWN);<br />
}<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> LineUp()<br />
{<br />
  SendMessage(NativeMethods.WM_VSCROLL, NativeMethods.SB_LINEUP);<br />
}<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> PageDown()<br />
{<br />
  SendMessage(NativeMethods.WM_VSCROLL, NativeMethods.SB_PAGEDOWN);<br />
}<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> PageUp()<br />
{<br />
  SendMessage(NativeMethods.WM_VSCROLL, NativeMethods.SB_PAGEUP);<br />
}<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> SendMessage(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> msg, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> value)<br />
{<br />
  Microsoft.WindowsCE.Forms.Message m <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> Microsoft.WindowsCE.Forms.Message.Create(handle,
msg, (IntPtr)value, handle);<br />
  Microsoft.WindowsCE.Forms.MessageWindow.PostMessage(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ref</span> m);<br />
}<br /><br />
[DllImport(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"coredll.dll"</span>)]<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">internal</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">static</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">extern</span> IntPtr
GetWindow(IntPtr hWnd, GW uCmd);<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">internal</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">enum</span> GW
: <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span><br />
{<br />
  HWNDFIRST <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 0,<br />
  HWNDLAST <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 1,<br />
  HWNDNEXT <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 2,<br />
  HWNDPREV <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 3,<br />
  OWNER <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 4,<br />
  CHILD <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 5,<br />
}<br /><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//scrollbar
messages</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">internal</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">const</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> WM_HSCROLL <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 0x0114;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">internal</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">const</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> WM_VSCROLL <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 0x0115;<br /><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//constants
for scrollbar actions</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">internal</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">const</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> SB_LINEUP <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 0;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">internal</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">const</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> SB_LINEDOWN <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 1;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">internal</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">const</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> SB_PAGEUP <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 2;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">internal</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">const</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> SB_PAGEDOWN <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 3;<br /><br />
}</span>
        </p>
        <p>
In order to use the control you create a new instance passing it the control of your
choice. Then call methods to scroll the control e.g.
</p>
        <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
          <p>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
              <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">private</span> ScrollBarHelper
wsbh;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">private</span> ScrollBarHelper
tsbh;<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> Form1_Load(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span> sender,
EventArgs e)<br />
{<br />
  wsbh <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> ScrollBarHelper(webBrowser1);<br />
  tsbh <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> ScrollBarHelper(textBox1);<br />
}</span>
          </p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <p>
              <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">private</span>
                <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> button1_Click(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span> sender,
EventArgs e)<br />
{<br />
  tsbh.PageUp(); 
<br />
}</span>
            </p>
          </span>
        </span>
        <p>
The control contains methods to Scroll via single lines or pages at a time, I didn't
get around to looking at setting the explicit value of the scrollbar control, but
this should be possible also - refer to the documentation for <a href="http://msdn2.microsoft.com/en-us/library/ms912690.aspx">WM_VSCROLL</a> for
how to pass the value.
</p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=769dafe3-f1a9-429d-bd03-a2872868dd8f" />
      </body>
      <title>How To: Programmatically Scroll Controls</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,769dafe3-f1a9-429d-bd03-a2872868dd8f.aspx</guid>
      <link>http://peterfoot.net/HowToProgrammaticallyScrollControls.aspx</link>
      <pubDate>Tue, 12 Feb 2008 23:00:04 GMT</pubDate>
      <description>&lt;p&gt;
A number of controls within .NETCF have built in ScrollBars. Occasionally you may
want to operate these programmatically on behalf of the user. When you do this you
want both the control to scroll and the scrollbars to correctly reflect the current
position. Faced with this requirement I found a solution in the WM_VSCROLL (and equivalent
HSCROLL) message. You can send this message to the native handle of your control along
with a number of present constants to offer hands-free scrolling. Along the way I
discovered that to work you must have the handle of the native control which implements
the scroll bars. In the case of the WebBrowser this is a grand-child of the outer
managed control so we have to use the native GetWindow API call to get down to the
right HWND. I wrapped this up in a class I've called ScrollBarHelper which allows
the user to move left, right, up and down. The code for the class is:-
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
Helper class to programmatically operate scrollbars.&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;class&lt;/span&gt; ScrollBarHelper&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
private&lt;/span&gt; IntPtr handle;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
public&lt;/span&gt; ScrollBarHelper(Control c)&lt;br&gt;
&amp;nbsp; {&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
if&lt;/span&gt; (c &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;is&lt;/span&gt; WebBrowser)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
//special case for complex control&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
//get the inner IE control&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IntPtr hInternetExplorer &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; NativeMethods.GetWindow(c.Handle,
NativeMethods.GW.CHILD);&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
//get the first child (status bar)&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IntPtr hStatus &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; NativeMethods.GetWindow(hInternetExplorer,
NativeMethods.GW.CHILD);&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;//get the html body area&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; handle &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; NativeMethods.GetWindow(hStatus,
NativeMethods.GW.HWNDNEXT);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
else&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; handle &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; c.Handle;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; LineRight()&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; SendMessage(NativeMethods.WM_HSCROLL, NativeMethods.SB_LINEDOWN);&lt;br&gt;
}&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; LineLeft()&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; SendMessage(NativeMethods.WM_HSCROLL, NativeMethods.SB_LINEUP);&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; PageRight()&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; SendMessage(NativeMethods.WM_HSCROLL, NativeMethods.SB_PAGEDOWN);&lt;br&gt;
}&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; PageLeft()&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; SendMessage(NativeMethods.WM_HSCROLL, NativeMethods.SB_PAGEUP);&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; LineDown()&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; SendMessage(NativeMethods.WM_VSCROLL, NativeMethods.SB_LINEDOWN);&lt;br&gt;
}&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; LineUp()&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; SendMessage(NativeMethods.WM_VSCROLL, NativeMethods.SB_LINEUP);&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; PageDown()&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; SendMessage(NativeMethods.WM_VSCROLL, NativeMethods.SB_PAGEDOWN);&lt;br&gt;
}&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; PageUp()&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; SendMessage(NativeMethods.WM_VSCROLL, NativeMethods.SB_PAGEUP);&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; SendMessage(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; msg, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; value)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; Microsoft.WindowsCE.Forms.Message m &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; Microsoft.WindowsCE.Forms.Message.Create(handle,
msg, (IntPtr)value, handle);&lt;br&gt;
&amp;nbsp; Microsoft.WindowsCE.Forms.MessageWindow.PostMessage(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ref&lt;/span&gt; m);&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
[DllImport(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"coredll.dll"&lt;/span&gt;)]&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;internal&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;extern&lt;/span&gt; IntPtr
GetWindow(IntPtr hWnd, GW uCmd);&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;internal&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;enum&lt;/span&gt; GW
: &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt;
&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; HWNDFIRST &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 0,&lt;br&gt;
&amp;nbsp; HWNDLAST &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 1,&lt;br&gt;
&amp;nbsp; HWNDNEXT &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 2,&lt;br&gt;
&amp;nbsp; HWNDPREV &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 3,&lt;br&gt;
&amp;nbsp; OWNER &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 4,&lt;br&gt;
&amp;nbsp; CHILD &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 5,&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//scrollbar
messages&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;internal&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;const&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; WM_HSCROLL &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 0x0114;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;internal&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;const&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; WM_VSCROLL &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 0x0115;&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//constants
for scrollbar actions&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;internal&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;const&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; SB_LINEUP &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 0;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;internal&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;const&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; SB_LINEDOWN &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 1;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;internal&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;const&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; SB_PAGEUP &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 2;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;internal&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;const&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; SB_PAGEDOWN &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 3;&lt;br&gt;
&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
In order to use the control you create a new instance passing it the control of your
choice. Then call methods to scroll the control e.g.
&lt;/p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private&lt;/span&gt; ScrollBarHelper
wsbh;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private&lt;/span&gt; ScrollBarHelper
tsbh;&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; Form1_Load(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; sender,
EventArgs e)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; wsbh &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; ScrollBarHelper(webBrowser1);&lt;br&gt;
&amp;nbsp; tsbh &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; ScrollBarHelper(textBox1);&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; button1_Click(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; sender,
EventArgs e)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; tsbh.PageUp(); 
&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;/span&gt;&lt;/span&gt; 
&lt;p&gt;
The control contains methods to Scroll via single lines or pages at a time, I didn't
get around to looking at setting the explicit value of the scrollbar control, but
this should be possible also - refer to the documentation for &lt;a href="http://msdn2.microsoft.com/en-us/library/ms912690.aspx"&gt;WM_VSCROLL&lt;/a&gt; for
how to pass the value.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=769dafe3-f1a9-429d-bd03-a2872868dd8f" /&gt;</description>
      <category>How To</category>
      <category>NETCF</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=5e8c66d2-b86a-4e81-a929-fe2f78b9ba38</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,5e8c66d2-b86a-4e81-a929-fe2f78b9ba38.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
While testing code using HttpWebRequest it can be observed in the debug output that
a number of exceptions are thrown within the GetResponse call of a HttpWebRequest.
If you run exactly the same code on the desktop you don't see this behaviour. For
reference the following is a simple example which displays the issue:-
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">System.Net.WebRequest
request <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> System.Net.WebRequest.Create(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"http://www.microsoft.com"</span>);<br />
System.Net.WebResponse webResponse <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> request.GetResponse();<br />
webResponse.Close();</span>
        </p>
        <p>
Since the exceptions are caught it doesn't stop the code from running but I considered
it annoying enough to investigate and try to find the cause. Here is the typical output
during the call to GetResponse:-
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">A
first chance exception of type 'System.IO.IOException' occurred <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">in</span> mscorlib.dll<br />
A first chance exception of type 'System.UriFormatException' occurred <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">in</span> System.dll<br />
The thread 0x577c6eaa has exited with code 0 (0x0).<br />
The thread 0xaf16af8a has exited with code 0 (0x0).<br />
A first chance exception of type 'System.UriFormatException' occurred <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">in</span> System.dll<br />
The thread 0x577c6eaa has exited with code 0 (0x0).<br />
The thread 0xaf16af8a has exited with code 0 (0x0).<br />
The thread 0xaf399a02 has exited with code 0 (0x0).</span>
        </p>
        <p>
I eventually tracked it down to an issue with WebProxy. It occurs if you do not specify
a Proxy or use the system proxy:-
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">request.Proxy <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> System.Net.GlobalProxySelection.Select;</span>
        </p>
        <p>
If you won't be using a proxy you can set the Proxy property to an empty WebProxy:-
</p>
        <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
          <p>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">request.Proxy <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> System.Net.GlobalProxySelection.GetEmptyWebProxy();</span>
          </p>
        </span>
        <p>
After making this change you'll see the method progress without any exceptions - you'll
just see the 5 thread exit notifications in the output. Whether or not this makes
a noticeable difference to performance I have yet to discover but it does indicate
an underlying issue since the desktop has no such problem.
</p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=5e8c66d2-b86a-4e81-a929-fe2f78b9ba38" />
      </body>
      <title>HttpWebRequest Exceptions under .NETCF</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,5e8c66d2-b86a-4e81-a929-fe2f78b9ba38.aspx</guid>
      <link>http://peterfoot.net/HttpWebRequestExceptionsUnderNETCF.aspx</link>
      <pubDate>Wed, 09 Jan 2008 20:39:47 GMT</pubDate>
      <description>&lt;p&gt;
While testing code using HttpWebRequest it can be observed in the debug output that
a number of exceptions are thrown within the GetResponse call of a HttpWebRequest.
If you run exactly the same code on the desktop you don't see this behaviour. For
reference the following is a simple example which displays the issue:-
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;System.Net.WebRequest
request &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; System.Net.WebRequest.Create(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"http://www.microsoft.com"&lt;/span&gt;);&lt;br&gt;
System.Net.WebResponse webResponse &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; request.GetResponse();&lt;br&gt;
webResponse.Close();&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
Since the exceptions are caught it doesn't stop the code from running but I considered
it annoying enough to investigate and try to find the cause. Here is the typical output
during the call to GetResponse:-
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;A
first chance exception of type 'System.IO.IOException' occurred &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;in&lt;/span&gt; mscorlib.dll&lt;br&gt;
A first chance exception of type 'System.UriFormatException' occurred &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;in&lt;/span&gt; System.dll&lt;br&gt;
The thread 0x577c6eaa has exited with code 0 (0x0).&lt;br&gt;
The thread 0xaf16af8a has exited with code 0 (0x0).&lt;br&gt;
A first chance exception of type 'System.UriFormatException' occurred &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;in&lt;/span&gt; System.dll&lt;br&gt;
The thread 0x577c6eaa has exited with code 0 (0x0).&lt;br&gt;
The thread 0xaf16af8a has exited with code 0 (0x0).&lt;br&gt;
The thread 0xaf399a02 has exited with code 0 (0x0).&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
I eventually tracked it down to an issue with WebProxy. It occurs if you do not specify
a Proxy or use the system proxy:-
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;request.Proxy &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; System.Net.GlobalProxySelection.Select;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
If you won't be using a proxy you can set the Proxy property to an empty WebProxy:-
&lt;/p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;request.Proxy &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; System.Net.GlobalProxySelection.GetEmptyWebProxy();&lt;/span&gt;
&lt;/p&gt;
&lt;/span&gt; 
&lt;p&gt;
After making this change you'll see the method progress without any exceptions - you'll
just see the 5 thread exit notifications in the output. Whether or not this makes
a noticeable difference to performance I have yet to discover but it does indicate
an underlying issue since the desktop has no such problem.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=5e8c66d2-b86a-4e81-a929-fe2f78b9ba38" /&gt;</description>
      <category>NETCF</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=a27e0377-c4d7-41bb-af39-46c23135c6a2</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,a27e0377-c4d7-41bb-af39-46c23135c6a2.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
One of the new features in v3.5 of the Compact Framework is the ability to easily
detect the platform you are running on from Smartphone (Standard Edition), PocketPC
(Classic or Professional Editions) or WinCEGeneric (Everything else). The code is
very straight-forward:-
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">using</span> Microsoft.WindowsCE.Forms;<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">if</span>(SystemSettings.Platform
== WinCEPlatform.Smartphone)<br />
{<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   //do
something smartphone specific...</span><br />
}</span>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <br />
 
</span>
        </p>
        <p>
In the latest (v3.0) version of <a href="http://inthehand.com/content/Mobile.aspx">Mobile
In The Hand</a> I've implemented a matching property, so for the above code sample
you'd just change the using statement to use InTheHand.WindowsCE.Forms and the code
would work the same way. This is available in both the .NETCF v1.0 and v2.0 builds
of the library.
</p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=a27e0377-c4d7-41bb-af39-46c23135c6a2" />
      </body>
      <title>Determine Platform - .NETCF 3.5 and earlier</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,a27e0377-c4d7-41bb-af39-46c23135c6a2.aspx</guid>
      <link>http://peterfoot.net/DeterminePlatformNETCF35AndEarlier.aspx</link>
      <pubDate>Fri, 23 Nov 2007 11:58:38 GMT</pubDate>
      <description>&lt;p&gt;
One of the new features in v3.5 of the Compact Framework is the ability to easily
detect the platform you are running on from Smartphone (Standard Edition), PocketPC
(Classic or Professional Editions) or WinCEGeneric (Everything else). The code is
very straight-forward:-
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; Microsoft.WindowsCE.Forms;&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;if&lt;/span&gt;(SystemSettings.Platform
== WinCEPlatform.Smartphone)&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//do
something smartphone specific...&lt;/span&gt;
&lt;br&gt;
}&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;
&lt;br&gt;
&amp;nbsp;
&lt;/p&gt;
&gt; 
&lt;p&gt;
In the latest (v3.0) version of &lt;a href="http://inthehand.com/content/Mobile.aspx"&gt;Mobile
In The Hand&lt;/a&gt; I've implemented a matching property, so for the above code sample
you'd just change the using statement to use InTheHand.WindowsCE.Forms and the code
would work the same way. This is available in both the .NETCF v1.0 and v2.0 builds
of the library.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=a27e0377-c4d7-41bb-af39-46c23135c6a2" /&gt;</description>
      <category>NETCF</category>
      <category>Windows Mobile</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=b8edd0a4-1557-4d5a-9ec5-965d3577a153</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,b8edd0a4-1557-4d5a-9ec5-965d3577a153.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In The Hand Ltd today released Networking In The Hand, a developer library for the
.NET Compact Framework 2.0 and 3.5 Beta. This library adds additional networking functionality
not found in in the Compact Framework while matching the object model used in the
full .NET framework to make it easy to share your code between platforms. Functionality
includes:-
</p>
        <ul>
          <li>
            <div>
              <strong>InTheHand.Net.WebClient</strong> - Provides helper methods for working
with information upload and download over HTTP and FTP transports, and any other WebRequest
based implementations.
</div>
          </li>
          <li>
            <div>
              <strong>InTheHand.Net.FtpWebRequest</strong> - Provides a complete desktop compatible
implementation of the WebRequest pattern for FTP.
</div>
          </li>
          <li>
            <div>
              <strong>InTheHand.Net.WebRequestMethods</strong> - Provides a reference of all
the HTTP and FTP methods (GET/POST etc)
</div>
          </li>
          <li>
            <div>
              <strong>InTheHand.Net.NetworkInformation.Ping</strong> - Perform a Ping and determine
network availability and performance.
</div>
          </li>
          <li>
            <div>
              <strong>InTheHand.Net.NetworkInformation.IPGlobalProperties</strong> - Retrieve
a wide range of networking statistics to measure traffic and help identify faults.
</div>
          </li>
        </ul>
        <p>
The library is licensed on a per-developer basis with no additional royalties required
to distribute the runtime with your applications. Full details on the product can
be found on the product details page - <a href="http://inthehand.com/content/Networking.aspx">http://inthehand.com/content/Networking.aspx</a>.
A fully functionality Evaluation version is available to download - <a href="http://inthehand.com/files/folders/evals/entry4014.aspx">http://inthehand.com/files/folders/evals/entry4014.aspx</a>.
</p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=b8edd0a4-1557-4d5a-9ec5-965d3577a153" />
      </body>
      <title>New Networking Component</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,b8edd0a4-1557-4d5a-9ec5-965d3577a153.aspx</guid>
      <link>http://peterfoot.net/NewNetworkingComponent.aspx</link>
      <pubDate>Fri, 21 Sep 2007 15:45:22 GMT</pubDate>
      <description>&lt;p&gt;
In The Hand Ltd today released Networking In The Hand, a developer library for the
.NET Compact Framework 2.0 and 3.5 Beta. This library adds additional networking functionality
not found in in the Compact Framework while matching the object model used in the
full .NET framework to make it easy to share your code between platforms. Functionality
includes:-
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;&lt;strong&gt;InTheHand.Net.WebClient&lt;/strong&gt; - Provides helper methods for working
with information upload and download over HTTP and FTP transports, and any other WebRequest
based implementations.
&lt;/div&gt;
&lt;li&gt;
&lt;div&gt;&lt;strong&gt;InTheHand.Net.FtpWebRequest&lt;/strong&gt; - Provides a complete desktop compatible
implementation of the WebRequest pattern for FTP.
&lt;/div&gt;
&lt;li&gt;
&lt;div&gt;&lt;strong&gt;InTheHand.Net.WebRequestMethods&lt;/strong&gt; - Provides a reference of all
the HTTP and FTP methods (GET/POST etc)
&lt;/div&gt;
&lt;li&gt;
&lt;div&gt;&lt;strong&gt;InTheHand.Net.NetworkInformation.Ping&lt;/strong&gt; - Perform a Ping and determine
network availability and performance.
&lt;/div&gt;
&lt;li&gt;
&lt;div&gt;&lt;strong&gt;InTheHand.Net.NetworkInformation.IPGlobalProperties&lt;/strong&gt; - Retrieve
a wide range of networking statistics to measure traffic and help identify faults.
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
The library is licensed on a per-developer basis with no additional royalties required
to distribute the runtime with your applications. Full details on the product can
be found on the product details page - &lt;a href="http://inthehand.com/content/Networking.aspx"&gt;http://inthehand.com/content/Networking.aspx&lt;/a&gt;.
A fully functionality Evaluation version is available to download - &lt;a href="http://inthehand.com/files/folders/evals/entry4014.aspx"&gt;http://inthehand.com/files/folders/evals/entry4014.aspx&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=b8edd0a4-1557-4d5a-9ec5-965d3577a153" /&gt;</description>
      <category>NETCF</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=da5c04d1-7742-4441-9ad0-5afb10a9db36</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,da5c04d1-7742-4441-9ad0-5afb10a9db36.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In .NETCF v3.5 there is a new namespace - System.Media which brings audio support
to the Compact Framework. Previously the common way to add sounds to your application
was to use the PlaySound API (either P/Invoking yourself or using one of many wrappers).
Now that the framework itself has built-in support, which matches the desktop .NET
v2.0 framework it makes sense to standardise on the <a href="http://msdn2.microsoft.com/en-us/library/system.media.soundplayer_members(VS.90).aspx">SoundPlayer</a> component.
</p>
        <p>
There are some differences in behaviour which you'll need to be aware of. When you
specify a filename this doesn't simply call through to the native APIs passing the
filename, the file is first loaded into memory and then the WaveOut APIs are used
to play it. This means that if you simply create a new <em>SoundPlayer</em> and call <em>Play</em> the
file will not be loaded, the Play method will have to first load the file contents,
and then play the sound. This will create a noticable delay before the sound is heard.
The class allows you to load the file at any time prior to calling play - you can
use either <em>Load</em> or <em>LoadAsync</em> to do this. Once the file is loaded
the Play method will be able to immediately begin playing the file. Exactly where
you call the <em>Load/LoadAsync</em> method will depend on your application design.
Keeping a large audio file cached will tie up valuable memory, you should dispose
of the SoundPlayer instance once you have finished with it.
</p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=da5c04d1-7742-4441-9ad0-5afb10a9db36" />
      </body>
      <title>System.Media.SoundPlayer versus the PlaySound API</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,da5c04d1-7742-4441-9ad0-5afb10a9db36.aspx</guid>
      <link>http://peterfoot.net/SystemMediaSoundPlayerVersusThePlaySoundAPI.aspx</link>
      <pubDate>Tue, 21 Aug 2007 15:51:09 GMT</pubDate>
      <description>&lt;p&gt;
In .NETCF v3.5 there is a new namespace - System.Media which brings audio support
to the Compact Framework. Previously the common way to add sounds to your application
was to use the PlaySound API (either P/Invoking yourself or using one of many wrappers).
Now that the framework itself has built-in support, which matches the desktop .NET
v2.0 framework it makes sense to standardise on the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.media.soundplayer_members(VS.90).aspx"&gt;SoundPlayer&lt;/a&gt; component.
&lt;/p&gt;
&lt;p&gt;
There are some differences in behaviour which you'll need to be aware of. When you
specify a filename this doesn't simply call through to the native APIs passing the
filename, the file is first loaded into memory and then the WaveOut APIs are used
to play it. This means that if you simply create a new &lt;em&gt;SoundPlayer&lt;/em&gt; and call &lt;em&gt;Play&lt;/em&gt; the
file will not be loaded, the Play method will have to first load the file contents,
and then play the sound. This will create a noticable delay before the sound is heard.
The class allows you to load the file at any time prior to calling play - you can
use either &lt;em&gt;Load&lt;/em&gt; or &lt;em&gt;LoadAsync&lt;/em&gt; to do this. Once the file is loaded
the Play method will be able to immediately begin playing the file. Exactly where
you call the &lt;em&gt;Load/LoadAsync&lt;/em&gt; method will depend on your application design.
Keeping a large audio file cached will tie up valuable memory, you should dispose
of the SoundPlayer instance once you have finished with it.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=da5c04d1-7742-4441-9ad0-5afb10a9db36" /&gt;</description>
      <category>NETCF</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=110d4195-6309-4cff-9aa9-2cd4e2b465d4</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,110d4195-6309-4cff-9aa9-2cd4e2b465d4.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
On the newsgroup somebody asked how to have multiple lines of text on a .NETCF Button
control. The native control supports this but the appropriate style is not set by
default. The following code snippet shows how to enable this:-
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">private</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">const</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> BS_MULTILINE <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 0x00002000;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">const</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> GWL_STYLE <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> -16;<br /><br />
[System.Runtime.InteropServices.DllImport(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"coredll"</span>)]<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">static</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">extern</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> GetWindowLong(IntPtr
hWnd, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> nIndex);<br /><br />
[System.Runtime.InteropServices.DllImport(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"coredll"</span>)]<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">static</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">extern</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> SetWindowLong(IntPtr
hWnd, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> nIndex, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> dwNewLong);<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">static</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> MakeButtonMultiline(Button
b)<br />
{<br />
    IntPtr hwnd <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> b.Handle;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   
int</span> currentStyle <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> GetWindowLong(hwnd,
GWL_STYLE);<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   
int</span> newStyle <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> SetWindowLong(hwnd,
GWL_STYLE, currentStyle <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">|</span> BS_MULTILINE);<br />
}</span>
        </p>
        <p>
The usage is simple, just pass the specific Button control to MakeButtonMultiline:-
</p>
        <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
          <p>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">MakeButtonMultiline(button1);</span>
          </p>
          <p>
Here is what the amended button looks like on the left (default appearance on the
right)
</p>
          <p>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            </span>
          </p>
          <p>
          </p>
        </span>
        <img src="http://peterfoot.net/content/binary/MultilineButton.png" border="0" />
        <p>
The designer fully supports entering multiple lines for the Button Text property,
just click the dropdown at the end of the field and it will pop up a window into which
you can add linebreaks with your text.
</p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=110d4195-6309-4cff-9aa9-2cd4e2b465d4" />
      </body>
      <title>Multiline Button</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,110d4195-6309-4cff-9aa9-2cd4e2b465d4.aspx</guid>
      <link>http://peterfoot.net/MultilineButton.aspx</link>
      <pubDate>Fri, 27 Jul 2007 09:24:36 GMT</pubDate>
      <description>&lt;p&gt;
On the newsgroup somebody asked how to have multiple lines of text on a .NETCF Button
control. The native control supports this but the appropriate style is not set by
default. The following code snippet shows how to enable this:-
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;const&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; BS_MULTILINE &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 0x00002000;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;const&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; GWL_STYLE &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; -16;&lt;br&gt;
&lt;br&gt;
[System.Runtime.InteropServices.DllImport(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"coredll"&lt;/span&gt;)]&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;extern&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; GetWindowLong(IntPtr
hWnd, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; nIndex);&lt;br&gt;
&lt;br&gt;
[System.Runtime.InteropServices.DllImport(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"coredll"&lt;/span&gt;)]&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;extern&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; SetWindowLong(IntPtr
hWnd, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; nIndex, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; dwNewLong);&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; MakeButtonMultiline(Button
b)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; IntPtr hwnd &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; b.Handle;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
int&lt;/span&gt; currentStyle &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; GetWindowLong(hwnd,
GWL_STYLE);&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
int&lt;/span&gt; newStyle &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; SetWindowLong(hwnd,
GWL_STYLE, currentStyle &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;|&lt;/span&gt; BS_MULTILINE);&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
The usage is simple, just pass the specific Button control to MakeButtonMultiline:-
&lt;/p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;MakeButtonMultiline(button1);&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
Here is what the amended button looks like on the left (default appearance on the
right)
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/span&gt;&lt;img src="http://peterfoot.net/content/binary/MultilineButton.png" border=0&gt;&gt;
&lt;p&gt;
The designer fully supports entering multiple lines for the Button Text property,
just click the dropdown at the end of the field and it will pop up a window into which
you can add linebreaks with your text.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=110d4195-6309-4cff-9aa9-2cd4e2b465d4" /&gt;</description>
      <category>NETCF</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=ef787d84-f757-4b60-96cf-7ada49e346cf</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,ef787d84-f757-4b60-96cf-7ada49e346cf.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I'm now a member of the CodePlex workspace for the <a href="http://www.codeplex.com/FacebookToolkit/">Facebook
Developer Toolkit</a>. I've been working on porting across my modifications into the
codebase. The .NETCF v2.0 version uses a project called Facebook.Compact but refers
to the existing source files from the desktop project. Then some conditional compilation
is used to hide a few unsupported features from .NETCF and implement some workarounds
for missing functionality. This will be a familiar technique if you've been to <a href="http://www.danielmoth.com/Blog/">Daniel</a>'s
sessions (or read his blog posts on the subject). It's not quite working yet since
my code made use of a couple of my own libraries for speed, so I'll need to implement
a few of the features within those in the Facebook.Compact project.
</p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=ef787d84-f757-4b60-96cf-7ada49e346cf" />
      </body>
      <title>More Facebook Progress</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,ef787d84-f757-4b60-96cf-7ada49e346cf.aspx</guid>
      <link>http://peterfoot.net/MoreFacebookProgress.aspx</link>
      <pubDate>Tue, 24 Jul 2007 20:21:07 GMT</pubDate>
      <description>&lt;p&gt;
I'm now&amp;nbsp;a member&amp;nbsp;of the CodePlex workspace for the &lt;a href="http://www.codeplex.com/FacebookToolkit/"&gt;Facebook
Developer Toolkit&lt;/a&gt;. I've been working on porting across my modifications into the
codebase. The .NETCF v2.0 version uses a project called Facebook.Compact but refers
to the existing source files from the desktop project. Then some conditional compilation
is used to hide a few unsupported features from .NETCF and implement some workarounds
for missing functionality. This will be a familiar technique if you've been to &lt;a href="http://www.danielmoth.com/Blog/"&gt;Daniel&lt;/a&gt;'s
sessions (or read his blog posts on the subject). It's not quite working yet since
my code made use of a couple of my own libraries for speed, so I'll need to implement
a few of the features within those in the Facebook.Compact project.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=ef787d84-f757-4b60-96cf-7ada49e346cf" /&gt;</description>
      <category>NETCF</category>
      <category>Facebook</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=e8a8af17-e500-46d9-b3db-ff5c1cd2566f</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,e8a8af17-e500-46d9-b3db-ff5c1cd2566f.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The <a href="http://developers.facebook.com/">Facebook API</a> allows third-party
web and desktop applications to interact with Facebook features. There is an excellent <a href="http://www.codeplex.com/FacebookToolkit/">shared-source</a> library
for .NET to wrap the Facebook calls but currently it only supports the full framework.
I did some work converting this source to compile and run on .NETCF v2.0. There are
some example screens here of the login process, and pulling back information about <a href="http://www.facebook.com/group.php?gid=2395373536">our
book group</a>.
</p>
        <p>
          <img src="/content/binary/FacebookLogin.png" border="0" />   <img src="/content/binary/FacebookGroup.png" border="0" /></p>
        <p>
Since the login screen uses the same page as the desktop it's not a great fit on a
Pocket PC screen, so that's an area for improvement.
</p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=e8a8af17-e500-46d9-b3db-ff5c1cd2566f" />
      </body>
      <title>Facebook API and the Compact Framework</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,e8a8af17-e500-46d9-b3db-ff5c1cd2566f.aspx</guid>
      <link>http://peterfoot.net/FacebookAPIAndTheCompactFramework.aspx</link>
      <pubDate>Fri, 20 Jul 2007 08:52:49 GMT</pubDate>
      <description>&lt;p&gt;
The &lt;a href="http://developers.facebook.com/"&gt;Facebook API&lt;/a&gt; allows third-party
web and desktop applications to interact with Facebook features. There is an excellent &lt;a href="http://www.codeplex.com/FacebookToolkit/"&gt;shared-source&lt;/a&gt; library
for .NET to wrap the Facebook calls but currently it only supports the full framework.
I did some work converting this source to compile and run on .NETCF v2.0. There are
some example screens here of the login process, and pulling back information about &lt;a href="http://www.facebook.com/group.php?gid=2395373536"&gt;our
book group&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="/content/binary/FacebookLogin.png" border=0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;img src="/content/binary/FacebookGroup.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Since the login screen uses the same page as the desktop it's not a great fit on a
Pocket PC screen, so that's an area for improvement.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=e8a8af17-e500-46d9-b3db-ff5c1cd2566f" /&gt;</description>
      <category>Facebook</category>
      <category>NETCF</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=c43edeb3-8b5c-4f28-a30b-c4b643848508</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,c43edeb3-8b5c-4f28-a30b-c4b643848508.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://nativemobile.blogspot.com/">João Paulo</a> was <a href="http://nativemobile.blogspot.com/2007/06/primary-key-or-index-rowguidcol-or.html">investigating
Guid performance</a> when used as identifiers in a SQL Compact database and discovered
that the performance of <em>Guid.NewGuid()</em> left a lot to be desired. The reason
for this is that the function uses lowest-common-denominator support, using a random
number generator and setting a couple of specific bits to conform to guid standards.
Another method I've been recommending for some time is to use the native <em>CoCreateGuid()</em> function
- see <a href="http://www.peterfoot.net/NeedAGUIDInAHurry.aspx">http://www.peterfoot.net/NeedAGUIDInAHurry.aspx</a>.
This method is supported in all devices running Windows Mobile 2003 and above, and
in Windows CE 4.x. I've been using it in the <em>InTheHand.Guid2</em> class in <a href="http://inthehand.com/content/Mobile.aspx">Mobile
In The Hand</a> (Will be renamed to <em>GuidHelper</em> in the next version).
I did some tests creating 100,000 guids in a row with both methods. <em>Guid.NewGuid()</em> took
139 seconds, and <em>GuidHelper.NewGuid()</em> took a mere 9 seconds. As you can see
that is quite a significant difference.
</p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=c43edeb3-8b5c-4f28-a30b-c4b643848508" />
      </body>
      <title>Guid.NewGuid Performance</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,c43edeb3-8b5c-4f28-a30b-c4b643848508.aspx</guid>
      <link>http://peterfoot.net/GuidNewGuidPerformance.aspx</link>
      <pubDate>Mon, 25 Jun 2007 19:13:33 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://nativemobile.blogspot.com/"&gt;João Paulo&lt;/a&gt; was &lt;a href="http://nativemobile.blogspot.com/2007/06/primary-key-or-index-rowguidcol-or.html"&gt;investigating
Guid performance&lt;/a&gt; when used as identifiers in a SQL Compact database and discovered
that the performance of &lt;em&gt;Guid.NewGuid()&lt;/em&gt; left a lot to be desired. The reason
for this is that the function uses lowest-common-denominator support, using a random
number generator and setting a couple of specific bits to conform to guid standards.
Another method I've been recommending for some time is to use the native &lt;em&gt;CoCreateGuid()&lt;/em&gt; function
- see &lt;a href="http://www.peterfoot.net/NeedAGUIDInAHurry.aspx"&gt;http://www.peterfoot.net/NeedAGUIDInAHurry.aspx&lt;/a&gt;.
This method is supported in all devices running Windows Mobile 2003 and above, and
in Windows CE 4.x. I've been using it in the &lt;em&gt;InTheHand.Guid2&lt;/em&gt; class in &lt;a href="http://inthehand.com/content/Mobile.aspx"&gt;Mobile
In The Hand&lt;/a&gt;&amp;nbsp;(Will be renamed to &lt;em&gt;GuidHelper&lt;/em&gt; in the next version).
I did some tests creating 100,000 guids in a row with both methods. &lt;em&gt;Guid.NewGuid()&lt;/em&gt; took
139 seconds, and &lt;em&gt;GuidHelper.NewGuid()&lt;/em&gt; took a mere 9 seconds. As you can see
that is quite a significant difference.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=c43edeb3-8b5c-4f28-a30b-c4b643848508" /&gt;</description>
      <category>NETCF</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=f72a4f9d-f3fc-4ed3-b4f3-c258ce8ee005</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,f72a4f9d-f3fc-4ed3-b4f3-c258ce8ee005.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
There have been numerous occasions where I've needed to write code to launch another
process and wait for it to complete, usually taking some action based on the exit
code. Therefore I've got a handy helper method to do this. It has changed a few times
and is made much simpler in .NETCF v2.0 by taking advantage of the <a href="http://msdn2.microsoft.com/en-us/library/system.diagnostics.process.aspx">Process</a> class.
Most recently I used the code in one of <a href="http://www.microsoft.com/MSPress/books/10294.aspx">the
book</a> chapters to show automatic installation of the Microsoft Message Queue (MSMQ)
components onto a Windows Mobile device. The method is named ShellWait, as the name
implies it launches a process and waits, the return value is the exit code from the
process. If the application doesn't exist it returns -1 immediately.
</p>
        <p>
[C#]
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//helper
function to launch a process and wait for the result code</span>
            <br />
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">private</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">static</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> ShellWait(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span> app, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span> args)<br />
{<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
if</span> (!File.Exists(app))<br />
   {<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">     
return</span> -1;<br />
   }</span>
        </p>
        <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
          <p>
            <br />
   Process p <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> Process.Start(app,
args);<br />
   p.WaitForExit();
</p>
          <p>
            <br />
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
return</span> p.ExitCode;<br />
}
</p>
        </span>
        <p>
 
</p>
        <p>
[VB]
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Private</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Shared</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Function</span> ShellWait(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> app <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">String</span>, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> args <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">String</span>) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Integer</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
If</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Not</span> File.Exists(app) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Then</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">     
Return</span> -1<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
Dim</span> p <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> Process <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> Process.Start(app,
args)<br />
   p.WaitForExit()<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
Return</span> p.ExitCode<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Function</span></span>
        </p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=f72a4f9d-f3fc-4ed3-b4f3-c258ce8ee005" />
      </body>
      <title>Waiting for a Process</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,f72a4f9d-f3fc-4ed3-b4f3-c258ce8ee005.aspx</guid>
      <link>http://peterfoot.net/WaitingForAProcess.aspx</link>
      <pubDate>Mon, 14 May 2007 15:24:55 GMT</pubDate>
      <description>&lt;p&gt;
There have been numerous occasions where I've needed to write code to launch another
process and wait for it to complete, usually taking some action based on the exit
code. Therefore I've got a handy helper method to do this. It has changed a few times
and is made much simpler in .NETCF v2.0 by taking advantage of the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.diagnostics.process.aspx"&gt;Process&lt;/a&gt; class.
Most recently I used the code in one of &lt;a href="http://www.microsoft.com/MSPress/books/10294.aspx"&gt;the
book&lt;/a&gt; chapters to show automatic installation of the Microsoft Message Queue (MSMQ)
components onto a Windows Mobile device. The method is named ShellWait, as the name
implies it launches a process and waits, the return value is the exit code from the
process. If the application doesn't exist it returns -1 immediately.
&lt;/p&gt;
&lt;p&gt;
[C#]
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//helper
function to launch a process and wait for the result code&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; ShellWait(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; app, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; args)&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
if&lt;/span&gt; (!File.Exists(app))&lt;br&gt;
&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
return&lt;/span&gt; -1;&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;/span&gt;
&lt;/p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt; 
&lt;p&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; Process p &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; Process.Start(app,
args);&lt;br&gt;
&amp;nbsp;&amp;nbsp; p.WaitForExit();
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
return&lt;/span&gt; p.ExitCode;&lt;br&gt;
}
&lt;/span&gt;&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
[VB]
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Shared&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Function&lt;/span&gt; ShellWait(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; app &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;String&lt;/span&gt;, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; args &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;String&lt;/span&gt;) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Integer&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
If&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Not&lt;/span&gt; File.Exists(app) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Then&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Return&lt;/span&gt; -1&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
Dim&lt;/span&gt; p &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; Process &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; Process.Start(app,
args)&lt;br&gt;
&amp;nbsp;&amp;nbsp; p.WaitForExit()&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
Return&lt;/span&gt; p.ExitCode&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Function&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=f72a4f9d-f3fc-4ed3-b4f3-c258ce8ee005" /&gt;</description>
      <category>NETCF</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=eeba420c-bb14-43c3-8cef-0ea515467bb1</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,eeba420c-bb14-43c3-8cef-0ea515467bb1.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=06111a3a-a651-4745-88ef-3d48091a390b&amp;DisplayLang=en">Windows
Mobile 6 SDK Refresh </a>is available today. It includes some documentation enhancements
and new samples. One of these is called RingtoneManager and is a C# application which
wraps all the Sound APIs for ringtone management and sound playback, the latter of
which were introduced with Windows Mobile 6. This is great because it gives you all
the P/Invokes etc you need to use this functionality yourself. However expect to see
these Windows Mobile specific APIs in the next version of <a href="http://www.inthehand.com/WindowsMobile.aspx">Mobile
In The Hand</a>.
</p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=eeba420c-bb14-43c3-8cef-0ea515467bb1" />
      </body>
      <title>New Sounds sample in Windows Mobile 6 SDK Refresh</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,eeba420c-bb14-43c3-8cef-0ea515467bb1.aspx</guid>
      <link>http://peterfoot.net/NewSoundsSampleInWindowsMobile6SDKRefresh.aspx</link>
      <pubDate>Tue, 01 May 2007 15:14:51 GMT</pubDate>
      <description>&lt;p&gt;
The &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=06111a3a-a651-4745-88ef-3d48091a390b&amp;amp;DisplayLang=en"&gt;Windows
Mobile 6 SDK Refresh &lt;/a&gt;is available today. It includes some documentation enhancements
and new samples. One of these is called RingtoneManager and is a C# application which
wraps all the Sound APIs for ringtone management and sound playback, the latter of
which were introduced with Windows Mobile 6. This is great because it gives you all
the P/Invokes etc you need to use this functionality yourself. However expect to see
these Windows Mobile specific APIs in the next version of &lt;a href="http://www.inthehand.com/WindowsMobile.aspx"&gt;Mobile
In The Hand&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=eeba420c-bb14-43c3-8cef-0ea515467bb1" /&gt;</description>
      <category>NETCF</category>
      <category>Windows Mobile</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=31ac8c97-103c-46a8-8b79-5022ff6f398a</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,31ac8c97-103c-46a8-8b79-5022ff6f398a.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I've been a bit quiet over the past few weeks, on vacation and at the Microsoft MVP
Summit. I've also been working on the <a href="http://www.inthehand.com/TomTom.aspx">TomTom
In The Hand</a> library and today have released a new version.
</p>
        <p>
It turns out that TomTom SDK 6 <a href="http://forums.pp-p.com/forums/1/743/ShowThread.aspx">shipped
with a known bug</a> that prevents you from passing negative co-ordinates into
any of the methods (returned values were okay). At the moment I believe that our library
is the only one which has a fix for this bug which was a major headache for developers.
You can now use TomTom through this library wherever you reside in the world (assuming
you have map coverage of course) without making any changes to your existing code.
</p>
        <p>
This release also adds some new functionality - The <em>RawGpsReceived</em> event
on the <em>Navigator</em> object allows you to receive NMEA data from TomTom which
allows you to share this data if you are not already using a multiplexer such as the
Windows Mobile 5.0 GPS service or <a href="http://franson.com/gpsgate/">Franson GPS
Gate</a> or similar.
</p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=31ac8c97-103c-46a8-8b79-5022ff6f398a" />
      </body>
      <title>TomTom In The Hand 6.1</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,31ac8c97-103c-46a8-8b79-5022ff6f398a.aspx</guid>
      <link>http://peterfoot.net/TomTomInTheHand61.aspx</link>
      <pubDate>Mon, 26 Mar 2007 11:40:00 GMT</pubDate>
      <description>&lt;p&gt;
I've been a bit quiet over the past few weeks, on vacation and at the Microsoft MVP
Summit. I've also been working on the &lt;a href="http://www.inthehand.com/TomTom.aspx"&gt;TomTom
In The Hand&lt;/a&gt; library and today have released a new version.
&lt;/p&gt;
&lt;p&gt;
It turns out that TomTom SDK 6 &lt;a href="http://forums.pp-p.com/forums/1/743/ShowThread.aspx"&gt;shipped
with a known bug&lt;/a&gt; that prevents you from&amp;nbsp;passing negative co-ordinates into
any of the methods (returned values were okay). At the moment I believe that our&amp;nbsp;library
is the only one which has a fix for this bug which was a major headache for developers.
You can now use TomTom through this library wherever you reside in the world (assuming
you have map coverage of course) without making any changes to your existing code.
&lt;/p&gt;
&lt;p&gt;
This release also adds some new functionality - The &lt;em&gt;RawGpsReceived&lt;/em&gt; event
on the &lt;em&gt;Navigator&lt;/em&gt; object allows you to receive NMEA data from TomTom which
allows you to share this data if you are not already using a multiplexer such as the
Windows Mobile 5.0 GPS service or &lt;a href="http://franson.com/gpsgate/"&gt;Franson GPS
Gate&lt;/a&gt; or similar.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=31ac8c97-103c-46a8-8b79-5022ff6f398a" /&gt;</description>
      <category>NETCF</category>
      <category>TomTom</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=1838c8a1-ffba-4926-90cc-1bf41a9b4b5e</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,1838c8a1-ffba-4926-90cc-1bf41a9b4b5e.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Windows Mobile devices, both Smartphone and Pocket PC support Speakerphone functionality.
When operating through the Phone application the end user can toggle the state, up
until now there has been no documented way to achieve this through code. Last year
I investigated the issue on behalf of one of my readers and failed on several attempts
at simulating a press-and-hold of the green phone button. It turns out that the device
issues a specific key constant to change the state, and this can be simulated through
code. It also turns out that the constant is equivalent to VK_F16 (thats Keys.F16
for managed code). I've wrapped up the necessary P/Invoke into the following code:-
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">sealed</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">class</span> SpeakerPhone<br />
{<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">private</span> SpeakerPhone()
{ }<br /><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">///
&lt;summary&gt;</span><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">///
Toggles the SpeakerPhone state.</span><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">///
&lt;/summary&gt;</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">static</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> Toggle()<br />
{<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//keydown</span><br />
NativeMethods.keybd_event((<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">byte</span>)Keys.F16,
0, 0, 0);<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//keyup</span><br />
NativeMethods.keybd_event((<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">byte</span>)Keys.F16,
0, NativeMethods.KEYEVENTF_KEYUP, 0);<br />
}<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">internal</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">static</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">class</span> NativeMethods<br />
{<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">internal</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">const</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> KEYEVENTF_KEYUP <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 0x0002;<br /><br /><br />
[System.Runtime.InteropServices.DllImport(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"coredll.dll"</span>)]<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">internal</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">static</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">extern</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> keybd_event(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">byte</span> bVk, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">byte</span> bScan, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> dwFlags, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> dwExtraInfo);<br />
}<br />
}</span>
        </p>
        <p>
 
</p>
        <p>
Since this just toggles the state, you can't determine the current state
at any particular time. This code has been tested on Windows Mobile 5.0 and beyond
(It possibly works on Windows Mobile 2003 but I haven't tested), it doesn't work on
the Windows Mobile 5.0 Emulators as Speakerphone isn't implemented. I was able to
establish a call on speakerphone using the following code:
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Microsoft.WindowsMobile.Telephony.Phone
p <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> Microsoft.WindowsMobile.Telephony.Phone();<br />
p.Talk(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"01234567890"</span>);<br />
SpeakerPhone.Toggle();</span>
        </p>
        <p>
Once the call is ended the speakerphone state is restored on subsequent calls.
</p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=1838c8a1-ffba-4926-90cc-1bf41a9b4b5e" />
      </body>
      <title>Programmatically Activating Speakerphone</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,1838c8a1-ffba-4926-90cc-1bf41a9b4b5e.aspx</guid>
      <link>http://peterfoot.net/ProgrammaticallyActivatingSpeakerphone.aspx</link>
      <pubDate>Mon, 26 Feb 2007 19:08:03 GMT</pubDate>
      <description>&lt;p&gt;
Windows Mobile devices, both Smartphone and Pocket PC support Speakerphone functionality.
When operating through the Phone application the end user can toggle the state, up
until now there has been no documented way to achieve this through code. Last year
I investigated the issue on behalf of one of my readers and failed on several attempts
at simulating a press-and-hold of the green phone button. It turns out that the device
issues a specific key constant to change the state, and this can be simulated through
code. It also turns out that the constant is equivalent to VK_F16 (thats Keys.F16
for managed code). I've wrapped up the necessary P/Invoke into the following code:-
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;sealed&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;class&lt;/span&gt; SpeakerPhone&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private&lt;/span&gt; SpeakerPhone()
{ }&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
Toggles the SpeakerPhone state.&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; Toggle()&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//keydown&lt;/span&gt;
&lt;br&gt;
NativeMethods.keybd_event((&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;byte&lt;/span&gt;)Keys.F16,
0, 0, 0);&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//keyup&lt;/span&gt;
&lt;br&gt;
NativeMethods.keybd_event((&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;byte&lt;/span&gt;)Keys.F16,
0, NativeMethods.KEYEVENTF_KEYUP, 0);&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;internal&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;class&lt;/span&gt; NativeMethods&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;internal&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;const&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; KEYEVENTF_KEYUP &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 0x0002;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
[System.Runtime.InteropServices.DllImport(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"coredll.dll"&lt;/span&gt;)]&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;internal&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;extern&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; keybd_event(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;byte&lt;/span&gt; bVk, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;byte&lt;/span&gt; bScan, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; dwFlags, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; dwExtraInfo);&lt;br&gt;
}&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Since&amp;nbsp;this just&amp;nbsp;toggles the state, you can't determine the current state
at any particular time. This code has been tested on Windows Mobile 5.0 and beyond
(It possibly works on Windows Mobile 2003 but I haven't tested), it doesn't work on
the Windows Mobile 5.0 Emulators as Speakerphone isn't implemented. I was able to
establish a call on speakerphone using the following code:
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Microsoft.WindowsMobile.Telephony.Phone
p &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; Microsoft.WindowsMobile.Telephony.Phone();&lt;br&gt;
p.Talk(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"01234567890"&lt;/span&gt;);&lt;br&gt;
SpeakerPhone.Toggle();&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
Once the call is ended the speakerphone state is restored on subsequent calls.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=1838c8a1-ffba-4926-90cc-1bf41a9b4b5e" /&gt;</description>
      <category>NETCF</category>
      <category>Windows Mobile</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=6236517a-44bd-41f9-a7ac-05b30ccfa21f</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,6236517a-44bd-41f9-a7ac-05b30ccfa21f.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://www.binaryrefinery.com/main/">Richard</a> has just started blogging,
starting with a sample for maximising screen space by creating a <a href="http://www.binaryrefinery.com/main/PermaLink,guid,4c6d5b61-09a7-4e1d-b5c2-6a06397cb23e.aspx">Vista
style textbox</a> with integral label, and a description of what he has been up to
in the fight against "<a href="http://www.binaryrefinery.com/main/PermaLink,guid,1fc0a522-b4f6-4709-8975-cdb0a06dcab7.aspx">Monkey
Code</a>". I've subscribed to his <a href="http://www.binaryrefinery.com/main/SyndicationService.asmx/GetRss">RSS
feed</a> and added him to the blogroll.
</p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=6236517a-44bd-41f9-a7ac-05b30ccfa21f" />
      </body>
      <title>Richard Jones is Blogging</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,6236517a-44bd-41f9-a7ac-05b30ccfa21f.aspx</guid>
      <link>http://peterfoot.net/RichardJonesIsBlogging.aspx</link>
      <pubDate>Wed, 21 Feb 2007 08:34:25 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://www.binaryrefinery.com/main/"&gt;Richard&lt;/a&gt; has just started blogging,
starting with a sample for maximising screen space by creating a &lt;a href="http://www.binaryrefinery.com/main/PermaLink,guid,4c6d5b61-09a7-4e1d-b5c2-6a06397cb23e.aspx"&gt;Vista
style textbox&lt;/a&gt; with integral label, and a description of what he has been up to
in the fight against "&lt;a href="http://www.binaryrefinery.com/main/PermaLink,guid,1fc0a522-b4f6-4709-8975-cdb0a06dcab7.aspx"&gt;Monkey
Code&lt;/a&gt;". I've subscribed to his &lt;a href="http://www.binaryrefinery.com/main/SyndicationService.asmx/GetRss"&gt;RSS
feed&lt;/a&gt; and added him to the blogroll.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=6236517a-44bd-41f9-a7ac-05b30ccfa21f" /&gt;</description>
      <category>NETCF</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=9f4172e1-6836-43f9-8db8-523a28814c4a</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,9f4172e1-6836-43f9-8db8-523a28814c4a.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
When I previously posted the list of additional system properties I was using the
Windows Mobile 6 SDK Documentation as a reference. Well it turns out that there are
even more new properties, you can view them using Object Browser in your project but
they aren't included in the documentation. The other new properties are:-
</p>
        <ul>
          <li>
CameraEnabled - <em>This in addition to existing CameraPresent property</em></li>
          <li>
CellularSystemAvailable1xrtt 
</li>
          <li>
CellularSystemAvailableEdge 
</li>
          <li>
CellularSystemAvailableEvdo 
</li>
          <li>
CellularSystemAvailableEvdv 
</li>
          <li>
CellularSystemAvailableGprs 
</li>
          <li>
CellularSystemAvailableHsdpa 
</li>
          <li>
CellularSystemAvailableUmts 
</li>
          <li>
CellularSystemConnected1xrtt 
</li>
          <li>
CellularSystemConnectedEdge 
</li>
          <li>
CellularSystemConnectedEvdo 
</li>
          <li>
CellularSystemConnectedEvdv 
</li>
          <li>
CellularSystemConnectedGprs 
</li>
          <li>
CellularSystemConnectedHsdpa 
</li>
          <li>
CellularSystemConnectedUmts 
</li>
          <li>
ClamshellClosed 
</li>
          <li>
DeviceLocked 
</li>
          <li>
KeyLocked 
</li>
          <li>
LockStates - <em>A combination of flags for Device, Key and Sim locks</em></li>
          <li>
SimLocked 
</li>
          <li>
PhoneTalkingCallStartTime</li>
        </ul>
        <p>
 
</p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=9f4172e1-6836-43f9-8db8-523a28814c4a" />
      </body>
      <title>What's New For Managed Developers In Windows Mobile 6 (Part 2)</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,9f4172e1-6836-43f9-8db8-523a28814c4a.aspx</guid>
      <link>http://peterfoot.net/WhatsNewForManagedDevelopersInWindowsMobile6Part2.aspx</link>
      <pubDate>Wed, 14 Feb 2007 17:09:38 GMT</pubDate>
      <description>&lt;p&gt;
When I previously posted the list of additional system properties I was using the
Windows Mobile 6 SDK Documentation as a reference. Well it turns out that there are
even more new properties, you can view them using Object Browser in your project but
they aren't included in the documentation. The other new properties are:-
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
CameraEnabled - &lt;em&gt;This in addition to existing CameraPresent property&lt;/em&gt; 
&lt;li&gt;
CellularSystemAvailable1xrtt 
&lt;li&gt;
CellularSystemAvailableEdge 
&lt;li&gt;
CellularSystemAvailableEvdo 
&lt;li&gt;
CellularSystemAvailableEvdv 
&lt;li&gt;
CellularSystemAvailableGprs 
&lt;li&gt;
CellularSystemAvailableHsdpa 
&lt;li&gt;
CellularSystemAvailableUmts 
&lt;li&gt;
CellularSystemConnected1xrtt 
&lt;li&gt;
CellularSystemConnectedEdge 
&lt;li&gt;
CellularSystemConnectedEvdo 
&lt;li&gt;
CellularSystemConnectedEvdv 
&lt;li&gt;
CellularSystemConnectedGprs 
&lt;li&gt;
CellularSystemConnectedHsdpa 
&lt;li&gt;
CellularSystemConnectedUmts 
&lt;li&gt;
ClamshellClosed 
&lt;li&gt;
DeviceLocked 
&lt;li&gt;
KeyLocked 
&lt;li&gt;
LockStates - &lt;em&gt;A combination of flags for Device, Key and Sim locks&lt;/em&gt; 
&lt;li&gt;
SimLocked 
&lt;li&gt;
PhoneTalkingCallStartTime&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=9f4172e1-6836-43f9-8db8-523a28814c4a" /&gt;</description>
      <category>NETCF</category>
      <category>Windows Mobile</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=70103236-cee6-4ad9-b78e-7f743f63a685</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,70103236-cee6-4ad9-b78e-7f743f63a685.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Excellent news from <a href="http://blogs.msdn.com/sqlservereverywhere/archive/2007/01/10/sql-server-compact-edition-release-to-web-rtw.aspx">the
SQL Server Everywhere blog</a> (those guys need to change the name of their blog again
:-)). Tomorrow the runtimes and tools for SQL Server Compact Edition will be released
to the web. It will replace the RC1 download so the link will remain the same:-
</p>
        <p>
          <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=85E0C3CE-3FA1-453A-8CE9-AF6CA20946C3&amp;displaylang=en">http://www.microsoft.com/downloads/details.aspx?FamilyID=85E0C3CE-3FA1-453A-8CE9-AF6CA20946C3&amp;displaylang=en</a>
        </p>
        <p>
 
</p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=70103236-cee6-4ad9-b78e-7f743f63a685" />
      </body>
      <title>SQL Server Compact Edition - Coming Tomorrow</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,70103236-cee6-4ad9-b78e-7f743f63a685.aspx</guid>
      <link>http://peterfoot.net/SQLServerCompactEditionComingTomorrow.aspx</link>
      <pubDate>Wed, 10 Jan 2007 17:08:06 GMT</pubDate>
      <description>&lt;p&gt;
Excellent news from &lt;a href="http://blogs.msdn.com/sqlservereverywhere/archive/2007/01/10/sql-server-compact-edition-release-to-web-rtw.aspx"&gt;the
SQL Server Everywhere blog&lt;/a&gt; (those guys need to change the name of their blog again
:-)). Tomorrow the runtimes and tools for SQL Server Compact Edition will be released
to the web. It will replace the RC1 download so the link will remain the same:-
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=85E0C3CE-3FA1-453A-8CE9-AF6CA20946C3&amp;amp;displaylang=en"&gt;http://www.microsoft.com/downloads/details.aspx?FamilyID=85E0C3CE-3FA1-453A-8CE9-AF6CA20946C3&amp;amp;displaylang=en&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=70103236-cee6-4ad9-b78e-7f743f63a685" /&gt;</description>
      <category>NETCF</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=ba1491a4-c4de-4c98-9f01-e3cce38c00a4</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,ba1491a4-c4de-4c98-9f01-e3cce38c00a4.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The full framework TreeView control supports setting a Font on a per-node basis, the
Compact Framework control doesn't support this, however with a little interop magic
you can mark individual nodes as Bold. Because the .NETCF v2.0 TreeView control exposes
it's own window handle, and each TreeNode also exposes it's handle, we have all the
raw data we need to format the node. First we need to define a structure and a couple
of enumerations:-
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">internal</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">struct</span> TVITEM 
<br />
{ 
<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span> TVIF
mask; 
<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span> IntPtr
hItem; 
<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span> TVIS
state; 
<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span> TVIS
stateMask; 
<br />
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)]<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span> pszText; 
<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> cchTextMax; 
<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> iImage; 
<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> iSelectedImage; 
<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> cChildren; 
<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> lParam; 
<br />
}<br /><br />
[Flags()]<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">internal</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">enum</span> TVIF<br />
{<br />
TEXT =0x0001,<br />
IMAGE =0x0002,<br />
PARAM =0x0004,<br />
STATE =0x0008,<br />
HANDLE =0x0010,<br />
SELECTEDIMAGE =0x0020,<br />
CHILDREN =0x0040,<br />
}<br /><br />
[Flags()]<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">internal</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">enum</span> TVIS<br />
{<br />
SELECTED =0x0002,<br />
CUT =0x0004,<br />
DROPHILITED =0x0008,<br />
BOLD =0x0010,<br />
EXPANDED =0x0020,<br />
EXPANDEDONCE =0x0040,<br />
EXPANDPARTIAL =0x0080,<br /><br />
OVERLAYMASK =0x0F00,<br />
STATEIMAGEMASK =0xF000,<br />
USERMASK =0xF000,<br />
}</span>
        </p>
        <p>
 
</p>
        <p>
Then I've created a single static method which can set the bold state of any node:-
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">static</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> SetNodeEmphasis(TreeNode
n, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">bool</span> bold)<br />
{<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//get
the control and node handles</span><br />
IntPtr hTreeview <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> n.TreeView.Handle;<br />
IntPtr hNode <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> n.Handle;<br /><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//create
a TVITEM struct</span><br />
TVITEM t <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> TVITEM();<br />
t.hItem <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> hNode;<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//mark
only the handle and state members as valid</span><br />
t.mask <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> TVIF.HANDLE <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">|</span> TVIF.STATE;<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//set
the state to bold if bold param was true</span><br />
t.state <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> bold
? TVIS.BOLD : 0;<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//set
statemask to show we want to set the bold state</span><br />
t.stateMask <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> TVIS.BOLD;<br /><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//pin
the struct in memory</span><br />
GCHandle hTVITEM <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> GCHandle.Alloc(t,
GCHandleType.Pinned);<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//create
a TVM_SETITEM message with the handle of our pinned struct</span><br />
Microsoft.WindowsCE.Forms.Message m <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> Microsoft.WindowsCE.Forms.Message.Create(hTreeview,
0x113F, IntPtr.Zero, hTVITEM.AddrOfPinnedObject());<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//send
the message to the treeview</span><br />
Microsoft.WindowsCE.Forms.MessageWindow.SendMessage(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ref</span> m);<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//free
the pinned structure</span><br />
hTVITEM.Free();<br />
}</span>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <font face="Verdana" size="2">The
method is easy to reuse as you only need to pass the TreeNode in, it will grab the
handle of the parent control from the node itself. After applying the formatting to
a couple of nodes you'll get something like this:-</font>
          </span>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
          </span> 
</p>
        <img src="http://www.peterfoot.net/content/binary/treeviewnodes1.jpg" border="0" />
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=ba1491a4-c4de-4c98-9f01-e3cce38c00a4" />
      </body>
      <title>Make Individual TreeView Nodes Bold</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,ba1491a4-c4de-4c98-9f01-e3cce38c00a4.aspx</guid>
      <link>http://peterfoot.net/MakeIndividualTreeViewNodesBold.aspx</link>
      <pubDate>Thu, 30 Nov 2006 10:08:27 GMT</pubDate>
      <description>&lt;p&gt;
The full framework TreeView control supports setting a Font on a per-node basis, the
Compact Framework control doesn't support this, however with a little interop magic
you can mark individual nodes as Bold. Because the .NETCF v2.0 TreeView control exposes
it's own window handle, and each TreeNode also exposes it's handle, we have all the
raw data we need to format the node. First we need to define a structure and a couple
of enumerations:-
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;internal&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;struct&lt;/span&gt; TVITEM 
&lt;br&gt;
{ 
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; TVIF
mask; 
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; IntPtr
hItem; 
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; TVIS
state; 
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; TVIS
stateMask; 
&lt;br&gt;
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)]&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; pszText; 
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; cchTextMax; 
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; iImage; 
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; iSelectedImage; 
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; cChildren; 
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; lParam; 
&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
[Flags()]&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;internal&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;enum&lt;/span&gt; TVIF&lt;br&gt;
{&lt;br&gt;
TEXT =0x0001,&lt;br&gt;
IMAGE =0x0002,&lt;br&gt;
PARAM =0x0004,&lt;br&gt;
STATE =0x0008,&lt;br&gt;
HANDLE =0x0010,&lt;br&gt;
SELECTEDIMAGE =0x0020,&lt;br&gt;
CHILDREN =0x0040,&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
[Flags()]&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;internal&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;enum&lt;/span&gt; TVIS&lt;br&gt;
{&lt;br&gt;
SELECTED =0x0002,&lt;br&gt;
CUT =0x0004,&lt;br&gt;
DROPHILITED =0x0008,&lt;br&gt;
BOLD =0x0010,&lt;br&gt;
EXPANDED =0x0020,&lt;br&gt;
EXPANDEDONCE =0x0040,&lt;br&gt;
EXPANDPARTIAL =0x0080,&lt;br&gt;
&lt;br&gt;
OVERLAYMASK =0x0F00,&lt;br&gt;
STATEIMAGEMASK =0xF000,&lt;br&gt;
USERMASK =0xF000,&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Then I've created a single static method which can set the bold state of any node:-
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; SetNodeEmphasis(TreeNode
n, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;bool&lt;/span&gt; bold)&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//get
the control and node handles&lt;/span&gt;
&lt;br&gt;
IntPtr hTreeview &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; n.TreeView.Handle;&lt;br&gt;
IntPtr hNode &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; n.Handle;&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//create
a TVITEM struct&lt;/span&gt;
&lt;br&gt;
TVITEM t &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; TVITEM();&lt;br&gt;
t.hItem &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; hNode;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//mark
only the handle and state members as valid&lt;/span&gt;
&lt;br&gt;
t.mask &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; TVIF.HANDLE &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;|&lt;/span&gt; TVIF.STATE;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//set
the state to bold if bold param was true&lt;/span&gt;
&lt;br&gt;
t.state &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; bold
? TVIS.BOLD : 0;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//set
statemask to show we want to set the bold state&lt;/span&gt;
&lt;br&gt;
t.stateMask &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; TVIS.BOLD;&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//pin
the struct in memory&lt;/span&gt;
&lt;br&gt;
GCHandle hTVITEM &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; GCHandle.Alloc(t,
GCHandleType.Pinned);&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//create
a TVM_SETITEM message with the handle of our pinned struct&lt;/span&gt;
&lt;br&gt;
Microsoft.WindowsCE.Forms.Message m &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; Microsoft.WindowsCE.Forms.Message.Create(hTreeview,
0x113F, IntPtr.Zero, hTVITEM.AddrOfPinnedObject());&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//send
the message to the treeview&lt;/span&gt;
&lt;br&gt;
Microsoft.WindowsCE.Forms.MessageWindow.SendMessage(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ref&lt;/span&gt; m);&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//free
the pinned structure&lt;/span&gt;
&lt;br&gt;
hTVITEM.Free();&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana size=2&gt;The
method is easy to reuse as you only need to pass the TreeNode in, it will grab the
handle of the parent control from the node itself. After applying the formatting to
a couple of nodes you'll get something like this:-&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;img src="http://www.peterfoot.net/content/binary/treeviewnodes1.jpg" border=0&gt;&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=ba1491a4-c4de-4c98-9f01-e3cce38c00a4" /&gt;</description>
      <category>NETCF</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=5ad38128-2e4c-4afd-9682-1d0b571a0e40</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,5ad38128-2e4c-4afd-9682-1d0b571a0e40.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
First things first a disclaimer, the following code is written for Mobile In The Hand
(Professional Edition), it does apply equally to a Windows Mobile 5.0 project with
the Microsoft.WindowsMobile managed APIs, you'll just need to change the namespaces
and assembly references.
</p>
        <p>
A normal MessageInterceptor is valid only for the lifetime of your application, once
you shut down you'll no longer be able to respond to messages that match your rule.
In many cases you'll want a specific message to launch your application and then process
as normal. The IApplicationLauncher interface which MessageInterceptor implements
contains methods to set this up. This allows the system to start your application,
optionally with command line arguments of your choosing. This is useful so that you
can tell when your app was called by an incoming SMS and when launched manually. The
following code snippet is called in Form_Load, it checks for an existing registration,
if not present it sets up all the required settings. The ApplicationLaunchId is a
string which is unique to your application, if you try to register with an id which
is already in use you'll receive an Exception.
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">if</span> (InTheHand.WindowsMobile.PocketOutlook.MessageInterception.MessageInterceptor.IsApplicationLauncherEnabled(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"testapp"</span>))<br />
{<br />
    mi <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> InTheHand.WindowsMobile.PocketOutlook.MessageInterception.MessageInterceptor(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"testapp"</span>);<br />
}<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">else</span><br />
{<br />
    mi <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> InTheHand.WindowsMobile.PocketOutlook.MessageInterception.MessageInterceptor(InTheHand.WindowsMobile.PocketOutlook.MessageInterception.InterceptionAction.NotifyAndDelete);<br />
    mi.MessageCondition <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> InTheHand.WindowsMobile.PocketOutlook.MessageInterception.MessageCondition(InTheHand.WindowsMobile.PocketOutlook.MessageInterception.MessageProperty.Body,
InTheHand.WindowsMobile.PocketOutlook.MessageInterception.MessagePropertyComparisonType.StartsWith, <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"test:"</span>, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">false</span>);<br /><br />
    mi.EnableApplicationLauncher(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"testapp"</span>,<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"\\Program
Files\\InterceptorTest\\InterceptorTest.exe"</span>);<br />
}<br /><br />
mi.MessageReceived += <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> InTheHand.WindowsMobile.PocketOutlook.MessageInterception.MessageInterceptorEventHandler(mi_MessageReceived);<br /></span>
        </p>
        <p>
Finally the event handler just displays the message body in a MessageBox:-
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> mi_MessageReceived(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span> sender,
InTheHand.WindowsMobile.PocketOutlook.MessageInterception.MessageInterceptorEventArgs
e)<br />
{<br />
    MessageBox.Show(((InTheHand.WindowsMobile.PocketOutlook.SmsMessage)e.Message).Body, <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Message"</span>);<br />
}</span>
        </p>
Download the skeleton project: <a href="http://www.peterfoot.net/content/binary/InterceptorTest.zip">InterceptorTest.zip
(11.08 KB)</a><img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=5ad38128-2e4c-4afd-9682-1d0b571a0e40" /></body>
      <title>Using MessageInterceptor to launch an application on SMS</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,5ad38128-2e4c-4afd-9682-1d0b571a0e40.aspx</guid>
      <link>http://peterfoot.net/UsingMessageInterceptorToLaunchAnApplicationOnSMS.aspx</link>
      <pubDate>Wed, 15 Nov 2006 16:13:46 GMT</pubDate>
      <description>&lt;p&gt;
First things first a disclaimer, the following code is written for Mobile In The Hand
(Professional Edition), it does apply equally to a Windows Mobile 5.0 project with
the Microsoft.WindowsMobile managed APIs, you'll just need to change the namespaces
and assembly references.
&lt;/p&gt;
&lt;p&gt;
A normal MessageInterceptor is valid only for the lifetime of your application, once
you shut down you'll no longer be able to respond to messages that match your rule.
In many cases you'll want a specific message to launch your application and then process
as normal. The IApplicationLauncher interface which MessageInterceptor implements
contains methods to set this up. This allows the system to start your application,
optionally with command line arguments of your choosing. This is useful so that you
can tell when your app was called by an incoming SMS and when launched manually. The
following code snippet&amp;nbsp;is called in Form_Load, it checks for an existing registration,
if not present it sets up all the required settings. The ApplicationLaunchId is a
string which is unique to your application, if you try to register with an id which
is already in use you'll receive an Exception.
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;if&lt;/span&gt; (InTheHand.WindowsMobile.PocketOutlook.MessageInterception.MessageInterceptor.IsApplicationLauncherEnabled(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"testapp"&lt;/span&gt;))&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; mi &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; InTheHand.WindowsMobile.PocketOutlook.MessageInterception.MessageInterceptor(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"testapp"&lt;/span&gt;);&lt;br&gt;
}&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;else&lt;/span&gt;
&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; mi &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; InTheHand.WindowsMobile.PocketOutlook.MessageInterception.MessageInterceptor(InTheHand.WindowsMobile.PocketOutlook.MessageInterception.InterceptionAction.NotifyAndDelete);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; mi.MessageCondition &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; InTheHand.WindowsMobile.PocketOutlook.MessageInterception.MessageCondition(InTheHand.WindowsMobile.PocketOutlook.MessageInterception.MessageProperty.Body,
InTheHand.WindowsMobile.PocketOutlook.MessageInterception.MessagePropertyComparisonType.StartsWith, &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"test:"&lt;/span&gt;, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;false&lt;/span&gt;);&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; mi.EnableApplicationLauncher(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"testapp"&lt;/span&gt;,&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"\\Program
Files\\InterceptorTest\\InterceptorTest.exe"&lt;/span&gt;);&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
mi.MessageReceived += &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; InTheHand.WindowsMobile.PocketOutlook.MessageInterception.MessageInterceptorEventHandler(mi_MessageReceived);&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
Finally the event handler just displays the message body in a MessageBox:-
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; mi_MessageReceived(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; sender,
InTheHand.WindowsMobile.PocketOutlook.MessageInterception.MessageInterceptorEventArgs
e)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; MessageBox.Show(((InTheHand.WindowsMobile.PocketOutlook.SmsMessage)e.Message).Body, &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Message"&lt;/span&gt;);&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
Download the skeleton project: &lt;a href="http://www.peterfoot.net/content/binary/InterceptorTest.zip"&gt;InterceptorTest.zip
(11.08 KB)&lt;/a&gt;&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=5ad38128-2e4c-4afd-9682-1d0b571a0e40" /&gt;</description>
      <category>NETCF</category>
      <category>Windows Mobile</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=0a54d2e7-86d1-41a9-a147-1c132f6ba204</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,0a54d2e7-86d1-41a9-a147-1c132f6ba204.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I recently ran into a problem with a Smart Device CAB Project in Visual Studio 2005,
which as it turns out is a known issue. You can build a CAB file which will register
your .NETCF dlls into the GAC - the File System Editor has a standard folder called
"Global Assembly Cache Folder" which you can put your files into. Behind the scenes
this deploys the dlls to the windows folder and generates a .GAC text file with a
list of paths to your dll(s). The problem is that the generated GAC file is a Unicode
text file and doesn't work on devices prior to Windows Mobile 5.0. I'm assuming the
same is true with generic CE 4.2 devices versus CE 5.0. In itself this seems bizarre
since CE is fully Unicode based so shouldn't have any problem reading the file. It
just so happens that when you are doing this the old fashioned way with notepad you
get an ANSI text file which works just fine on all devices.
</p>
        <p>
The workaround is simple, don't use the whizzy GAC support in the CAB project, place
your dlls into the Windows Folder, and manually create a .GAC text file and place
this in the Windows Folder also. The downside to this approach is that you must update
your GAC file if you add or remove dlls from your setup project. I'd like to say thanks
to fellow MVP <a href="http://janyeh.tw/blog">Jan Yeh</a> for helping to test the
issue and to Manish Vasani from the <a href="http://blogs.msdn.com/vsdteam/">Visual
Studio for Devices team</a> for following up with more details on the issue.
</p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=0a54d2e7-86d1-41a9-a147-1c132f6ba204" />
      </body>
      <title>Bug in GAC Installation from VS2005 Device CAB Projects</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,0a54d2e7-86d1-41a9-a147-1c132f6ba204.aspx</guid>
      <link>http://peterfoot.net/BugInGACInstallationFromVS2005DeviceCABProjects.aspx</link>
      <pubDate>Wed, 11 Oct 2006 16:23:01 GMT</pubDate>
      <description>&lt;p&gt;
I recently ran into a problem with a Smart Device CAB Project in Visual Studio 2005,
which as it turns out is a known issue. You can build a CAB file which will register
your .NETCF dlls into the GAC - the File System Editor has a standard folder called
"Global Assembly Cache Folder" which you can put your files into. Behind the scenes
this deploys the dlls to the windows folder and generates a .GAC text file with a
list of paths to your dll(s). The problem is that the generated GAC file is a Unicode
text file and doesn't work on devices prior to Windows Mobile 5.0. I'm assuming the
same is true with generic CE 4.2 devices versus CE 5.0. In itself this seems bizarre
since CE is fully Unicode based so shouldn't have any problem reading the file. It
just so happens that when you are doing this the old fashioned way with notepad you
get an ANSI text file which works just fine on all devices.
&lt;/p&gt;
&lt;p&gt;
The workaround is simple, don't use the whizzy GAC support in the CAB project, place
your dlls into the Windows Folder, and manually create a .GAC text file and place
this in the Windows Folder also. The downside to this approach is that you must update
your GAC file if you add or remove dlls from your setup project. I'd like to say thanks
to fellow MVP &lt;a href="http://janyeh.tw/blog"&gt;Jan Yeh&lt;/a&gt; for helping to test the
issue and to Manish Vasani from the &lt;a href="http://blogs.msdn.com/vsdteam/"&gt;Visual
Studio for Devices team&lt;/a&gt; for following up with more details on the issue.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=0a54d2e7-86d1-41a9-a147-1c132f6ba204" /&gt;</description>
      <category>NETCF</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=e583eb5b-b17d-474c-9b87-f8c3aaede369</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,e583eb5b-b17d-474c-9b87-f8c3aaede369.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you refer to the original Windows Mobile 5.0 documentation (or the Intellisense)
when using this component you'll notice it has a property called <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mobilesdk5/html/P_Microsoft_WindowsMobile_Forms_SelectPictureDialog_LockDirectory.asp">LockDirectory</a> which
is supposed to prevent the user from browsing outside of the folder you specified
in <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mobilesdk5/html/P_Microsoft_WindowsMobile_Forms_SelectPictureDialog_InitialDirectory.asp">InitialDirectory</a>.
To cut a long story short this property is not implemented and setting it will not
affect the behaviour of the dialog. The online MSDN documentation has since been updated
to indicate this.
</p>
        <p>
When faced with this problem my first thought was to look at the native API which
this component uses (<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mobilesdk5/html/mob5lrfGetOpenFileNameEx.asp">GetOpenFileNameEx</a>)
and P/Invoke it since the documentation still indicates that there is a flag to achieve
this behaviour. However as it turns out this too is unimplemented. It was a late change
in Windows Mobile 5.0 and hence the SDK and documentation were innacurate.
</p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=e583eb5b-b17d-474c-9b87-f8c3aaede369" />
      </body>
      <title>SelectPictureDialog.LockDirectory property</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,e583eb5b-b17d-474c-9b87-f8c3aaede369.aspx</guid>
      <link>http://peterfoot.net/SelectPictureDialogLockDirectoryProperty.aspx</link>
      <pubDate>Fri, 22 Sep 2006 10:28:31 GMT</pubDate>
      <description>&lt;p&gt;
If you refer to the original Windows Mobile 5.0 documentation (or the Intellisense)
when using this&amp;nbsp;component you'll notice it has a property called &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mobilesdk5/html/P_Microsoft_WindowsMobile_Forms_SelectPictureDialog_LockDirectory.asp"&gt;LockDirectory&lt;/a&gt; which
is supposed to prevent the user from browsing outside of the folder you specified
in &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mobilesdk5/html/P_Microsoft_WindowsMobile_Forms_SelectPictureDialog_InitialDirectory.asp"&gt;InitialDirectory&lt;/a&gt;.
To cut a long story short this property is not implemented and setting it will not
affect the behaviour of the dialog. The online MSDN documentation has since been updated
to indicate this.
&lt;/p&gt;
&lt;p&gt;
When faced with this problem my first thought was to look at the native API which
this component uses (&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mobilesdk5/html/mob5lrfGetOpenFileNameEx.asp"&gt;GetOpenFileNameEx&lt;/a&gt;)
and P/Invoke it since the documentation still indicates that there is a flag to achieve
this behaviour. However as it turns out this too is unimplemented. It was a late change
in Windows Mobile 5.0 and hence the SDK and documentation were innacurate.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=e583eb5b-b17d-474c-9b87-f8c3aaede369" /&gt;</description>
      <category>NETCF</category>
      <category>Windows Mobile</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=101fcad8-a30e-4080-ab5d-b6425bf8348f</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,101fcad8-a30e-4080-ab5d-b6425bf8348f.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Although it took a lot longer than I originally anticipated I've finally put the finishing
touches to v2.0 of the <a href="http://32feet.net/">32feet.NET</a> library. v2.0 is
a major re-write of the code so that the single codebase can be built into separate
dlls for desktop or device. This was primarily to get around the bug in the desktop
VB.NET compiler which couldn't cope with redirecting the device System.dll reference
to the desktop equivalent. It has had the pleasant side-effect of making the footprint
much smaller. The 4 previous dlls are now merged into the single InTheHand.Net.Personal.dll
which range from 91kb for the .NETCF v1.0 version to 76kb for the desktop v2.0 version.
</p>
        <p>
You can download the installer which includes the library, documentation and samples
from <a href="http://32feet.net/files/18/releases/entry1738.aspx">the 32feet website</a>.
This release is the first release version to have the full source code available since
the project was hosted <a href="http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=32feet&amp;ReleaseId=195">at
CodePlex</a>. You can also use the CodePlex site to download other builds of <a href="http://www.codeplex.com/SourceControl/ListDownloadableCommits.aspx?ProjectName=32feet">the
code</a> and post <a href="http://www.codeplex.com/WorkItem/List.aspx?ProjectName=32feet">bugs/feature
requests</a>. If you want to get involved in the project drop me a mail, or join the
discussions on the <a href="http://32feet.net/forums/default.aspx">32feet site</a>.
</p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=101fcad8-a30e-4080-ab5d-b6425bf8348f" />
      </body>
      <title>32feet.NET Reaches v2.0 Milestone</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,101fcad8-a30e-4080-ab5d-b6425bf8348f.aspx</guid>
      <link>http://peterfoot.net/32feetNETReachesV20Milestone.aspx</link>
      <pubDate>Mon, 28 Aug 2006 15:56:47 GMT</pubDate>
      <description>&lt;p&gt;
Although it took a lot longer than I originally anticipated I've finally put the finishing
touches to v2.0 of the &lt;a href="http://32feet.net/"&gt;32feet.NET&lt;/a&gt; library. v2.0 is
a major re-write of the code so that the single codebase can be built into separate
dlls for desktop or device. This was primarily to get around the bug in the desktop
VB.NET compiler which couldn't cope with redirecting the device System.dll reference
to the desktop equivalent. It has had the pleasant side-effect of making the footprint
much smaller. The 4 previous dlls are now merged into the single InTheHand.Net.Personal.dll
which range from 91kb for the .NETCF v1.0 version to 76kb for the desktop v2.0 version.
&lt;/p&gt;
&lt;p&gt;
You can download the installer which includes the library, documentation and samples
from &lt;a href="http://32feet.net/files/18/releases/entry1738.aspx"&gt;the 32feet website&lt;/a&gt;.
This release is the first release version to have the full source code available since
the project was hosted &lt;a href="http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=32feet&amp;amp;ReleaseId=195"&gt;at
CodePlex&lt;/a&gt;. You can also use the CodePlex site to download other builds of &lt;a href="http://www.codeplex.com/SourceControl/ListDownloadableCommits.aspx?ProjectName=32feet"&gt;the
code&lt;/a&gt; and post &lt;a href="http://www.codeplex.com/WorkItem/List.aspx?ProjectName=32feet"&gt;bugs/feature
requests&lt;/a&gt;. If you want to get involved in the project drop me a mail, or join the
discussions on the &lt;a href="http://32feet.net/forums/default.aspx"&gt;32feet site&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=101fcad8-a30e-4080-ab5d-b6425bf8348f" /&gt;</description>
      <category>Bluetooth</category>
      <category>NETCF</category>
    </item>
  </channel>
</rss>