<?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 - How To</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 - How To</title>
      <link>http://peterfoot.net/</link>
    </image>
    <copyright>Peter Foot</copyright>
    <lastBuildDate>Sat, 23 Feb 2008 16:29:11 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=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=ca832e77-f409-4533-86af-f95b64f1b617</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,ca832e77-f409-4533-86af-f95b64f1b617.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://inthehand.com/content/Mobile.aspx">Mobile In The Hand 3.0</a> has
just been released. This is the latest version of our .NET Compact Framework library
for working with all aspects of Windows Mobile. This latest version is optimised for
.NET Compact Framework 2.0 and 3.5 and introduces a number of new classes. One of
these is the <strong>WirelessManager</strong> which allows you to toggle the radio
mode of your Phone, WiFi and Bluetooth just like the built in Wireless Manager application.
I have prepared this sample to demonstrate how to use the class. It exposes a single
form with checkboxes for each of the radio types, toggling the checkbox changes the
radio mode for the specific device. You will need to have <a href="http://inthehand.com/content/Mobile.aspx">Mobile
In The Hand 3.0</a> installed to use this sample (The Evaluation Edition can be used).
The sample can be downloaded here:-
</p>
        <p>
          <a href="http://inthehand.com/files/folders/resources/entry4227.aspx">http://inthehand.com/files/folders/resources/entry4227.aspx</a>
        </p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=ca832e77-f409-4533-86af-f95b64f1b617" />
      </body>
      <title>WirelessManager sample</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,ca832e77-f409-4533-86af-f95b64f1b617.aspx</guid>
      <link>http://peterfoot.net/WirelessManagerSample.aspx</link>
      <pubDate>Tue, 13 Nov 2007 14:44:15 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://inthehand.com/content/Mobile.aspx"&gt;Mobile In The Hand 3.0&lt;/a&gt; has
just been released. This is the latest version of our .NET Compact Framework library
for working with all aspects of Windows Mobile. This latest version is optimised for
.NET Compact Framework 2.0 and 3.5 and introduces a number of new classes. One of
these is the &lt;strong&gt;WirelessManager&lt;/strong&gt; which allows you to toggle the radio
mode of your Phone, WiFi and Bluetooth just like the built in Wireless Manager application.
I have prepared this sample to demonstrate how to use the class. It exposes a single
form with checkboxes for each of the radio types, toggling the checkbox changes the
radio mode for the specific device. You will need to have &lt;a href="http://inthehand.com/content/Mobile.aspx"&gt;Mobile
In The Hand 3.0&lt;/a&gt; installed to use this sample (The Evaluation Edition can be used).
The sample can be downloaded here:-
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://inthehand.com/files/folders/resources/entry4227.aspx"&gt;http://inthehand.com/files/folders/resources/entry4227.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=ca832e77-f409-4533-86af-f95b64f1b617" /&gt;</description>
      <category>How To</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=5d6790fa-9c27-4685-8ebf-cc5fa48ace97</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,5d6790fa-9c27-4685-8ebf-cc5fa48ace97.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://inthehand.com/content/Networking.aspx">Networking In The Hand</a> introduces
a repository for all the various method types for FTP and HTTP operations. While the
common ones are easy to remember ("GET","POST" etc) many others are not, and so this
class (like its desktop equivalent) provides a central place to refer to them, without
dotting your code with hard-coded strings. WebRequestMethods contains two static classes
- Ftp and Http which as the name suggests contain the two sets of operations. Here
we find one used in the previous sample:-
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">InTheHand.Net.WebRequestMethods.Ftp.GetDateTimestamp</span>
        </p>
        <p>
As with all the functionality in the namespace, you'll find the full details
in the online <a href="http://inthehand.com/library/">documentation library</a>.
</p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=5d6790fa-9c27-4685-8ebf-cc5fa48ace97" />
      </body>
      <title>How To: Use the WebRequestMethods class</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,5d6790fa-9c27-4685-8ebf-cc5fa48ace97.aspx</guid>
      <link>http://peterfoot.net/HowToUseTheWebRequestMethodsClass.aspx</link>
      <pubDate>Tue, 09 Oct 2007 15:06:01 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://inthehand.com/content/Networking.aspx"&gt;Networking In The Hand&lt;/a&gt; introduces
a repository for all the various method types for FTP and HTTP operations. While the
common ones are easy to remember ("GET","POST" etc) many others are not, and so this
class (like its desktop equivalent) provides a central place to refer to them, without
dotting your code with hard-coded strings. WebRequestMethods contains two static classes
- Ftp and Http which as the name suggests contain the two sets of operations. Here
we find one used in the previous sample:-
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;InTheHand.Net.WebRequestMethods.Ftp.GetDateTimestamp&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
As with all the functionality in the namespace, you'll find the full&amp;nbsp;details
in the online &lt;a href="http://inthehand.com/library/"&gt;documentation library&lt;/a&gt;.
&lt;/p&gt;
&gt;&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=5d6790fa-9c27-4685-8ebf-cc5fa48ace97" /&gt;</description>
      <category>How To</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=ab41f447-3e85-4154-a812-bcb5acc2cf1f</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,ab41f447-3e85-4154-a812-bcb5acc2cf1f.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://inthehand.com/content/Networking.aspx">Networking In The Hand</a> includes
a full desktop-compatible implementation of the FtpWebRequest class. This plugs into
the WebRequest class so that calling WebRequest.Create() with an FTP Uri will create
an object of type FtpWebRequest. Because FTP support isn't built into the Compact
Framework you have to register the class with this prefix using the the following
code (only required once in your code):-
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">InTheHand.Net.FtpWebRequest.RegisterPrefix();</span>
        </p>
        <p>
We have already looked at performing simple operations with the WebClient class. for
more complex FTP operations you can use the FtpWebRequest directly. For example retrieving
the modification date of a specific file:-
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">FtpWebRequest
requestDate <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> (FtpWebRequest)FtpWebRequest.Create(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><font color="#000000">requestUri</font></span>);<br />
requestDate.Method <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> WebRequestMethods.Ftp.GetDateTimestamp;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">if</span> (wc.Credentials
!<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">null</span>)<br />
{<br />
   requestDate.Credentials <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> wc.Credentials;<br />
}<br />
FtpWebResponse responseDate <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">null</span>;<br /><br />
responseDate <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> (FtpWebResponse)requestDate.GetResponse();<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">if</span> (responseDate
!<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">null</span>)<br />
{<br />
   MessageBox.Show(responseDate.LastModified.ToString());<br />
   responseDate.Close();<br />
}</span>
        </p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=ab41f447-3e85-4154-a812-bcb5acc2cf1f" />
      </body>
      <title>How To: Use the FtpWebRequest</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,ab41f447-3e85-4154-a812-bcb5acc2cf1f.aspx</guid>
      <link>http://peterfoot.net/HowToUseTheFtpWebRequest.aspx</link>
      <pubDate>Thu, 04 Oct 2007 15:00:00 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://inthehand.com/content/Networking.aspx"&gt;Networking In The Hand&lt;/a&gt; includes
a full desktop-compatible implementation of the FtpWebRequest class. This plugs into
the WebRequest class so that calling WebRequest.Create() with an FTP Uri will create
an object of type FtpWebRequest. Because FTP support isn't built into the Compact
Framework you have to register the class with this prefix using the the following
code (only required once in your code):-
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;InTheHand.Net.FtpWebRequest.RegisterPrefix();&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
We have already looked at performing simple operations with the WebClient class. for
more complex FTP operations you can use the FtpWebRequest directly. For example retrieving
the modification date of a specific file:-
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;FtpWebRequest
requestDate &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; (FtpWebRequest)FtpWebRequest.Create(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font color=#000000&gt;requestUri&lt;/font&gt;&lt;/span&gt;);&lt;br&gt;
requestDate.Method &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; WebRequestMethods.Ftp.GetDateTimestamp;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;if&lt;/span&gt; (wc.Credentials
!&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;null&lt;/span&gt;)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp; requestDate.Credentials &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; wc.Credentials;&lt;br&gt;
}&lt;br&gt;
FtpWebResponse responseDate &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;null&lt;/span&gt;;&lt;br&gt;
&lt;br&gt;
responseDate &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; (FtpWebResponse)requestDate.GetResponse();&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; (responseDate
!&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;null&lt;/span&gt;)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp; MessageBox.Show(responseDate.LastModified.ToString());&lt;br&gt;
&amp;nbsp;&amp;nbsp; responseDate.Close();&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=ab41f447-3e85-4154-a812-bcb5acc2cf1f" /&gt;</description>
      <category>How To</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=02194550-9895-4412-8039-cff1c25351ce</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,02194550-9895-4412-8039-cff1c25351ce.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://inthehand.com/content/Networking.aspx">Networking In The Hand</a> includes
the WebClient class which is a helper class which makes it easier to do uploading
and downloading of data using HTTP and FTP transports. For example rather than creating
an HttpWebRequest, setting a number of properties, getting the response and reading
the response stream and copying the data into a file, why not use DownloadFile to
perform a single operation to write the data from a specific Uri to a local file:-
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">WebClient
wc <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> WebClient();<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">if</span> (saveFileDialog1.ShowDialog()
== DialogResult.OK)<br />
{ 
<br />
   wc.DownloadFile(uriTarget, saveFileDialog1.FileName);<br />
}</span>
        </p>
        <p>
Additional methods provide the ability to download a string, and download a byte array
containing the data. There are a similar set of operations for uploading:-
</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> (openFileDialog1.ShowDialog()
== DialogResult.OK)<br />
{<br />
   wc.UploadFile(uriDestination, openFileDialog1.FileName);<br />
}</span>
        </p>
        <p>
Not only does this work with the HTTP transport, but also with the FTP support which
is also part of the library - the only difference is the Uri that you pass in. If
your site requires a username/password you can set the Credentials property of the
WebClient once and they will be used for all subsequent operations.
</p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=02194550-9895-4412-8039-cff1c25351ce" />
      </body>
      <title>How To: Use the WebClient</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,02194550-9895-4412-8039-cff1c25351ce.aspx</guid>
      <link>http://peterfoot.net/HowToUseTheWebClient.aspx</link>
      <pubDate>Tue, 02 Oct 2007 14:49:06 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://inthehand.com/content/Networking.aspx"&gt;Networking In The Hand&lt;/a&gt; includes
the WebClient class which is a helper class which makes it easier to do uploading
and downloading of data using HTTP and FTP transports. For example rather than creating
an HttpWebRequest, setting a number of properties, getting the response and reading
the response stream and copying the data into a file, why not use DownloadFile to
perform a single operation to write the data from a specific Uri to a local file:-
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;WebClient
wc &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; WebClient();&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;if&lt;/span&gt; (saveFileDialog1.ShowDialog()
== DialogResult.OK)&lt;br&gt;
{ 
&lt;br&gt;
&amp;nbsp;&amp;nbsp; wc.DownloadFile(uriTarget, saveFileDialog1.FileName);&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
Additional methods provide the ability to download a string, and download a byte array
containing the data. There are a similar set of operations for uploading:-
&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; (openFileDialog1.ShowDialog()
== DialogResult.OK)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp; wc.UploadFile(uriDestination, openFileDialog1.FileName);&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
Not only does this work with the HTTP transport, but also with the FTP support which
is also part of the library - the only difference is the Uri that you pass in. If
your site requires a username/password you can set the Credentials property of the
WebClient once and they will be used for all subsequent operations.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=02194550-9895-4412-8039-cff1c25351ce" /&gt;</description>
      <category>How To</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=91e89cc6-79ce-4b9a-9530-0ede7f77d601</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,91e89cc6-79ce-4b9a-9530-0ede7f77d601.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <a href="http://inthehand.com/content/Networking.aspx">Networking
In The Hand</a> includes the Ping class (In the InTheHand.Net.NetworkInformation namespace).
The component allows you to determine if a network path to a particular host is available
and whether the host is responding. It doesn't guarantee that a particular service
is running on the server (HTTP, FTP etc). You can perform a Ping in a couple of lines
of code, the class has been designed to be an exact subset of the equivalent class
in the full .NET framework. The following is an example of the simplest ping request
using a default payload and timeout settings. 
<p><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">InTheHand.Net.NetworkInformation.Ping
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> InTheHand.Net.NetworkInformation.Ping();<br />
InTheHand.Net.NetworkInformation.PingReply reply <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> p.Send(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"www.google.com"</span>);<br /></span></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> (reply.Status
== IPStatus.Success)<br />
{<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
string</span> message <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">string</span>.Format(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Address:
{0}\r\nRoundTrip time: {1}\r\nTime to live: {2}\r\nDon't fragment: {3}\r\nBuffer size:
{0}",</span><br />
      reply.Address.ToString(),<br />
      reply.RoundtripTime,<br />
      reply.Options.Ttl,<br />
      reply.Options.DontFragment,<br />
      reply.Buffer.Length);<br /><br />
   MessageBox.Show(message, <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Ping"</span>);<br />
}<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">else</span><br />
{<br />
   MessageBox.Show(reply.Status.ToString(), <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Ping"</span>);<br />
}</span></p><p>
The class allows you to further customise the request. You can specify your own data
payload for example, or set a different timeout value (the default is 5 seconds).
</p><img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=91e89cc6-79ce-4b9a-9530-0ede7f77d601" /></body>
      <title>How To: Use the Ping class</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,91e89cc6-79ce-4b9a-9530-0ede7f77d601.aspx</guid>
      <link>http://peterfoot.net/HowToUseThePingClass.aspx</link>
      <pubDate>Mon, 01 Oct 2007 14:40:28 GMT</pubDate>
      <description>&lt;a href="http://inthehand.com/content/Networking.aspx"&gt;Networking In The Hand&lt;/a&gt; includes
the Ping class (In the InTheHand.Net.NetworkInformation namespace). The component
allows you to determine if a network path to a particular host is available and&amp;nbsp;whether
the host is responding. It doesn't guarantee that a particular service is running
on the server (HTTP, FTP etc). You can perform a Ping in a couple of lines of code,
the class has been designed to be an exact subset of the equivalent class in the full
.NET framework. The following is an example of the simplest ping request using a default
payload and timeout settings. 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;InTheHand.Net.NetworkInformation.Ping
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; InTheHand.Net.NetworkInformation.Ping();&lt;br&gt;
InTheHand.Net.NetworkInformation.PingReply&amp;nbsp;reply &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; p.Send(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"www.google.com"&lt;/span&gt;);&lt;br&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 style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;if&lt;/span&gt; (reply.Status
== IPStatus.Success)&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;
string&lt;/span&gt; message &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;string&lt;/span&gt;.Format(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Address:
{0}\r\nRoundTrip time: {1}\r\nTime to live: {2}\r\nDon't fragment: {3}\r\nBuffer size:
{0}",&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; reply.Address.ToString(),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; reply.RoundtripTime,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; reply.Options.Ttl,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; reply.Options.DontFragment,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; reply.Buffer.Length);&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; MessageBox.Show(message, &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Ping"&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; MessageBox.Show(reply.Status.ToString(), &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Ping"&lt;/span&gt;);&lt;br&gt;
}&lt;/span&gt;&gt;
&lt;/p&gt;
&lt;p&gt;
The class allows you to further customise the request. You can specify your own data
payload for example, or set a different timeout value (the default is 5 seconds).
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=91e89cc6-79ce-4b9a-9530-0ede7f77d601" /&gt;</description>
      <category>How To</category>
    </item>
    <item>
      <trackback:ping>http://peterfoot.net/Trackback.aspx?guid=a3d7d3b6-e1b4-4258-b383-81d3f18ed5fa</trackback:ping>
      <pingback:server>http://peterfoot.net/pingback.aspx</pingback:server>
      <pingback:target>http://peterfoot.net/PermaLink,guid,a3d7d3b6-e1b4-4258-b383-81d3f18ed5fa.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://inthehand.com/content/Networking.aspx">Networking In The Hand</a> 2.0
offers a new dialog which allows you to prompt the user for networking credentials.
The dialog is designed for the best appearance depending on your platform, for example
the screenshots below show both Windows Mobile 5.0 Pocket PC and Windows Mobile 6
Standard Landscape:-
</p>
        <p>
 
</p>
        <p>
          <img src="http://peterfoot.net/content/binary/AuthenticationDialogProfessional.png" border="0" />   <img src="http://peterfoot.net/content/binary/AuthenticationDialogStandard.png" border="0" /></p>
        <p>
If your application stores authentication details you can pre-populate the dialog.
Optionally you can display a Save Settings checkbox on the form. The following code
snippet shows how to display the dialog and return the credentials as an ICredentials
object:-
</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> ICredentials
GetCredentials(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span> resourceName)<br />
{<br />
   InTheHand.Windows.Forms.AuthenticationDialog ad <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.Windows.Forms.AuthenticationDialog();</span>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   ad.ResourceName <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> resourceName;</span>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <br />
   <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">if</span>(ad.ShowDialog()
== DialogResult.OK)<br />
   {<br />
        <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">return</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> NetworkCredential(ad.Username,
ad.Password, ad.Domain);<br />
   }<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   else</span><br />
   {<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">      return</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">null</span>;<br />
   }</span>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">}</span>
        </p>
        <img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=a3d7d3b6-e1b4-4258-b383-81d3f18ed5fa" />
      </body>
      <title>How To: Use the AuthenticationDialog</title>
      <guid isPermaLink="false">http://peterfoot.net/PermaLink,guid,a3d7d3b6-e1b4-4258-b383-81d3f18ed5fa.aspx</guid>
      <link>http://peterfoot.net/HowToUseTheAuthenticationDialog.aspx</link>
      <pubDate>Fri, 28 Sep 2007 14:28:16 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://inthehand.com/content/Networking.aspx"&gt;Networking In The Hand&lt;/a&gt; 2.0
offers a new dialog which allows you to prompt the user for networking credentials.
The dialog is designed for the best appearance depending on your platform, for example
the screenshots below show both Windows Mobile 5.0 Pocket PC and Windows Mobile 6
Standard Landscape:-
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://peterfoot.net/content/binary/AuthenticationDialogProfessional.png" border=0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;img src="http://peterfoot.net/content/binary/AuthenticationDialogStandard.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
If your application stores authentication details you can pre-populate the dialog.
Optionally you can display a Save Settings checkbox on the form. The following code
snippet shows how to display the dialog and return the credentials as an ICredentials
object:-
&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; ICredentials
GetCredentials(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; resourceName)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;InTheHand.Windows.Forms.AuthenticationDialog ad &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.Windows.Forms.AuthenticationDialog();&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;ad.ResourceName &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; resourceName;&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;if&lt;/span&gt;(ad.ShowDialog()
== DialogResult.OK)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;return&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; NetworkCredential(ad.Username,
ad.Password, ad.Domain);&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;
&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;&amp;nbsp;return&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;null&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&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;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://peterfoot.net/aggbug.ashx?id=a3d7d3b6-e1b4-4258-b383-81d3f18ed5fa" /&gt;</description>
      <category>How To</category>
    </item>
  </channel>
</rss>