Archive for the 'Dev Stuff' Category

Highlighting External Links within WordPress

You may have seen this symbol  next to links on various pages of the Web. It denotes that the link (which is usually placed before the symbol) is an external link.

If you’ve ever wanted to differentiate internal links from external links on your blog, there is a fairly simple way of doing it, and all it requires is a few lines of text added to your stylesheet.

In this post, we’ll show you how to do it.

Why differentiate between internal and external links?

Today, most people scan, they don’t read the full text of a blog. By representing your external links visually, visitors can see - at a glance - that you’ve given them quick access to relevant and related content that is not solely on your site. This is significant because the easier you make it for your visitors; the more information you supply, the more likely they are to subscribe to your RSS feed, or return to your site next time around.

How to differentiate between internal and external links on your blog

You won’t need to change anything on your existing posts; you’ll just need to make a few small changes to your style sheet.

This change will automatically update every post you have ever written.

Step 1: Copy the ‘external’ Image File

You need to copy the image file, external.gif, to the images sub-folder within your current WordPress theme folder.

Step 2: Add ‘external’ Image to Links

To create links that appear within posts as:

Add the following to your style sheet:

a
{
  background: url(/category/dev_stuff/images/external.gif) no-repeat right top;
  padding-right: 12px;
}
 

The right padding value of 12 pixels ensures that the image does not overlap the text of the link.

Step 3: Differentiate Between Relative and Absolute Links

A handy feature of CSS is that you can apply a style not only to a HTML tag, but optionally based on the contents of any of the HTML tag’s attributes.

For example, to apply the above style to only those link references which contain “http:”, you modify the style sheet entries as follows:

a[href^="http:"]
{
  background: url(/category/dev_stuff/images/external.gif) no-repeat right top;
  padding-right: 12px;
}
 

But this is only useful, if links to other posts are relative and not absolute links. An example of a relative link is ‘<a href=”another-post”>…</a>‘; whereas, an absolute link is ‘<a href=”http://blog.example.com/another-post”>…</a>‘.

Step 4: Exclude Absolute Links to Your Blog or Web Site

Now WordPress always uses absolute links. So to ensure that any link to your own blog or Web site does not have the external image applied, you follow the above style with entries which undo this change. The entries are specific to domain name of the blog or Web site.

For BlogWell, all our links start with http://blog-well.com. You will need to replace “http://blog-well.com” in the entries below with the domain name of your blog or Web site:

a[href^="http:"]
{
  background: url(/category/dev_stuff/images/external.gif) no-repeat right top;
  padding-right: 12px;
}
a[href^=http://blog-well.com]
{
  background: none;
  padding-right: 0px;
} 

Step 5: Add a Class to Exclude the ‘external’ Image

Sometimes you may want some links which go outside of your blog or Web site to not have the external image applied. You can do this on a case by case basis by using a link class of ‘noexternallink’. Within your post you would write the link as:

<a class='noexternallink' href='http://example.com'>Example</a>

And the style sheet would contain:

a[href^="http:"]
{
  background: url(/category/dev_stuff/images/external.gif) no-repeat right top;
  padding-right: 12px;
}
a.noexternallink[href^="http:"],
a[href^=http://blog-well.com]
{
  background: none;
  padding-right: 0px;
}

Note than ‘a.noexternallink[href^="http:"]‘ and ‘a[href^="/index.html"]‘ are separated by a comma. This is very important, since it ensures that the background of none and right padding of 0 pixels are applied to both ‘a.noexternallink[href^="http:"]‘ and ‘a[href^="/index.html"]‘. If you forget the comma, then it will only be applied, should ‘a[href^="/index.html"]‘ follow a ‘a.noexternallink[href^="http:"]‘.

Step 6: Exclude ‘external’ Image from Header and Footer Items

Within BlogWell’s theme we did not want any links within the header or footer to use the external image. Our theme uses the DIV HTML tag to identify the header and footer, and use the ID values of ‘header’ and ‘footer’ for each respectively.

<div id='header'>
...
</div>
...
<div id='footer'>
...
</div>

Without having to change all the links within the header and footer to use the ‘noexternallink’ class for links, we can easily prevent any links within the header and footer DIVs by using the following:

a[href^="http:"]
{
  background: url(/category/dev_stuff/images/external.gif) no-repeat right top;
  padding-right: 12px;
}
#header a[href^="http:"],
#footer a[href^="http:"],
a.noexternallink[href^="http:"],
a[href^=http://blog-well.com]
{
  background: none;
  padding-right: 0px;
}

Step 7: Exclude ‘external’ Image from Sidebar Items

If you didn’t want the external image to be applied to any links within any of the sidebars, you can do the following:

a[href^="http:"]
{
  background: url(/category/dev_stuff/images/external.gif) no-repeat right top;
  padding-right: 12px;
}
#header a[href^="http:"],
#footer a[href^="http:"],
#sidebar a[href^="http:"],
a.noexternallink[href^="http:"],
a[href^=http://blog-well.com]
{
  background: none;
  padding-right: 0px;
}

Step 8: Include Both Normal and Secure HTTP Links

If you use Secure HTTP, then your links will start with “https:”. To handle either standard HTTP (http://) or Secure HTTP (https://), then the above style sheet entries would be:

a[href^="http:"], a[href^="https:"]
{
  background: url(/category/dev_stuff/images/external.gif) no-repeat right top;
  padding-right: 12px;
}
#header a[href^="http:"], #header a[href^="https:"],
#footer a[href^="http:"], #footer a[href^="https:"],
#sidebar a[href^="http:"], #sidebar a[href^="https:"],
a.noexternallink[href^="http:"], a.noexternallink[href^="https:"]
a[href^="/index.html"], a[href^=https://blog-well.com]
{
  background: none;
  padding-right: 0px;
}

Step 9: Review Padding Styles for Existing Links in Your Theme

A word or caution, as now links within the blog or Web Site will have a right padding of 0 pixels. If your theme explicitly sets the right padding for some items, then you will need to mark these settings as important which will ensure that value is used instead of the new value of 0 which is set in the above style sheet entries.

For example, BlogWell’s menu in the header, uses links which have a right padding of 20 pixels. So after adding the above entries to our theme’s style sheet, our menu appeared as:

The style entry which sets the menu’s right padding is:

#topnav ul li a
{
  padding-right: 20px;
}

CSS allows style sheet attributes to be marked as important, which means they will not be overridden by other style sheet entries. We can use the “!important” tag to ensure that the right padding of 20 pixels is used rather than it be overridden by the 0 pixel padding of our external link entries.

#topnav ul li a
{
  padding-right: 20px !important;
}

Our menu is now restored to its correct state:

Step 10: Review

To highlight external links within your blog or Web site do the following:

1) Copy external.gif to the images sub-folder of your current WordPress’ theme folder.

2) Add the following lines to your style sheet:

a[href^="http:"], a[href^="https:"]
{
  background: url(/category/dev_stuff/images/external.gif) no-repeat right top;
  padding-right: 12px;
}
#header a[href^="http:"], #header a[href^="https:"],
#footer a[href^="http:"], #footer a[href^="https:"],
#sidebar a[href^="http:"], #sidebar a[href^="https:"],
a.noexternallink[href^="http:"], a.noexternallink[href^="https:"]
a[href^="/index.html"], a[href^=https://blog-well.com]
{
  background: none;
  padding-right: 0px;
}

3) Review your style sheet to see if any entries explicitly set the right padding value, in which case you may need to mark them with the “!important” tag.

A Final Word on Browsers

Should the link wrap around to a new line, Mozilla Firefox will display the external image correctly, following the end of the link on the new line.

 

However, Microsoft Internet Explorer will display the external image incorrectly at the end of the first line without any margin so it overlaps the text.

 

Sphere: Related Content

Hacking Tool Useful for Web Developers

Photo Credit: practicalowl

I discovered a cool free tool at the recent RSA conference, called Paros, a man-in-the-middle (MITM) proxy. While my fist impression was that Paros is no more than a hacking tool, upon further investigation I discovered it can be really useful to developers and testers.

If you don’t know what a man in the middle attack is, it is an Internet attack, where the person doing the attacking intercepts, and attempts to read or alter information moving between two computers.

As a dev tool, Paros is useful because:

  • You can easily monitor the traffic between the browser and the site you are developing.
  • You can trap the requests, and if you made an error you can change it, so you can test that whether the remainder of the application works correctly. This saves you having to immediately change the application to correct the erroneous request.
  • It raises the visibility of the information being exchanged. If there is any user related information, other than the initial login information, get rid of it quick, as this will allow hackers to easily request other user’s information.

Fore warned is fore armed.

One thing I don’t like is that when you download Paros, they hide the download link in the top right hand corner of the download page, and present sponsor solicitations, which on a quick glance, you think they are required for downloading. They are not, so skip them.

I have since discovered Fiddler, which I had yet to try. This is a free tool, supposedly from Microsoft, so if you prefer a non-Java based application, as Paros is, give this a try.

Sphere: Related Content

100+ Resources for Web Developers

100+ Resources for Web Developers

Photo Credit: SMITHMag

Update #1 - March 14, 2008 

There is some amazing stuff out there on the Web–resources, tools, tricks, and tips. Problem is, as a Web developer, you spend so much of your time just keeping up with new technologies - learning, playing – and this doesn’t leave much time to go hunting for the latest and greatest tool, or for a better way of doing things.

So we’ve put together a list of over 100 resources to help make your life as a developer easier; where to find snippets of code, sites that automate processes, cheat sheets, lessons, useful tools and a couple of silly videos to give your brain a break if you make it through to the end. Please enjoy!

Code

Head Tag

Photo Credit: Josh Lewis

1. Little Boxes
CSS Templates for various page layouts

2. Snipplr
Collection of code snippets - JavaScript, HTML, PHP, CSS, Ruby, Objective C

3. AJAX, DHTML and JavaScript Libraries
An extensive list with over 60 Ajax, Javascript and DHTML Libraries - with detailed descriptions.

4. Javascript Framework
Easy Ajax and DOM manipulation for dynamic Web applications

5. AJAX Javascript Solutions for Professional Coding
Over 90 useful AJAX-based techniques you should always have ready to hand

6. DHTML and AJAX samples
Nice looking simple downloadable DHTML and AJAX code

7. AJAX Patterns
A Wiki of reusable AJAX code, and huge AJAX resource

8. Mozilla Developer Center - AJAX
Mozilla’s offering on AJAX

9. CSS Typeset
Interactive CSS generator

10. Open Source Directory
An archive of the Web’s best Open Source software, applications and references.

11. .htaccess Creator
Online tool to create .htaccess files

12. PHP Form
Create HTML Forms in seconds and get the code

13. Best Solutions for Images
30 scripts of impressive slideshows, lightboxes and galleries you can use for effective presentations of your images.

14. Lightbox
Lightbox is a simple unobtrusive script used to overlay images on a page

15. Design patterns and tips
101 Design Patterns and Tips for Developers

16. Spanky Corners
Creates CSS and GIF images for rounded corners

17. Nifty Corners Cube
Rounded corners with no images

18. How to redirect a Web page the right way
Don’t lose PageRank! Steven Hargrove gives you the code to redirect using htaccess, Mod_Rewrite, IIS, ColdFusion, ASP, Java, Perl, Ruby and PHP.

19. jQuery
jQuery is a fast, concise, JavaScript Library that simplifies how you write your web pages.

Cool Online Tools

Online Tools

Photo Credit: Stavros Markopoulos

20. Pipe Bytes
Send files of any size through any Web browser. No software to install, private and the recipient can start downloading while you’re still uploading

21. PHP FTP Synchronizer
Free program to update your website from local files

22. Dummy Text Generator
Generate text by number of paragraphs, words, bytes or lists

23. UTF-8 decoder
Unicode Decoder

24. CSS Tidy
Open source CSS parser and optimizer

25. HTML Tidy
Open source utility for tidying up HTML

26. FireFTP
Free, secure, cross-platform FTP client for Mozilla Firefox

27. FileZilla
Free FTP client and FTP server

28. Dust-Me Selectors
Firefox extension that finds unused CSS selectors

29. ColorZilla
Get a color reading from any point within Firefox

30. FireFox IE Tab
Run IE inside Firefox

31. Font Sizer
Let visitors change the font size on your site. XHTML, CSS, and PHP source available

32. Recaptcha
Captcha helps prevent automated abuse of your site, ensuring only humans perform certain actions; free

33. Super Screenshot
Take a full sized screenshot of any Web page

34. Web Site Thumbnails
Get thumbnails of any Web site

35. Back Orifice
A remote admin system that enables a user to control a computer over a network

36. CoPilot
Remote control another computer – free on weekends, otherwise $5 for 24 hours

Documentation and Reference

Documentation and Reference

Photo Credit: Perreira

37. Ajax: A New Approach to Web Applications
The ultimate AJAX introduction

38. Cheat Sheet Round Up
Your one stop shop for all cheat sheets including: Actionscript, Ajax, Apache, ASCII, ASP, C#, CSS, CVS, C++, Django, Firefox, Google, HTML/XHTML, Java, JavaScript, LaTeX, MySQL, Perl, Photoshop, GIMP, PHP, Python, Regular Expressions, Ruby, Unix, Linux, Weblogs, Windows, XML.

39. Quick reference
Searches for references on C, C++, CSS, HTML, HTML DOM, Java, JavaScript, MySQL, Perl, PHP, Python, and Ruby

40. Got API
Easily search sites for API documentation

41. CSS Basics
Cascading Style Sheets made easy

42. The Ultimate CSS Resource

43. RSS Specifications
The authority on RSS - from Harvard

44. RSS Best Design Practices and Icons
All things RSS including free icons

45. Go To and Learn
Free video tutorials on Flash

46. Optimize Your PHP code
40 Tips to optimize your PHP code

47. Optimizing MYSQL queries
10 Tips to optimize MYSQL queries

48. How to Create a Dynamic BlogRoll
Using Feedjumbler - it takes 5 minutes

Testing

Testing

Photo Credit: Sebastian Bergmann

49. CSS Validation
At W3C

50. HTML/XHTML Validation
At W3C

51. HTML Validator
Firefox extension to validate your HTML (as used within http://validator.w3.org/)

52. Link Checker
Checks for broken links in your HTML pages

53. Firebug
Edit, debug, and monitor CSS, HTML, and JavaScript live in any Web page

54. Gray Bit
Online testing tool; convert a full color page into grayscale to visually test contrast

55. Cross Browser Compatibility Testing
Check your site with multiple browsers on a single machine

56. Screen Sizer
Check out your site in different screen sizes

57. Feed Validator
If you’ve ever noticed invalid characters or XML markup in content items, check your feed for validity problems.

Windows

Windows

Photo Credit: Marius

58. Windows Unlocker
Tells you the application that is stopping you from deleting a file

59. Windows Dependency Walker
See which DLLs are required for Windows applications

60. Pending Moves
Show files will be updated when you next restart Windows

61. Process Explorer
View active processes – Task Manager on steroids

62. Process Monitor
Monitors file system, registry and process/thread activity

63. Regulazy
Visual regular expression builder

64. WinDirStat
Display size of files and folders graphically

65. wget for Windows
Gets a HTML resource (HTML, image, document, javascript, css etc)

66. WinSnap
Takes a snap shot of your screen ($19.90)

Converters

Converters

Photo Credit: AndiH

67. Convert HTML to RSS
Generate an RSS feed for almost any Web page.

68. Convert RSS to HTML
Creates a widget displaying a specific RSS feed in HTML.

69. Binary to Base64
Create data streams for embedding images (or any type of file) in (X)HTML, CSS and XML

70. HTML To JS/PHP/Perl Converter
This tool will convert normal HTML code to a script based language such as JavaScript, PHP or Perl

71. Text to Voice
Create an MP3 of a voice reading your text

72. Free PDF online conversion
Converts various files (DOC, PUB, RTF, XLS, PPT, HTML, JPG, PNG, BMP, TIFF, WMF, EMF, GIF etc.), to PDF online, then e-mails you the PDF

73. Web 2 PDF
Allow your visitors to create PDFs of any Web page

74. Text to Hex converter
Write your name in hex

Graphics

75. YotoPhoto
Search engine for royalty free images (over 250,000 indexed)

76. Background Image maker - http://lab.rails2u.com/bgmaker/
Create background images online with this quick and easy tool

77. Iconaholic
Lots of great free icons

78. Animated GIFs
Generate and preview animated GIFs, then download

79. 216 Color Webmasters Palette
Web Safe colors for webmasters

80. ASCII Art
The original Web Art

81. ASCII Generator

82. Image to ASCII
Convert images and text to ASCII

83. GIMP
GNU Image Manipulation Program

84. Inkscape
Open Source vector graphics editor, similar to Illustrator and CorelDraw

85. Create Web 2.0 Badges (image –png)
Ajax lessons show you how to create a shiny Web 2.0 badge in eight easy steps

86. Color Scheme Generator

87. Smashup Graphics
Smashups to create logos, backgrounds, buttons and menus.

88. IconFinder
Great looking resource with easy to identify licensing information.

89. Tabs Generator
Creates tab buttons on demand.

Site Analytics

Site Analytics

Photo Credit: Wessex Archaeology

90. Who is the Owner?
Find out who owns a Web site quickly

91. Google Banned Tool
Quick way to find out whether your URL is in Google’s banned database

92. Crazy Egg
Variety of products to see what people are doing on your site using a heatmap or just plain hard data. Pricing plans start with free accounts that let you track up to 5000 visits per month and four pages, up to Pro an offering for $99 per month that lets you track 250,000 visits per month.

93. SiteScan
A free way to ensure that your website is configured properly for Google Analytics.

94. Reinvigorate’s Snoop
Real Time Web Analytics - free for PC and Mac. Greater flexibility than Google Analytics

95. PopURI
At-a-glance link popularity of any site based on its ranking (Google PageRank, Alexa Rank, Technorati etc.), social bookmarks (del.icio.us, etc), subscribers (Bloglines, etc) and more

96. Quantcast
Demographics for your site

97. Social Meter
Scans popular social websites to analyze your social popularity.

98. StatCounter
Highly configurable hit counter and real-time detailed web stats. Useful for European Web sites.

99. Clicky Web Analytics
Web analytics - nicely organised and oh so pretty.

WordPress

100. How to create a WordPress theme
A 16 part series on how to build a WordPress theme from whoa to go

101. Highlight Author Comments
Matt Cutts shows you how to change the color of your own comments so they stand out. For WordPress

102. 100 High Quality and Free WordPress Themes
Smashing Magazine has downloaded, installed, and tested hundreds of themes; these are their top 100 picks. Whether you are after design inspiration or coding solutions, this is the place to start

Online Storage

Storage

Photo Credit: Kevin

103. Box
Up to 1GB free storage but monthly bandwidth restricted to 10GB, file size restricted to 10MB

104. Xdrive
Up to 5GB free storage. AOL sign-up required.

105. Humyo
Up to 30 GB [25 GB media (phots/music/videos) and 5 GB non-media files]. BUT files are deleted if no login on the account within 90 days.

106. Orbitfiles.com
Up to 6GB free storage, but monthly bandwidth restricted to 20 GB, file size restricted to 100 MB.

107. GigaSize
Unlimited storage, but file size is limited to 600 MB, and files are deleted after 45 days. Unspecified download limits apply. Awful ads!

108. DropBoks
Up to 1GB free storage, but file size is limited to 50MB.

109. Get Gspace
Use Google’s GMail 2 GB storage as your own private online storage with this Firefox extension.

110. WordPress.com
Want another 3GB of free online storage? Why not make a private blog and use the space for your files!

Miscellaneous

Fun Stuff

Photo Credit: Robin Hutton

111. Map-o-net
Shows you where you lie in the structure of IP addresses

112. Domain Hacks
Helps you find domains which are the combination of unusual TLD, directories and subdomains. For instance, http://l.id can be registered (from Indonesia)

113. Scratch – programming for kids
Want your little person taking over the family web development business? Let them play with Scratch. Developed by MIT

114. Internet World Stats
Comprehensive statistics about the Internet and Web

115. Feed Journal
The next generation newspaper, FeedJournal turns your RSS feeds into a newspaper formatted PDF so you can print it out and read it anywhere - free

Useful Sites

116. Windows Guides

Fun Stuff

You’ve made it this far - so a little silliness for your viewing pleasure - enjoy!

117. Music using ONLY sounds from Windows XP and 98! (approx. 2 mins)

118. Mac Parody (approx. 3 mins)

119. Ze Frank’s Punctuation Substitution (approx. 2 mins)

120. Wes Borg-Internet Help Desk Live (approx. 6 mins)

121. BlueScreen of Death Screen Saver v3.2

I’d love to see this list grow over time; get rid of defunct listings and add new and useful ones as I come across them, so if you know of any that should have been included (or if you think some are really awful) please let me know, and I’ll keep editing. With your help, I think this could be a great resource for tons of folk!

Sphere: Related Content

Using Stylesheets to Print Differently

Stylesheets are used to control the appearance of HTML pages, can also be used to allow you to change the appearance of a page when it is printed.

Why is this useful?  If, for example, you have a navigation panel on the left hand side of your page, you can hide this panel when you print, so the printout contains the useful information only and takes advantage of the full page width, which generally means it can be printed on fewer pages.

Normally stylesheets are used within a HTML page as follows:

  <link type='text/css' rel='Stylesheet' href='/category/dev_stuff/sytles.css'>

To use different stylesheets for the screen and printer, you use the media attribute as follows:

  <link type='text/css' rel='Stylesheet' media='screen' href='/category/dev_stuff/screen.css'>
  <link type='text/css' rel='Stylesheet' media='print' href='/category/dev_stuff/printer.css'>

In this case, you would need to duplicate all the common styles in both files, so if there are a lot of common styles, you may want to have smaller stylesheets which just contain those styles which you want to be different on the screen to how they appear on the printer.  So, a better strategy would be:

  <link type='text/css' rel='Stylesheet' href='/category/dev_stuff/common.css'>
  <link type='text/css' rel='Stylesheet' media='screen' href='/category/dev_stuff/screen.css'>
  <link type='text/css' rel='Stylesheet' media='print' href='/category/dev_stuff/printer.css'>

The  different media types include handheld, projection, braille, and more, so you if your web pages appear in different devices, you can customize the appearance to better suite the device.

Sphere: Related Content

Find out why you can’t delete a file on Windows

Cedrick Collomb has a handy utility called Unlocker which will tell you which processes are preventing you from deleting a file or folder.

If a delete fails, you get the generic access denied error message from Windows; however, if you have Unlocker installed, then it will popup and display the processes which have a lock on the file or folder.

For example, attempting to delete C:\Windows\System32\user32.dll (yes this would be a dumb thing to do) will display the following list of processes (which will be almost everything running on Windows):

Unlocker displaying list of processes which have a lock on C:WindowsSystem32user32.dll

Unlocker allows you to force the file to be unlocked, or even kill the processes; however, I prefer to find out which processes are preventing the deletion and closing them myself.

One common issue, is that you have an editor active, but no files currently being edited, and you can’t delete the folder which contained files you just recently edited.  The editor’s current directory is the one you want to delete, so Unlocker will show the editor process in its list.  So you know to exit the editor so you can delete the folder.  An alternative is to open a file from a different folder within the editor, so the current directory changes to something other than the folder you want to delete (or ones of its children).

You can run Unlocker on a file before you attempt to delete it.

It would be nice to have a Close button within Unlocker, which would politely ask the application to close, much the same way you would select Close from the system menu when you right click on the system tray’s entry for the application.

Sphere: Related Content

Free loading/waiting animated gifs

Found this Web 2.0 site which creates animated gifs.

bar-circle.gifbig-flower.gifindicator-big-2.gifbig-roller.gifradar.gifcircling-ball.gifbouncing-ball.gif

(Excuse the borders around the images which is an issue with the WordPress theme)

You specify:

  • Style
  • Background color (any) or transparent
  • Foreground colour (any)

It calls itself the “ Ajax loading gif generator“; however, it is ironic that it doesn’t behave like an Ajax based Web 2.0 (is this redundant) Web site, since pages are reloade; nor does it remember the transparency setting.

Anyways, free, fun and useful - win, win all around.

Sphere: Related Content

Implementing “Sent To Mail Recipient”; in your Application

I wanted to be able to easily email a file from a utility I wrote, and thought “wouldn’t it be so much easier if I could incorporate the ‘Sent To Mail Receipient’ functionality available within Windows” so I didn’t have to worry about which email application is actually installed.  I know this will typically limit this to either Microsoft Outlook Express or Microsoft Outlook, but at least I don’t have to worry about the mechanism required to create an email with an attachment which is yet to be sent.

So the following is the C++ code which implements createEmailWithAttachment().

The GetUIObjectOfFile() routine is taken from Raymand Chen’s blog where he posted How to host an IContextMenu, part 1.

The droptarget code was taken from a discussion thread which was incomplete.

Unicode and non-unicode variants are supported.

HRESULT GetUIObjectOfFile(HWND hwnd, LPCWSTR pszPath, REFIID riid,
                          void **ppv)
{
  *ppv = NULL;
  HRESULT hr;
  LPITEMIDLIST pidl;
  SFGAOF sfgao;
  hr = SHParseDisplayName(pszPath, NULL, &pidl, 0, &sfgao);
  if (SUCCEEDED(hr))
  {
    IShellFolder *psf;
    LPCITEMIDLIST pidlChild;
    hr = SHBindToParent(pidl, IID_IShellFolder, (void**)&psf,
                        &pidlChild);
    if (SUCCEEDED(hr))
    {
      hr = psf->GetUIObjectOf(hwnd, 1, &pidlChild, riid, NULL, ppv);
      psf->Release();
    }
    CoTaskMemFree(pidl);
  }
  return hr;
} 

#ifdef DEFINE_GUID
#undef DEFINE_GUID
#endif 

#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
        EXTERN_C const GUID name
                = { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } } 

DEFINE_GUID(CLSID_SendMail, 0x9E56BE60, 0xC50F, 0x11CF, 0x9A, 0x2C, 0x00,
            0xA0, 0xC9, 0x0A, 0x90, 0xCE); 

static HRESULT createEmailWithAttachment(LPCTSTR pszFileName)
{
  IDataObject *pDataObject = NULL;
  IDropTarget *pDropTarget = NULL;
  LPCWSTR pwszFileName = NULL;
  bool bCreated = false;
  HRESULT hr; 

#ifdef UNICODE
  pwszFileName = pszFileName;
#else
  WCHAR *pwszBuffer = NULL; 

  int nLength = MultiByteToWideChar(CP_ACP, 0, pszFileName,
                                    strlen(pszFileName), NULL, 0);
  if (nLength DragEnter(pDataObject, MK_LBUTTON, pt, &dwEffect);
      if (SUCCEEDED(hr))
      {
        hr = pDropTarget->Drop(pDataObject, MK_LBUTTON, pt, &dwEffect);
        if (SUCCEEDED(hr))
          bCreated = true;
      }
      pDropTarget->Release();
    } 

#ifndef UNICODE
    free(pwszBuffer);
#endif // UNICODE 

    pDataObject->Release();
  } 

  return hr;
}
Sphere: Related Content

Microsoft giveth with one hand and taketh away

Microsoft Office 2007 introduces a whole lot of new features - revamped UI, new file formats etc.  However, one thing is missing, which is support for the Outlook protocol (outlook://).

Developers wanting to open emails from other applications could use the Outlook protocol to get Microsoft Outlook to display them.  For example, outlook:00000000AEB50BC0928BD511A2700000E8D73A91C4A56101.

This is all well for Microsoft Outlook XP and 2003 (not quite sure about 2000); however, for Microsoft Outlook 2007 Microsoft have decided to no longer support it. 

Upgrading to Outlook 2007 will remove the Outlook protocol registry details which was setup by the previous version of Outlook.

Information about this is available [buried] in http://support.microsoft.com/kb/929590, which says:

Known issues when you develop custom solutions for Office Outlook 2007

The Outlook protocol no longer works outside Outlook

The Outlook protocol (Outlook://) has been changed. This protocol will only
work when you use it in Outlook. You can use this protocol on a folder home
page, on the Web toolbar, or in the body of an Outlook item.

Now registration of the Outlook protocol is straightforward, and results in outlook.exe being invoked with the /select command line argument with the value of the Outlook protocol following.

To reactivate the Outlook protocol with Outlook 2007 installed, simple copy the following into a .REG file and double click on it from Windows Explorer.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\outlook]
“URL Protocol”=”"
@=”URL:Outlook Folders”

[HKEY_CLASSES_ROOT\outlook\DefaultIcon]
@=”C:\\Program Files\\Microsoft Office\\Office12\\OUTLOOK.EXE,-9403″

[HKEY_CLASSES_ROOT\outlook\shell]
@=”open”

[HKEY_CLASSES_ROOT\outlook\shell\open]
@=”"

[HKEY_CLASSES_ROOT\outlook\shell\open\command]
@=”\”C:\\Program Files\\Microsoft Office\\Office12\\OUTLOOK.EXE\” /select \”%1\”"

If Microsoft Outlook  2007 is not installed in default folder “C:\Program Files\Microsoft Office\Office12″ you will need to update the above accordingly.

Obviously this will only work whilst Office 2007 still supports the /select command line argument.

Also, in this day and age of automatic updates, Microsoft could, if they wished, revoke full support of the Outlook protocol at any time.

This workaround will give you some breathing space for an alternative solution to be developed.

Sphere: Related Content

Developer Toolbar for Microsoft Internet Explorer

Microsoft has released a developer toolbar for Microsoft Internet Explorer which may be useful to SEO folk for ad-hoc analysis of individual pages.

For example, it allows the details of the commonly used description and keywords meta tags without having to troll through the raw html source code.

Tooltips are used to allow the all of the content to be displayed. 

meta description tooltip
 
It is interesting to note that MS capitalize the tag names within the toolbar even though lowercase is the strict W3C definition.

A suggestion for MS with respect to visually distinguishing between the different meta tags is to include the name value within the navigation tree on the left hand side.  For example, instead of “<META>” you would see “<META name=’description’>”.

The other common SEO attribute is the title tag, but viewing the actual contents is confusing at first as nothing is shown when the title tag is viewed even though one is set.

To view the value of the title tag you need to use the innerText attribute of the tag, which is done by checking the “Show Read-Only Properties”.

title tag innerTag
 
Another suggestion for MS would be for the innerText attribute to always be displayed.

Without going into too much detail, there are a lot of interesting things you can do with the toolbar:

1. Easily resize Internet Explorer to 800×600, 1024×768 etc to see what your page looks like for the resolutions you want to support.
2. Easy access to W3C validation tools and link checker, and accessibility reports.
3. Ability to turn off CSS – which is interesting for no other purpose that to see how awful a page looks.
4. Table and div tags etc can be outlined on the screen.
5. You can change the class of a tag and see its effect immediately before you edit the change within the actual page file.  All other read-write attributes can be changed also.
6. The toolbar can annotate the tag to image sizes, link paths, etc.  For example, viewing link paths replaces the original text of:

Original page contents

With the following:

Page contents with show links
 
7. And lots more

Download, install and give it a spin.

Displaying the toolbar is less than intuitive in my mind, which is done by selecting the >> to show additional items.

Show toolbar

Sphere: Related Content

Sangers and Beer at the Googleplex

If you’re an engineer and live in Silicon Valley, Google is inviting you to its G’day Google night on May 8, to learn about all the cool things they are doing in Australia.

Neat huh?  Until you get to the added bonus:

“Australian food and drink — I’m talking Vegemite sangers, yabbies, meat pies, Australian beer, more   Australian beer, and wine”

Wow!  Sangers.  Really?  And lots of beer? Well…no doubt about it, I’m IN!

C’mon Google, give me a break.  Don’t fall into the trap so many other American companies have if you want credibility with the folk down under…it’s lame.

Here’s a clue:

Slang + Australians + Google?*
* Pay particular attention to number 6.

Sphere: Related Content

Next Page »