<?xml version="1.0" encoding="utf-8"?><!-- generator="wordpress/1.5.1.3" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Drawing a selection rubber band like Explorer - improved</title>
	<link>http://www.sturmnet.org/blog/archives/2005/08/26/explorer-rubber-band2/</link>
	<description>General musings and programming stuff</description>
	<pubDate>Sat, 22 Nov 2008 11:53:15 +0000</pubDate>
	<generator>http://wordpress.org/?v=1.5.1.3</generator>

	<item>
		<title>by: Oliver Sturm</title>
		<link>http://www.sturmnet.org/blog/archives/2005/08/26/explorer-rubber-band2/#comment-81419</link>
		<pubDate>Mon, 12 Mar 2007 11:10:02 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2005/08/26/explorer-rubber-band2/#comment-81419</guid>
					<description>Hey Garf - well, this is not a control, it's just a sample to show you how it can be done. It's also rather generic - it doesn't assume what you're going to do with it. If your own application is something like Windows Explorer, then sure, selection like Explorer makes sense to you. For others it wouldn't...
That said, it's really rather easy to do. You just have to have a list of rects for the elements you want to make selectable, and every time the selection rect changes, you check for overlaps between any of the selectable rects in your list and the actual selection rect. 
If I ever find the time, I might have a shot at this... but I remember there were still other ideas I was planning to follow up on, so this may not be highest on my priority list. Plus, if I ever have time...</description>
		<content:encoded><![CDATA[	<p>Hey Garf - well, this is not a control, it&#8217;s just a sample to show you how it can be done. It&#8217;s also rather generic - it doesn&#8217;t assume what you&#8217;re going to do with it. If your own application is something like Windows Explorer, then sure, selection like Explorer makes sense to you. For others it wouldn&#8217;t&#8230;<br />
That said, it&#8217;s really rather easy to do. You just have to have a list of rects for the elements you want to make selectable, and every time the selection rect changes, you check for overlaps between any of the selectable rects in your list and the actual selection rect.<br />
If I ever find the time, I might have a shot at this&#8230; but I remember there were still other ideas I was planning to follow up on, so this may not be highest on my priority list. Plus, if I ever have time&#8230;
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Garf</title>
		<link>http://www.sturmnet.org/blog/archives/2005/08/26/explorer-rubber-band2/#comment-81417</link>
		<pubDate>Mon, 12 Mar 2007 10:54:00 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2005/08/26/explorer-rubber-band2/#comment-81417</guid>
					<description>Nice code. However, windows explorer updates the selected items while the user is selecting them. It would be nice if you could implement that in this control</description>
		<content:encoded><![CDATA[	<p>Nice code. However, windows explorer updates the selected items while the user is selecting them. It would be nice if you could implement that in this control
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Oliver Sturm</title>
		<link>http://www.sturmnet.org/blog/archives/2005/08/26/explorer-rubber-band2/#comment-2713</link>
		<pubDate>Sat, 27 Aug 2005 12:27:10 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2005/08/26/explorer-rubber-band2/#comment-2713</guid>
					<description>You are right, but that's easy to work around. Just put the following code in the form class and call the DotNet1DrawToBitmap method instead of the &quot;normal&quot; DrawToBitmap. You don't need the targetRect in that case.

&lt;pre language=&quot;c#&quot;&gt;
  [DllImport(&amp;#34;user32.dll&amp;#34;)]
  static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, DrawingOptions drawingOptions);
  const int WM_PRINT = 0x317;

  [Flags]
  enum DrawingOptions {
    PRF_CHECKVISIBLE = 0x01,
    PRF_NONCLIENT = 0x02,
    PRF_CLIENT = 0x04,
    PRF_ERASEBKGND = 0x08,
    PRF_CHILDREN = 0x10,
    PRF_OWNED = 0x20
  }

  void DotNet1DrawToBitmap(Bitmap bitmap) {
    using (Graphics gr = Graphics.FromImage(bitmap)) {
      IntPtr hdc = gr.GetHdc( );
      SendMessage(Handle, WM_PRINT, hdc, DrawingOptions.PRF_CHILDREN &amp;#166; DrawingOptions.PRF_ERASEBKGND &amp;#166;
        DrawingOptions.PRF_CLIENT &amp;#166; DrawingOptions.PRF_NONCLIENT);
      gr.ReleaseHdc(hdc);
    }
  }
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[	<p>You are right, but that&#8217;s easy to work around. Just put the following code in the form class and call the DotNet1DrawToBitmap method instead of the &#8220;normal&#8221; DrawToBitmap. You don&#8217;t need the targetRect in that case.</p>
	<pre language="c#">
  [DllImport(&quot;user32.dll&quot;)]
  static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, DrawingOptions drawingOptions);
  const int WM_PRINT = 0x317;
	
  [Flags]
  enum DrawingOptions {
    PRF_CHECKVISIBLE = 0x01,
    PRF_NONCLIENT = 0x02,
    PRF_CLIENT = 0x04,
    PRF_ERASEBKGND = 0x08,
    PRF_CHILDREN = 0x10,
    PRF_OWNED = 0x20
  }
	
  void DotNet1DrawToBitmap(Bitmap bitmap) {
    using (Graphics gr = Graphics.FromImage(bitmap)) {
      IntPtr hdc = gr.GetHdc( );
      SendMessage(Handle, WM_PRINT, hdc, DrawingOptions.PRF_CHILDREN | DrawingOptions.PRF_ERASEBKGND |
        DrawingOptions.PRF_CLIENT | DrawingOptions.PRF_NONCLIENT);
      gr.ReleaseHdc(hdc);
    }
  }
</pre>
]]></content:encoded>
				</item>
	<item>
		<title>by: Larry</title>
		<link>http://www.sturmnet.org/blog/archives/2005/08/26/explorer-rubber-band2/#comment-2711</link>
		<pubDate>Fri, 26 Aug 2005 20:49:18 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2005/08/26/explorer-rubber-band2/#comment-2711</guid>
					<description>The DrawToBitmap method is unavailable before .NET V2. :-(</description>
		<content:encoded><![CDATA[	<p>The DrawToBitmap method is unavailable before .NET V2. <img src='http://www.sturmnet.org/blog/wp-images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' />
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
