DotNet Windows Form Image Transparency

Recently during a project I had a need to overlay an image on a windows form in order to indicate a status of inability.  This image had a semi-transparency quality as well as a full transparency background.  To my dismay, the semi-transparency rendered in full color and the full transparency background seemed to inherit the parent form, but not show the controls behind it as one would expect.

After sometime of researching the issue, I came to a determination that what I was trying to do could only be done in web development (HTML).  From my research I had assembled some ideas in how to make transparencies work.   I took ideas from several sources and came up with the following.

Step By Step ( see Sample Code )

1. Create a class that extends System.Windows.Forms.Control
2. Place code from sample cod
3. Compile Project
4. Add new control to the Form ( remember this is for a windows application )
5. Set Background Image

Sample Code


protected override CreateParams CreateParams
{
     // Make window transparent
     get
     {
          CreateParams cp = base.CreateParams;
          cp.ExStyle |= 0x20;  // WS_EX_TRANSPARENT return cp;
     }
}

protected override void OnPaintBackground(PaintEventArgs pevent)
{
// Do not paint the background
}

protected override void OnPaint(PaintEventArgs e)
{ 
     // Paint background image 
     if (BackgroundImage != null)
     {
          Bitmap bmp = new Bitmap(BackgroundImage);
          bmp.MakeTransparent(Color.White);
          e.Graphics.DrawImage(bmp, 0, 0, Width, Height);
     }
}

Note:  When you overlay an image – even transparent, you may see the controls behind, but you will not be able to access them.  This is true in both web and windows development.

8 Search Engine Friendly Web Design Tips

  1. Make meta tags relevant to the web page – not specifically to the site
  2. Add ALT attributes to images and make sure it describes the image
  3. Add Title attributes to links and make sure it describes the link and its function
  4. Have content that changes periodically – blog or news feeds can add dynamic and relevant content
  5. Flash-based content and sites with a lot of images are difficult
  6. Use the Google / Yahoo site manager tools
    ( http://google.com/webmasters/tools ) or ( http://siteexplorer.search.yahoo.com )
  7. Use a good stat services like StatCounter.com or Google Analytics
  8. Keep to W3C standards ( http://validator.w3.org )

    Note: A good web developer will not charge extra for most of these points.  A site is worthless unless setup properly for search engines.

Internet Explorer Crashes On ActiveX Plug-ins

I was recently trying to download some development tools from MSDN where a Microsoft File Download Plug-in is used.  Every time I clicked the download link, the file download manager tried to launch and then crash the Internet Explorer session.  I had also seen this with some open source remote help desk tools, but figured it was a bad update on the plug-ins.

Well the answer was, Microsoft is trying to manage your memory so to prevent attacks on your computer.  To install the plug-ins, you need to :

  1. Go to the Tools menu
  2. Click on Internet Options
  3. Click on the Advanced tab.
  4. Go to the Security Section
  5. Uncheck the “Enable memory protection to help mitigate online attacks *”
  6. Click Apply
  7. Click OK

Close Internet Explorer and then try your plug-in that previously crashed your Internet Explorer.  If you are not a local administrator, you will have to contact your IT department to do this for you.

Note:
When your plug-in is installed or you have finished your activity, re-enable the “Enable memory protection to help mitigate online attacks *” option as extra protection.  I and Microsoft do not recommend surfing without this option enabled.

Checking Active Process on Sql Server

I have needed to monitor the SQL servers a little more than usual. I am mostly concerned about memory and CPU usage. By properly setting our program names in the SQL connection string, I am able to find the offending applications a little easier. There are times, that I set the application and routine in the connection string when the offending process is not so obvious.

Here is my script that I use to view the offending SQL processes

SQL Query using SysProcess

use master
declare @memlimit as int, @cpulimit as int
set @memlimit = 100 — Memory Filter Limit
set @cpulimit = 200 — CPU Filter Limit
select spid, login_time, last_batch, hostname, program_name, memusage,cpu
from sysprocesses
where ( memusage > @memlimit or cpu > @cpulimit )

Once I have a list of offending processes, I seek and fix the code has the issue. If the process is a closed application like the BlackBerry® Mobile Data Server Connection Service, I check for updates or in rare cases set up a scheduled task to restart the service.

I am back – Whoo Whoo!

Despite the Blogger’s removal of FTP support, I have been able to continue using my blog. I have created my own ATOM feed interpretor. It was pretty easy to do in ASP.NET. Look for my future blog on how to perform the integration. Thanks to all who follow me and thanks for your patience.

~ Andrew

Blogger Removes FTP support

Well, it has happened. Blogger is pulling its FTP support. This means that this is my last post of this kind. I will be updating my blog portion of my site with a different technology unless blogger creates something new.

If this portion is down, it is because blogger removed its service that I used.

Sorry for any issues.

8 Firefox Plugins

Tonight I have assembled a list of 8 Firefox Plug-ins that either make my development life easier or simply add a little flair to my web surfing.  Each plug-in is my own choice and is not a paid endorsement.  These are all free.

IE TAB
Emulates the Internet Explorer rendering engine
Website

InterClue
Preview links before clicking on them
Website

Colorful Tabs
Colors tabs to make each unique
Website

ColorZilla
Advanced eyedropper that allows you to select colors from web pages
Website

Cooliris
3D wall for searching and viewing archives
Website

Download Helper
Allows you to download your favorite media including YouTube videos
Website

FireBug
Web Development Tool
Website

FireShot
Screen shot of the current page. Allows user to add annotations easily.
Website

HTML Centering DIV Tag ( DIV Element )

The easiest way without JavaScript to center a DIV tag is to use a style tag or css that resembles the following.

style=’padding:5px;width: 400px;height:200px; margin-top:-100px; margin-left:-200px; left:50%;top:50%; border:outset 1px #ccff99; background-color:#ccff99;position:absolute;font-weight:normal;’

Sample Image

I am not the WhozaDog.com creator

There has been a rash of discussions about “a” Andrew Pallant who is the creator the of WhozaDog.com website.  I am not that same person.  While we share the same name, we do not share the same outlook on life.  Please be aware that there is more than one person with the same name.  I am going on record to say I am not in anyway associated to the Andrew Pallant who created the WhozDog.com site or associated to the site is self which is Australian based.

Rippers

People from all over the world have used software to steal or copy websites.  If you are using statcounter.com you may see in the browser column “Ripper” or “Rippers 0” or something in a similar naming convention.  To prevent some of this activity you can try the following javascript code that I have found on the statcounter.com forums.

var browser_type=navigator.appName
var browser_version=parseInt(navigator.appVersion)
if (browser_type==”Rippers”&&browser_version>=0)
window.location.replace(“http://www.google.com”)

It appears to work for me.