tag:blogger.com,1999:blog-53772339364863883972024-03-13T10:13:45.700-07:00jeffdav on codePractical coding tips, tricks, advice and anecdotes. Including, but not limited to: C++, C#, JavaScript, COM, OLE, Internet Explorer, Win32 and what-not.jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.comBlogger34125tag:blogger.com,1999:blog-5377233936486388397.post-46122029844082007652010-07-15T17:51:00.000-07:002010-07-15T17:51:10.970-07:00Worst Microsoft DialogsSo, I thought this dialog was pretty bad:<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxZZiRWT0KDNlo0V9AVwKZQuS4ev4U267sfo9T3Dqh5umnsxcMcsYS8tkBYHVyhTR1DvUkEUFqtuUTfcjWyJmb3fssOxCZHQnFzlBMgPeb4y-EIMhr3JhFhYPxi0Mjmg9pgSJOTHe_dIc/s1600/visual-studio-worst-dialog-ever.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxZZiRWT0KDNlo0V9AVwKZQuS4ev4U267sfo9T3Dqh5umnsxcMcsYS8tkBYHVyhTR1DvUkEUFqtuUTfcjWyJmb3fssOxCZHQnFzlBMgPeb4y-EIMhr3JhFhYPxi0Mjmg9pgSJOTHe_dIc/s320/visual-studio-worst-dialog-ever.png" /></a></div><br />
I mean, the only question in all that text (you know, the sentence that ends in a <i>question mark</i>) is not a yes/no question. The actual question is down at the bottom and ends in a nonsensical colon. And it has not one, but <i>two</i> parenthetical phrases. And it contains a really long, unwieldy URL that isn't clickable or copyable.<br />
<br />
But then I got this gem from Windows Live Mail (in Windows 7) today:<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgY68BRDSsTAjp9EfI9_r0fYcLVw8iKv8MCN-cqA8OGnV0gLx9R3J2uadwDtLHytWLjnBR8M8qq1qCbLuyh7__EJiAMHrp9IkjTsDcn2pQ1k_2D5Fr5sk4FHNn1WFzK8OYIAsNkCvufDqY/s1600/windows-live-mail-stupid-dialog.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgY68BRDSsTAjp9EfI9_r0fYcLVw8iKv8MCN-cqA8OGnV0gLx9R3J2uadwDtLHytWLjnBR8M8qq1qCbLuyh7__EJiAMHrp9IkjTsDcn2pQ1k_2D5Fr5sk4FHNn1WFzK8OYIAsNkCvufDqY/s320/windows-live-mail-stupid-dialog.png" /></a></div><br />
First of all, I had pressed ALT+F4 to close WLM having completed my business with it. Opening a modal dialog for something only tangentially related to exiting the app is a little intrusive, but, okay. The thing that's really bad about this is that it tells me what <i>won't</i> happen if I click yes, but I still have no idea what <i>will</i> happen if I click yes. But I only use WLM to read mail that comes to my passport account from Microsoft lists, so if it all gets deleted I don't really care. So I'm feeling adventurous and click yes. Then I get this:<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjASkXQ5B2wZxMt52TJLarlK2YtIDa1klLmYnf8bVS0iCVktc8Lvr4A_E_lpEB1-0hB-Sa-WnHeLWHsK1Sw-ADh1Y6FJjCal88mqQ2wPyU-fTTu4RuEATl9GukAI4pK0VcABTFsP1ydvG0/s1600/windows-live-mail-stupid-dialog-2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjASkXQ5B2wZxMt52TJLarlK2YtIDa1klLmYnf8bVS0iCVktc8Lvr4A_E_lpEB1-0hB-Sa-WnHeLWHsK1Sw-ADh1Y6FJjCal88mqQ2wPyU-fTTu4RuEATl9GukAI4pK0VcABTFsP1ydvG0/s320/windows-live-mail-stupid-dialog-2.png" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: left;">Really? You didn't see that one coming WLM?</div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;">Sigh. The fight goes on.</div>jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.com1tag:blogger.com,1999:blog-5377233936486388397.post-47260982554649956832010-03-24T09:58:00.000-07:002010-03-24T09:58:59.407-07:00Perforce has the best error messages.I wanted to know what the path to something was on the server, but I couldn't remember. Little did I know that perforce would be so judgemental:<br />
<br />
<blockquote>c:\source>p4 dirs *<br />
//depot/foo/bar/baz<br />
//depot/foo/bar/qux<br />
Client map too twisted for directory list.</blockquote><br />
And then there was the time I made a perfectly reasonable request, I wanted to edit all the unittest files in the entire tree, and it had to go and get all preachy:<br />
<br />
<blockquote>c:\source\v2-dev>p4 edit foo\...*unittest.cc<br />
Senseless juxtaposition of wildcards in '//jeff-src/foo/...*unittest.cc'.</blockquote><br />
I mean, yeah, maybe there's a typo there, but you don't have to insult me.jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.com2tag:blogger.com,1999:blog-5377233936486388397.post-59511671058590142092010-03-17T08:20:00.000-07:002010-03-17T08:26:01.438-07:00GetModuleFileName() on OS X.So, you want to know the path to your module. On Windows, it's easy: you call <a href="http://msdn.microsoft.com/en-us/library/ms683197(VS.85).aspx">GetModuleFileName()</a> and pass NULL for the HMODULE.<br />
<br />
But what if you're trying to do it on OS X? <br />
<br />
<pre>#include <dlfcn.h>
std::string GetModuleFileNameOSX() {
Dl_info module_info;
if (dladdr(reinterpret_cast<void*>(GetModuleFileNameOSX), &module_info) == 0) {
// Failed to find the symbol we asked for.
return std::string();
}
return std::string(module_info.dli_fname);
}
</pre><br />
For the first param to dladdr, you can pass any symbol you know will be in your module. In theory, something similar should work on linux, but I haven't tried.jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.com0tag:blogger.com,1999:blog-5377233936486388397.post-10979671563785859522009-11-10T10:05:00.000-08:002009-11-10T10:09:18.418-08:00Adventures in Diffing...So <a href="http://www.schneier.com/blog/archives/2009/11/is_antivirus_de.html">today Schneier recommended AVG</a> as a useful, free anti-virus solution. As I'm terribly anti-virus, I wanted to see if really ran "...in the background, automatically, and you won't notice any performance degradation at all." So I installed it. My first step was going to be comparing the registry before and after the install to see what sorts of things it was installing. This is where my experiment took a left turn: I just wanted to view the diff.<br />
<br />
<blockquote>c:\Users\jeff\Desktop>dir *.reg<br />
Volume in drive C has no label.<br />
Volume Serial Number is 96A6-6911<br />
<br />
Directory of c:\Users\jeff\Desktop<br />
<br />
11/10/2009 09:18 AM 487,799,220 registry-after-install.reg<br />
11/10/2009 08:53 AM 487,588,198 registry-before.reg<br />
2 File(s) 975,387,418 bytes<br />
0 Dir(s) 220,934,803,456 bytes free<br />
</blockquote><br />
Turns out the registry is frickin' huge! Whatever AVG did, it added about 211k of goop to the registry.<br />
<br />
My first attempt was to use my favorite diff tool, windiff.exe. Windiff has been my trusted companion ever since I joined MSFT back in 2001. Today, for the first time, it let me down. After churning on the files for about two minutes it ran out of memory.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtfpwWB_YTBfMLVPMiohf2aN5lbFjlx7_MDVREd-g3ydxv43R-lYZ8BvqGlUoOhON9hI_vqSbZAQeWi7baXOUPERfTlp7CeQEOLc5PdK2lYFjBVCDAzPyv2cGYf_01QsY54XD8QMZzjgk/s1600-h/windiff-oom-fail.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtfpwWB_YTBfMLVPMiohf2aN5lbFjlx7_MDVREd-g3ydxv43R-lYZ8BvqGlUoOhON9hI_vqSbZAQeWi7baXOUPERfTlp7CeQEOLc5PdK2lYFjBVCDAzPyv2cGYf_01QsY54XD8QMZzjgk/s640/windiff-oom-fail.jpg" /></a><br />
</div><br />
Very sad. So, next we tried gnu diff from the command line. Gnu diff allocated some memory, then allocated some more, and, in a manner much quicker than windiff, proceeded to give me garbage output because it doesn't believe in unicode.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0Zqpd71sw_RtIC7sGebgWEkX2cBCxzuu-lAuspWP1pXVHOw4xZU6HmGgbwlijT1gIzb6lGRdNdHwogTxmNgNekPwoL7HMWTz-afiWf0hx0CVXCVy_U4fibhjQIYvfMn87PCzgQ2jNmC8/s1600-h/winmerge-like-windiff-but-faster.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0Zqpd71sw_RtIC7sGebgWEkX2cBCxzuu-lAuspWP1pXVHOw4xZU6HmGgbwlijT1gIzb6lGRdNdHwogTxmNgNekPwoL7HMWTz-afiWf0hx0CVXCVy_U4fibhjQIYvfMn87PCzgQ2jNmC8/s640/winmerge-like-windiff-but-faster.jpg" /></a><br />
</div><br />
I also tried P4Merge, but it knew its limitations.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1_W7OXMCt3KqNtvBIfyfVBpLYSf7cc1jZOQvWk_EnTiz49jG0vI_MKTGN_VB4xI4wm4PWF63d6vhyBlvQCXqVEF1QZRjhkHwFQtUd83Es9ciZefd-41lWppC9XDwsY4wy15dLA1jFxAA/s1600-h/p4-merge-says-youre-fucking-kidding-right-cropped.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1_W7OXMCt3KqNtvBIfyfVBpLYSf7cc1jZOQvWk_EnTiz49jG0vI_MKTGN_VB4xI4wm4PWF63d6vhyBlvQCXqVEF1QZRjhkHwFQtUd83Es9ciZefd-41lWppC9XDwsY4wy15dLA1jFxAA/s640/p4-merge-says-youre-fucking-kidding-right-cropped.jpg" /></a><br />
</div><br />
In a last-ditch effort to get the info I wanted, I turned to the Mac. FileMerge on OS X 10.5 (so, the 32bit version) failed as well. It churned for awhile, the crashed with no clear reason, but I suspect it was out of memory.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvBTm4yJ5Vq9066qxIJhxvDEgCvJQHoNySYK0tZxl5Pih2Yb9fq59hDn9MoGSfOV5GP5sabVmwXNX6M_EhvOF6jcd6Cl5QRVL6eSbt-DzFTEsqrOHRL3qpP1SPS9rv-PMvU9o9friTG_I/s1600-h/Picture+4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvBTm4yJ5Vq9066qxIJhxvDEgCvJQHoNySYK0tZxl5Pih2Yb9fq59hDn9MoGSfOV5GP5sabVmwXNX6M_EhvOF6jcd6Cl5QRVL6eSbt-DzFTEsqrOHRL3qpP1SPS9rv-PMvU9o9friTG_I/s640/Picture+4.png" /></a><br />
</div><br />
So, my little experiment failed. What did we learn from all this? The Windows Registry is too large, I think. Or, just trust Bruce.jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.com1tag:blogger.com,1999:blog-5377233936486388397.post-66547184776983288932009-11-10T09:19:00.000-08:002009-11-10T09:19:02.660-08:00Things I Hope Are Fixed In The Next VersionExporting from the registry to disk happens on the UI thread. I hope this is fixed in regedit in Windows 7.<br />
<br />
Loading symbols (from disk or the public symbol server) happens on the UI thread. I hope this is fixed in Visual Studio 2010.<br />
<br />
I'm holding my breath.jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.com0tag:blogger.com,1999:blog-5377233936486388397.post-26108105273568505082009-07-16T14:51:00.000-07:002009-07-16T15:00:07.782-07:00a trip to the Microsoft company store...I was recently in Redmond and one of my good MSFT friends was kind enough to take me to the company store to pick up a copy of VS2008 and Vista. As we strolled through the lobby, we saw this:<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjX6gGjBjrpxagSwS0IUfmDiA-UjWkQx3isJ548VEai1rMmJk8jz9IW7fiQLUMDFc5vWXqfVuOGiWIR4LlXBG2HF9ppj5TRKGX5fR2TIajux9Uj5oCqwYeNrIukGyzuTu_X2Yd5cO18P9g/s1600-h/gigantic+iphone+import+2378.JPG"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 240px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjX6gGjBjrpxagSwS0IUfmDiA-UjWkQx3isJ548VEai1rMmJk8jz9IW7fiQLUMDFc5vWXqfVuOGiWIR4LlXBG2HF9ppj5TRKGX5fR2TIajux9Uj5oCqwYeNrIukGyzuTu_X2Yd5cO18P9g/s320/gigantic+iphone+import+2378.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5359179791265767522" /></a><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgG-2t1zZrnwv3iZmks4-CZw1xUhqRXvTjJXaqH1AVETqOomHt3Knv9a7tVB96iuN9eb3wCZlTkxtStCF1uwTbNRztHX2CF8fFrEvuo6h88oSnrVsdvttvGtL5LfxOrS9HdNbUe85n496c/s1600-h/gigantic+iphone+import+2379.JPG"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 240px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgG-2t1zZrnwv3iZmks4-CZw1xUhqRXvTjJXaqH1AVETqOomHt3Knv9a7tVB96iuN9eb3wCZlTkxtStCF1uwTbNRztHX2CF8fFrEvuo6h88oSnrVsdvttvGtL5LfxOrS9HdNbUe85n496c/s320/gigantic+iphone+import+2379.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5359179797741709794" /></a><br /><br />And later on, inside the store proper, we saw this:<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhacb8PHGDqqN7v5HlUwwzSYyCVL6O-5-Ov0yQ_Wij_gxlwjqEUxERjpveG1K24VAdxg56f4O7BcMa7LxOHn7wsMae31vxOmSH6sf2znNsKSGq3VgRZ-e-bcL4HtZpcIjh-Nrsl-df9nuA/s1600-h/gigantic+iphone+import+2381.JPG"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 240px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhacb8PHGDqqN7v5HlUwwzSYyCVL6O-5-Ov0yQ_Wij_gxlwjqEUxERjpveG1K24VAdxg56f4O7BcMa7LxOHn7wsMae31vxOmSH6sf2znNsKSGq3VgRZ-e-bcL4HtZpcIjh-Nrsl-df9nuA/s320/gigantic+iphone+import+2381.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5359179799007776578" /></a><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqHGmMA8d-frroeZZa_HMe8i7p8bvurQc7r8UTL_VHjEtdXuePnmsLgDvu074EZvoE-b0TFu0AF9zhzlISqz-k4Uu1BLrbPy7UyJTc2a3dhZdp8YAUmST40_7xPBpf44qJVkvVwzjol_k/s1600-h/gigantic+iphone+import+2380.JPG"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 240px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqHGmMA8d-frroeZZa_HMe8i7p8bvurQc7r8UTL_VHjEtdXuePnmsLgDvu074EZvoE-b0TFu0AF9zhzlISqz-k4Uu1BLrbPy7UyJTc2a3dhZdp8YAUmST40_7xPBpf44qJVkvVwzjol_k/s320/gigantic+iphone+import+2380.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5359179805824952962" /></a><br /><br />My friend, who is a PM for User Experience related things in the Windows team just sighed and said, "why does it gotta be this way?" And I laughed.<br /><br />But it is easy to make fun of Microsoft for failing in their own technology showcase, but I've learned two things:<br /><br />1) All software is pretty terrible when you get down to it.<br />2) Programming is hard.<br /><br />Both machines are using Windows in a way that was not the primary concern of anyone who was working on Windows Vista. Developers tend to focus on the use cases they expect--users at home, users at work. But as computers become more general purpose, we have to start thinking through a bunch of other scenarios as well. Heck, I bet someone even knows how to configure these machines to prevent these things from happening, but I couldn't tell you how to do it.jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.com0tag:blogger.com,1999:blog-5377233936486388397.post-26792271025964231092009-06-10T09:27:00.000-07:002009-06-10T09:29:37.282-07:00Adventures in Driver UpdatesI love that Windows Update brings me the latest drivers for my video card. It's too bad that hardware OEMs still can't figure out how to write installers. The engrish is amusing as well:<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKOLm7Z51Z0TjF-M6aiyiusluiOhNNsfU8mUqmnUuQuqu1V9hnvrZiN7p_eC9OvCPnBs8pnxdMmBVpm7_xn7cdMrUOHjFo21omUhht7aRidKfXG4Sr5ax00g9fHisA_45c4vZB-OVb3_o/s1600-h/EXIT-IS-THE-ONLY-OPTION.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 170px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKOLm7Z51Z0TjF-M6aiyiusluiOhNNsfU8mUqmnUuQuqu1V9hnvrZiN7p_eC9OvCPnBs8pnxdMmBVpm7_xn7cdMrUOHjFo21omUhht7aRidKfXG4Sr5ax00g9fHisA_45c4vZB-OVb3_o/s320/EXIT-IS-THE-ONLY-OPTION.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5345736821343696658" /></a><br /><br />At least Windows Update thinks it succeeded.jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.com0tag:blogger.com,1999:blog-5377233936486388397.post-37336914789849864112009-01-30T19:05:00.000-08:002009-01-30T19:06:19.831-08:00Browser Market Share<img src="http://spreadsheets.google.com/pub?key=p_1nmISrQ8m_6ZbxcS3IfFQ&oid=4&output=image" /><br /><br />I made this chart today. It's revealing.jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.com1tag:blogger.com,1999:blog-5377233936486388397.post-17323065559023106652009-01-21T16:26:00.000-08:002009-01-21T16:27:39.708-08:00else while?Everyone accepts the "else if" construct in C++, but nobody likes it when I try to do "else while". I wonder why.jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.com0tag:blogger.com,1999:blog-5377233936486388397.post-2429875030599123622009-01-09T21:24:00.000-08:002009-01-09T21:25:42.404-08:00We won!Hey, looks like we won the Best Design Crunchie. If you voted for us, thanks!jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.com0tag:blogger.com,1999:blog-5377233936486388397.post-82069945142150621412008-12-29T19:17:00.000-08:002008-12-29T19:21:42.766-08:00Cooliris nominated for 2008 CrunchieMy company (and product) has been nominated for a Crunchie in the "Best Design" category. I'm not surprised, since the product was cool enough to make me want to work there. However, it is nice to get recognition and positive feedback that other people feel the same way I do about it. <br /><br />Anyway, if you like Cooliris and want to vote, you can vote for us here:<br /><br /><a href="http://crunchies2008.techcrunch.com/votes/">http://crunchies2008.techcrunch.com/votes/</a><br /><br />And if you haven't tried Cooliris yet, please <a href="http://www.cooliris.com">give it a whirl</a>.jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.com0tag:blogger.com,1999:blog-5377233936486388397.post-73570288365153476952008-10-05T12:43:00.000-07:002008-10-05T12:57:57.041-07:00Cooliris 1.8.3 Released!<span style="font-weight:bold;">Cooliris 1.8.3</span><br /><br />Last week we released 1.8.3 of Cooliris (formerly known as PicLens). You can <a href="http://www.cooliris.com/">download it here</a>. In addition to Firefox 2 and 3 (Mac and Windows) we now support Safari 3 (Mac) and Internet Explorer 8 Beta 2 (Windows), though our IE8 Beta support is itself in Beta. In addition, we have lots of new features. 1.8.3 is one of the biggest releases we've had since we first debuted the 3D view.<br /><br /><span style="font-weight:bold;">More Shopping</span><br /><br />A while ago we introduced support for searching Amazon in Cooliris. With 1.8.3 we now support ten different retailers such as eLuxury, Nordstrom, beauty.com, Macy's, Wal-mart and more, with more stores to be added. (Geeky aside: the client makes a request to our servers for some XML that describes all the stores that we support so we can add more stores without having to publish a new client.) In addition to more stores, we also now have improved UI for browsing the stores and sorting the results by price, popularity, etc. <br /><br /><span style="font-weight:bold;">Flash Support</span><br /><br />In addition to various improvements we made to our A\V playback code (A\V sync issues, as well as better buffering logic for slow connections), this release debuts the project I've been hard at work on the last few months: Flash support. We now host the Flash plugin and can render SWF content directly in the wall. The upside for the user is they get the full YouTube player experience when browsing YouTube video, and we will be adding more and more interactive content over time. Right now we only support the Netscape Plugin version of Flash (NPSWF32.dll). So if you've installed Flash for Firefox or other Netscape derivatives, you'll get Flash support. If you only have the IE Active X plugin (flash9f.ocx, or related) you'll need to install the correct version which can be <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&P2_Platform=Win32&P3_Browser=Netscape)">downloaded here</a>.<br /><br />There are lots of other improvements, fixes, optimizations, etc, such as better Keyboard Input support, but I can't remember all of them right now. I suggest you download the latest <a href="http://www.cooliris.com">Cooliris</a> and explore it for yourself.jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.com1tag:blogger.com,1999:blog-5377233936486388397.post-15012240154574314252008-09-06T16:30:00.000-07:002008-09-07T13:08:38.183-07:00Google Chrome: Better than Firefox, Internet ExplorerI installed Chrome when it came out last week and after only a day of using it I did the unthinkable: I made it my default browser. This is a big deal. I resisted making Firefox my default browser out of a very strong sense of loyalty to Internet Explorer. Chrome, however, is what I have always wanted a web browser to be: useful.<br /><br />Let us start with the obvious things. The Tab UI is awesome. I have never liked the Firefox Tab UI. I think the IE Tab UI looks good, but they (we) never really nailed all the little quirks. Putting it up in the non-client area seems like such a no-brainer now. The UI is snappy, the animations are good looking, but subtle enough not to get in the way of using the product. <br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsDCxfu65L3fG1GMj-UW8xzee0MN92iow-0aDMgQrrwG67XBEH3W8v8OfTL_rPVug12TfJYCgMcarfR8dvYFvB4SXmue4L2WTrv2PNqYaDCUjkDu4HyboZEN6qObI06xw8CNCPvPKunwE/s1600-h/chrome.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsDCxfu65L3fG1GMj-UW8xzee0MN92iow-0aDMgQrrwG67XBEH3W8v8OfTL_rPVug12TfJYCgMcarfR8dvYFvB4SXmue4L2WTrv2PNqYaDCUjkDu4HyboZEN6qObI06xw8CNCPvPKunwE/s320/chrome.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5243056406841098994" /></a><br /><br />The MFU with thumbnails on the new-tab page is nice, though I wish it was more than just the top nine pages. I find it odd that I like it so much because I was really against doing something like this for IE (but I also never thought it could be made so fast in IE). I love the history-as-a-webpage feature. I am a little disappointed that I can not find a shortcut key to get to bookmarks. I don't want to take up screen space by having the bookmarks bar visible (though it is nice UI if you do turn it on). I know I can just type the name of the bookmark in the address bar, but I actually have long lists of bookmarks that I like to visit every day in a specific order. Instead I use CTRL+T to get a new tab then click the bookmark button.<br /><br />I love the simplicity. We tried to make IE7 simple by getting rid of the menu bars and re-working things into the command bar. Chrome takes it all the way though. <br /><br />The only UI I think looks wonky is the little pop-up in the bottom corner of the screen that appears when you hover over links. But I do like the little drop-down find box.<br /><br />And of course, it would be nice if it worked with the ajax-y features of Facebook and Netflix.jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.com0tag:blogger.com,1999:blog-5377233936486388397.post-88549722796918223612008-07-02T10:17:00.000-07:002008-07-02T10:35:56.152-07:00firefox 3: better than internet explorer 7This is a difficult thing for me to admit, but I think Firefox 3 is better than Internet Explorer 7. Having worked on the IE team, I am the first one to defend it, apologize for it, and staunchly refuse to use anything else. So how could this have happened?<br /><br />Well, the product <a href="http://www.piclens.com/">I work on now</a> is a plug-in for both Firefox and IE. Since I am primarily responsible for the IE version, and I do most of my development and debugging of our product when it is running inside IE. As a result I am forced to use Firefox to read e-mail and such while my IE install is in a bad state. <br /><br />Firefox 2 was usable, but I liked IE much better still. A lot of really good UI work went into IE 7 around the Tab UI and optimizing away the old menu bar. Sure, it has its faults and quirks, but I still felt more at home in IE.<br /><br />Now that Firefox 3 is out, I basically have been converted without even thinking about it. And that's the key: when I use Firefox 3, I don't notice that it isn't IE. The only time I notice it's Firefox is when it does something better than IE, like spell checking my edit boxes, or remembering the URLs from my last session. <br /><br />It's the little things that matter.<br /><br />When I use IE now, it feels slow and poorly put together. Firefox is snappy; the UI is more polished. They stole some ideas from IE (The Gold Bar) and made them better. They have some ideas of their own (disjoint search term matching in autocomplete) that are great, too.<br /><br />And as a good friend of mine used to say, "if it ain't snappy, it's crappy." <br /><br />So Firefox 3 sets a high bar for the IE team to meet. I sincerely hope they blow it away. I think it is way too early to judge the IE8 UI; I will just have to wait and see how it shapes up.jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.com6tag:blogger.com,1999:blog-5377233936486388397.post-35287435153251794652008-06-22T08:54:00.000-07:002008-06-22T09:07:11.646-07:00your bho and your activex control can't be the same objectFrequently I see people writing a BHO, and at some point they realize they need to make a way for a webpage to call some function implemented by the BHO. The best way to do this is to expose an ActiveX control. The most common mistake I see is trying to make the ActiveX control be the same C++ object as the BHO.<br /><br />This is wrong for several reasons.<br /><br /><strong>It violates good coding practice.</strong> <br /><br />The whole point of object level encapsulation is that each object does one thing. If your BHO is your ActiveX control, now it does two things. It may seem at first that you're really just adding a new method to your BHO, but you have to take into account all that goes along with being an ActiveX control. Implementing IDispatch, loading and dealing with the type library, implementing IObjectSafety, etc. <br /><br /><strong>Your site will be wrong.</strong> <br /><br />Pretty much every IE extension type--toolbands, BHOs, toolbar buttons, ActiveX controls--implements IObjectWithSite. If you make one object be two different types of extension, they will share IObjectWithSite implementations. And they all have a different IE object that is their site. <br /><br />For example, a toolbar button's site will be an object in IE's toolbar code. A BHO's site is a completely different object in ieframe.dll that knows how to create and interact with a BHO. Explorer bars are sited to an object in ieframe.dll that hosts an explorer bar. And ActiveX controls are sited to an object in mshtml.dll that knows how to host ActiveX controls and implements several DOM interfaces (IHTMLElement, etc) as well. <br /><br />So if you make your BHO and your ActiveX control the same object, the BHO will be instantiated first and IE will call your IObjectWithSite::SetSite() method with a pointer to one type of object. Then, when your ActiveX control is created later on, IE will call the IObjectWithSite::SetSite() method again, but this time with a different internal IE object's address. Now your BHO is broken. And debugging this sort of thing may take you a long time.<br /><br /><strong>What we Learned Today</strong><br /><br />Every IE extension you implement must be it's own object, or bad things will start to happen.jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.com0tag:blogger.com,1999:blog-5377233936486388397.post-42027857464623125152008-06-21T10:57:00.000-07:002008-06-21T11:07:54.436-07:00the internet explorer object cookbookWhen you start writing Internet Explorer extensions, or dealing with the DOM and the Webbrowser control at all, you frequently find you have an object of type X and you need to get the corresponding object of type Y. There is a lot of myth and bad advice on the web surrounding how to do some of these things. <br /><br />The "site" in all of the following refer to the IUnknown you are given by Internet Explorer when it calls your IObjectWithSite::SetSite() method.<br /><br /><strong>IWebBrowser2 from site</strong><br /><br />1. QueryInterface() your site for IID_IServiceProvider.<br />2. QueryService() the IServiceProvider for SID_STopLevelBrowser, IID_IServiceProvider.<br />3. QueryService() the top level IServiceProvider for SID_SWebBrowserApp, IID_IWebBrowser2.<br /><br /><strong>IHTMLDocument2 from IWebBrowser2</strong><br /><br />1. Call IWebBrowser2::get_Document().<br />2. QueryInterface() the resulting IDispatch pointer for IID_IHTMLDocument2.<br /><br /><strong>IHTMLDocument2 from site</strong><br /><br />1. Follow steps for "IWebBrowser2 from site" above.<br />2. Follow steps for "IHTMLDocument2 from IWebBrowser2" above.<br /><br /><strong>IWebBrowser2 from IHTMLDocument2</strong><br /><br />1. QueryInterface() the IHTMLDocument2 for IID_IServiceProvider.<br />2. QueryService() the IServiceProvider for SID_SWebBrowserApp, IID_IWebBrowser2.<br /><br /><strong>IHTMLDocument2 from IHTMLElement</strong><br /><br />1. Call IHTMLElement::get_Document();<br />2. QueryInterface() the resulting IDispatch pointer for IID_IHTMLDocument2.<br /><br /><strong>IHTMLDocument2 from HWND</strong><br /><br />1. Use the accessibility hack described at <a href="http://support.microsoft.com/kb/q249232/">here</a>.jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.com0tag:blogger.com,1999:blog-5377233936486388397.post-20872055821184267552008-06-02T08:38:00.001-07:002008-06-02T09:26:12.102-07:00the freedom to choose includes the freedom to choose poorlyNo, I am not going to talk about democrotics and our current and upcoming elected officials. I am going to talk about the consumer computer eco-system. <br /><br />When I was doing IT consulting work during collage, there were a few major players in the PC world: Dell, HP, Compaq and Gateway. They all had their ups and downs with their products. Usually one would be good while the other was making boxes with problems, but then it would switch. Our job was to keep up on who was making good boxes at the time and sell them to our customers. However, we all knew the best machines were machines you built yourself. And we enjoyed building them. So when friends and family would ask me what computer they should buy, I would mention who I though was making a good model, but I would also offer to build them one that was better for cheaper.<br /><br />When I worked at MSFT, we all had Dell workstations. I would say about 90% of all Windows development took place on Dell machines with Intel Processors. So when friends and family would ask for a computer recommendation, I would point them at Dell. Of course, I no longer had time to build them a machine, though I still built my own from scratch.<br /><br />Now that I work on PicLens, I have to write code that supports Firefox, Internet Explorer and Safari on both Mac and Windows. We have subsystems that run on top of OpenGL, DirectX, and a software rendered that works in two different modes, depending on which we detect would give better support on a specific system. <br /><br />Yet we still get a fair number of people who send in e-mail with reports of graphics issues. Some are minor glitches, some are major glitches that make the product unusable. A very small number are blue screens. We take all customer feedback seriously and follow up with them asking about their configuration, etc. Almost all of them have one thing in common: non-premium graphics cards, by which I mean a card that is not a high end ATI or NVidia card.<br /><br />I am coming to the part where I get to the point.<br /><br />These days, when friends and family ask me what computer they should get, I think I will start telling them to get a Mac. <br /><br />Let me be clear, I still hate Macs. With a passion. I have to use one at work, and I remain unconverted. But what they do is take away the freedom to choose poorly. <br /><br />Let me explain:<br /><br />With a PC, you never know what you are going to get. And even people who build there own machines often make decisions based on price point, not quality. Not to mention people who build their own machines but do not really understand how hardware and software drivers work. <br /><br />With a Mac, you always get good hardware. They all have Intel processors. They all have NVidia or ATI graphics cards, with drivers that are known to work. Sure, Microsoft can certify drivers, but they can not test them in every possible configuration of PC hardware. But Apple can test every configuration. Because they only have tens of possibilities instead of thousands. <br /><br />Nothing has really changed since I was in IT consulting. The trade-offs are still the same: build your own, buy an OEM and roll the dice, or pay a bunch more for a Mac that you can only do so much with but at least it will work. All that has changed is my point of view. <br /><br />As an idealistic youth, I wanted everyone to get the most from their computing experience. I wanted to educate them about the machines and the software. At Microsoft I just wanted them to leave me alone and figure it out for themselves. Now I just can not be bothered by it at all. Macs work. They stop you from shooting yourself in the foot. And hey, if people think it makes them look cool, then even better.<br /><br />I will still be building my own machines. My house is all Asus all the time. It is amazing, but I have never had any problems with Asus video cards in Asus mother boards. I prefer NVidia (though it is not a logical or rational preference). I only buy Intel Processors(but that is a completely separate discussion) and Seagate hard drives (though I will accept Western Digital and I really wish there was a quality third player). <br /><br />Everyone else should get a Mac. It makes my life easier in the short term, since I do not have to do any support. Though, I guess if everyone got a Mac I would have to do ALL my development on a Mac. And I would miss Visual Studio and NTSD.<br /><br />So, I guess the moral of the story is when choosing a video card, choose wisely. <em>Caveat emptor</em> and all that. Or, spend more than $20 on a video card.<br /><br />See also: <a href="http://www.wired.com/gadgets/displays/news/2008/06/gpu">Wired: Graphics Chips Gun for Supremacy in Silicon Showdown</a>jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.com0tag:blogger.com,1999:blog-5377233936486388397.post-84165946805404418672008-05-31T09:16:00.000-07:002008-05-31T09:26:02.566-07:00the TIF really is a cache -- and it acts like oneIt seems obvious, but I guess it has to be said. Internet Explorer's Temporary Internet Files folder is a cache. From Wikipedia: <em>a cache is a temporary storage area where frequently accessed data can be stored for rapid access</em>. Please note the use of the word <em>temporary</em>. This means that the data you want may not actually be there. <br /><br />I frequently see questions along the lines of "How can I find this image/page in the cache?" or, even better, "How come this page I viewed isn't in the cache?" I love it when the askers of the latter form imply that this is a bug.<br /><br />Files in the cache can be deleted at anytime. You can be looking at a page and then go to the cache and find it isn't there. There are many scenarios where this is legitimate. For example, if, while you are viewing this page, you go to Tools->Delete Browsing History and then clear your Temporary Internet Files, the only representation that IE will have of this page and all of its elements is the one in memory. Close the browser and that memory is freed and now its gone until you download it from the webserver again.<br /><br />The page you are viewing may use the no-cache http header. The cache manager may have decided its time to scavenge. There may have even been an error writing to the cache and the cache has become corrupt.<br /><br />I am sure there are other scenarios as well. The point is, you cannot rely on data to always be there. You must either capture the data in some other way, or be prepared to make a request to the server.jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.com0tag:blogger.com,1999:blog-5377233936486388397.post-90106299265971898842008-05-29T09:39:00.000-07:002008-05-29T09:52:11.548-07:00to help or not to helpMore and more I am confronted with a sort of moral dilemma. I read and post to the <a href="http://forums.microsoft.com/MSDN/default.aspx?ForumGroupID=253&SiteID=1">IE development forums</a> over at MSDN. Frequently I see posts like this:<br /><br /><div style="background-color:#ffffff;color:#227722;border:1px solid orange; padding:2px 2px 2px 2px;font-family:courier new;font-size:12px;">i want a BHO which continuously observe IE activity and send the URLs visited and time of visit and time of outfocus of them as soon as they are available,to listening java servlet. Now Please suggest me how to do this,perticularly this sending of url and their time details to java servlet.<br /></div><br /><br />He does not ask for help with a specific problem or bug he has encountered in the process. He does not tell us what he has done or post a sample of code he can not get to work. He simply asks, "how do I do this?" His masterful command of English does not help his case.<br /><br />This guy is probably up to no good.<br /><br />I can only think of one semi-legit use for such a thing, which would be for employers or parents to spy on their employees or children. And I'm not sure I can even get behind that.<br /><br />So my dilemma becomes, do I help this guy? Do I tell him what to do? On the one hand, I do not want to be enabling spyware makers in anyway. On the other hand, if someone is paying him to do this thing, he is going to write the program whether I help him or not. Given that, is it better to make sure he does it right? I mean, which is better, crashing spyware or non-crashing spyware? <br /><br />Anyway, today I am not helping this guy.jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.com0tag:blogger.com,1999:blog-5377233936486388397.post-74748882616700384772008-04-15T11:26:00.001-07:002008-04-15T11:31:18.579-07:00PicLens 1.6.3 ReleasedWe released 1.6.3 yesterday to <a href="http://www.piclens.com">piclens.com</a>. Why the change from 1.6.2 to 1.6.3? Because we now support <em>video</em> in the Wall. <br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8y7e6u5ubAz0FiHNY46pHXSVeM-nc11WieEmWQFXgSQg92Xl2WCfINvc_fq35XZiNGj4zDU4Q-UjYU7prFh-HXLmfDmuM8Eeyg_uGm7uCyv7VQMc0T8-vObJEUK_eE3YNTtvkn2osyuo/s1600-h/video-ss.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8y7e6u5ubAz0FiHNY46pHXSVeM-nc11WieEmWQFXgSQg92Xl2WCfINvc_fq35XZiNGj4zDU4Q-UjYU7prFh-HXLmfDmuM8Eeyg_uGm7uCyv7VQMc0T8-vObJEUK_eE3YNTtvkn2osyuo/s320/video-ss.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5189541170845288754" /></a><br /><br />You can search YouTube and watch the videos right in the wall. During development we spent a lot of time watching videos... it can be very addictive.jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.com0tag:blogger.com,1999:blog-5377233936486388397.post-49097363303233701512008-03-20T10:25:00.000-07:002008-03-20T10:59:52.751-07:00I can't stand it anymore, I have to say itI love my iPhone.<br /><br />There, I said it. I feel dirty.<br /><br />My Windows-based SmartPhone got crushed in an under-the-motorized-car-seat retrieval operation that went horribly awry. Faced with a rapidly diminishing usable space on the cracked LCD screen, I went to the AT&T store to get the new hotness.<br /><br />I suspected I wanted an iPhone. I didn't want to pay a lot for a phone, but what can you do? I carefully considered each and every phone they had and compared it to the iPhone. The results fell into one of two catagories:<br /><br />1) This phone is complete crap and they have the nerve to charge [$100..$200] for it.<br />2) This phone isn't an iPhone, but costs just as much.<br /><br />So I bought the iPhone.<br /><br />The installation experience was harrowing. I found out you have to activate it through iTunes. I hate iTunes. I hate QuickTime. I hate all Apple software. I hate all third party software. I don't like the way it infects my machine with little processes that run without asking and little icons littered about the desktop and quicklaunch and systray. I hates it all.<br /><br />But my wife has an iPod, so it was already installed. What can you do?<br /><br />However, I had to upgrade to the latest version of iTunes. So I fired up IE and went to apple.com. Halfway through the download, IE crashed. <br /><br />So I used FireFox to download iTunes.<br /><br />As a developer who used to work on Internet Explorer, you have no idea how much that hurt me. It was a sad, sad day. Snow flakes were reported in Hell. <br /><br />But now I have the iPhone and it's the best phone ever and probably the best UI for anything other than <a href="http://www.piclens.com">PicLens</a>.jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.com3tag:blogger.com,1999:blog-5377233936486388397.post-59784051413904522292008-03-14T10:13:00.000-07:002008-03-14T10:16:02.141-07:00WikiTalk redesignMy previous project, <a href="http://www.wikitalk.com">WikiTalk</a>, has just undergone a major face lift this morning. I didn't know it was coming and was quite shocked to see it when I loaded it before work this morning.<br /><br /><a href="http://www.wikitalk.com"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgym74tCw44Mjrhyphenhyphenb6bLeSUkzVFnhDRuYPMlS9uY6rI0DH_ZoXi4umUYB9Dgpp9i5EEVaF8mGcIotB7ME4ahyphenhyphenGWqo7BcAEevpm5RALecIAZbZgbbnWTOs5tKq1iUUWDM2n7wvOJHayDiB4/s320/wikitalk.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5177646877956550546" /></a><br /><br />Congratulations guys. It looks really good.jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.com0tag:blogger.com,1999:blog-5377233936486388397.post-55148711868723621392008-03-09T12:56:00.001-07:002008-03-09T13:00:59.440-07:00PicLens: new version and news round-upWe worked hard all week, some team members staying awake for inadvisably long periods of time, to bring you all our latest work: <a href="http://www.piclens.com/">PicLens 1.6.2</a>.<br /><br />This new version fixes many performance and stability issues, and most notably, improves graphics support for a significant number of people who may have had issues with previous versions of PicLens. We added Direct3D 9 support when running on Windows. This means you must have Windows XP Service Pack 2 (or the DX9 redist) installed or you will be running with a software renderer. <br /><br />In the news, the <a href="http://www.nytimes.com/2008/03/09/business/09stream.html?_r=1&oref=slogin">New York Times has an article</a> on PicLens and the future of web browsing. And we've been <a href="http://slashdot.org/article.pl?no_d2=1&sid=08/03/09/1323243">slashdotted</a>.jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.com0tag:blogger.com,1999:blog-5377233936486388397.post-77951107334237595852008-02-19T22:52:00.001-08:002008-02-19T23:43:26.481-08:00how to create an activex control that fires events to javascript (without using ATL)<strong>Creating ActiveX Controls that Fire Events (without ATL)</strong><br /><br />I recently spent a fair bit of time at work figuring out how to write all the COM and OLE goo to make this work. There are lots of articles that tell you how to use ATL, but I am against ATL and I wanted to do it the old fashioned way. Here is a summary of what I learned.<br /><br />The scenario was this: I wanted to have an ActiveX control that would download some file on a worker thread, then fire events that could be handled by JScript before, during and after the download. The general outline would look like this:<br /><br />1. Page loads, control instantiated via object tag.<br />2. JScript calls attachEvent() to setup event handlers for the control.<br />3. JScript calls a method to start download.<br />4. Control spins up a worker thread which calls URLDownloadToFile().<br />5. The worker thread receives progress notifications via IBindStatusCallback(). Control fires events to JScript (from the worker thread) to inform JScript of progress.<br />6. Download completes, worker thread fires event to JScript.<br /><br />I will call my control the Downloader and his CLSID is CLSID_DownloaderCtrl.<br /><br />To make this happen your control must implement (and respond to in IUnknown::QueryInterface()):<br /><br />1. IUnknown<br />2. IDispatch<br />3. IProvideClassInfo, IProvideClassInfo2<br />4. IObjectWithSite<br />5. IConnectionPointContainer<br />6. IDownloader (this is the dual interface for scripts to call methods the control exposes)<br />7. IObjectSafety<br />8. IServiceProvider (for URLDownloadToFile() to work properly)<br />9. IBindStatusCallback (optional -- only if you want download progess)<br /><br />You will also need to implement IConnectionPoint, but do not repsond to it in QueryInterface. More on this later.<br /><br /><strong>IUnknown</strong><br /><br />I assume you know how to implement IUnknown. Read Raymond's post on <a href="http://blogs.msdn.com/oldnewthing/archive/2004/03/26/96777.aspx">getting it wrong</a> to make sure you know how to implement it.<br /><br /><strong>Type Libraries</strong><br /><br />Before we can do much more we need a type library. To get this working, you have to create an .idl file that contains definitions. There are four important parts. Each one has its own GUID. They are specified in the .idl and MIDL will generate a header file and c file that defines them.<br /><br />1. The outgoing event (disp)interface. DIID_DDownloaderEvents<br />2. The incoming (dual) interface. IID_IDownloader<br />3. The coclass goo. CLSID_DownloaderCtrl<br />4. The library. LIBID_Downloader<br /><br />Your .idl should look something like this:<br /><pre><br />[<br /> uuid(00000000-0000-0000-0000-000000000000),<br /> version(1.0)<br />]<br />library Downloader<br />{<br /> [<br /> uuid(11111111-1111-1111-1111-111111111111), <br /> hidden<br /> ]<br /> dispinterface DDownloaderEvents<br /> {<br /> properties: <br /> methods:<br /> [id(DISPID_PROGRESS)] void Progress();<br /> [id(DISPID_COMPLETE)] void Complete();<br /> }<br /><br /> [<br /> dual,<br /> uuid(22222222-2222-2222-2222-222222222222)<br /> ]<br /> interface IDownloader : IDispatch<br /> {<br /> [id(DISPID_DOWNLOAD)] HRESULT download(BSTR bstrFile);<br /> }<br /><br /> [<br /> uuid(33333333-3333-3333-3333-333333333333)<br /> ]<br /> coclass DownloaderCtrl<br /> {<br /> [default] interface IDownloader;<br /> [source, default] dispinterface DDownloaderEvents;<br /> }<br />}<br /></pre><br /><br /><br />MIDL will generate a .tlb file from this. You must include this type library as a resource in your .dll. To do that, add a line like the following:<br /><br />1 TYPELIB "downloader.tlb"<br /><br />Now you can call LoadTypeLib() using your module's path to get the type library, which you will need to use in your IDispatch implementation.<br /><br /><strong>IDispatch</strong><br /><br />I am going to assume you know mostly know how to implement this as well. It is well documented. The important thing is to make sure you expose your typelib correctly.<br /><br /><strong>IProvideClassInfo, IProvideClassInfo2</strong><br /><br />These are pretty straight-forward. In GetGUID() return your outgoing event interface, DIID_DDownloaderEvents. <br /><br />The only tricky part is in GetClassInfo. You should call LoadTypeLib() then call ITypeLib->GetTypeInfoOfGuid(). The question is, which GUID do you use? The correct answer is CLSID_DownloaderCtrl. This gets the type info of your coclass, which Internet Explorer can use to figure out what your outgoing event interface is.<br /><br /><strong>IConnectionPointContainer</strong><br /><strong></strong><br />When you call attachEvent() in JScript, IE will ask for this interface to try to find a connection point for your outgoing event interface. You have to implement FindConnectionPoint(). I found EnumConnectionPoints() and to not be called by Internet Explorer. However, you may experience different results here. Set breakpoints and/or use asserts() to make sure anything you E_NOTIMPL isn't called, otherwise you may find yourself debugging into the wee hours.<br /><strong></strong><br /><strong>IConnectionPoint</strong><br /><strong></strong><br />FindConnectionPoint() gives out a pointer to an IConnectionPoint, which should really be a different object than your IConnectionPointContainer. See the documentation. We don't respond to IConnectionPoint in QueryInterface, since the only allowed way of getting it is via FindConnectionPoint(). <br /><br />You have to implement Advise() and Unadvise(). The remaining methods were never called for my implementation. However, as above, your milage may vary. Everytime IE calls Advise(), it will pass you an IUnknown. QueryInterface() for IID_IDispatch and remember that pointer. Make sure you associate it with the cookie you give back (std::map is one option, if you go in for that sort of thing).<br /><br />When you want to fire your event, simply call the Invoke() member of all the IDispatch pointers you are holding on to, passing whatever parameters you want and the DISPID of whatever event you want to send.<br /><br />Important: Before you use this pointer, read the bit about marshalling below.<br /><strong></strong><br /><strong>IObjectWithSite</strong><br /><br />This is simple as well. Make sure you respond to SetSite(NULL) by releasing all the pointers you acquired from your site. Also, this is your queue that your control is going away soon.<br /><br /><strong>IServiceProvider</strong><br /><br />All you have to do here is QueryInterface your site for IServiceProvider and thunk the call to QueryService() through to your site's implementation. If you're using the Vista SDK, you can use IUnknown_QueryService(). <br /><br />If you don't implement this, URLDownloadToFile() may not be able to get access to certain security information and your life will be harder.<br /><br /><strong>IObjectSafety</strong><br /><br />You should implement this to make instantiating your control easier and safer. Refer to the documentation and plentiful on-line examples.<br /><br /><strong>A Word on Marshalling</strong><br /><br />My object operates on two threads--the IE Tab thread that it is created on, and a worker thread that does the heavy lifting. The point of using a worker thread is to not hang the UI while the download happens. This gives a nice experience, but makes implementation harder.<br /><br />The one thing to remember, is all of IE's interaction with your object will happen on it's thread. You will receive IDispatch pointers on this thread. You cannot use these pointers in a different apartment (which means, you cannot use them on the worker thread). <br /><br />In order to fire events from the worker thread, you must marshal the IDispatch pointers. You have two options for doing this:<br /><br />1) Call CoMarshalInterThreadInterfaceInStream() on the IE thread, then CoGetInterfaceAndReleaseStream() on the worker thread. Do this for every IDispatch pointer and use the pointer returned on the worker thread. <br />2) Use the GIT (Global Interface Table). You're on your own with that one -- see the documentation.<br /><br />If you try to use the pointer on the wrong thread, your Invoke() call will fail silently and the event will not be fired.<br /><br /><strong>Setting up the JScript</strong><br /><br />1. Create your object using the object tag. You cannot use new ActiveXObject() because IE will not hook-up the events for you. <br />2. Give your object tag and ID, such as ID="downloader". <br />3. In the onLoad handler for the body element, call a function that uses the ID to attach the event handlers to events. E.g., downloader.attachEvent('Progress', onProgressEvent). Then simply implement the onProgressEvent() in JScript in the script section of your HTML.<br /><br /><strong>Conclusion</strong><br /><br />Well, I hope that helps someone. If you have anything to add, please leave a comment.jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.com6tag:blogger.com,1999:blog-5377233936486388397.post-50908353491973205572008-02-15T10:47:00.000-08:002008-02-15T10:55:02.149-08:00New build of PicLens for Internet ExplorerWe posted a new build of PicLens for Internet Explorer yesterday to <a href="http://www.piclens.com">PicLens.com</a>. It does not add any features, but does contain several performance and stability improvements. <br /><br />If you have PicLens for Internet Explorer (or even if you don't have it yet!) you should be sure to upgrade to this latest version.jeffdavhttp://www.blogger.com/profile/14865307340669462204noreply@blogger.com0