Archive for November 2007


Light reading at the traffic light

November 29th, 2007 — 10:59 pm

In case you were wondering, the book in the picture is the bible.

2 comments » | Amuzing

Five steps for creating a transparent user control

November 29th, 2007 — 04:30 am

Guest post from Eyal Ron:

After much testing this is the correct formula for a truly transparent user control:

  1. Derive from Panel rather then UserControl.

  2. Override the OnPaintBackground function:
    protected override void OnPaintBackground(PaintEventArgs pevent)
    {
    //do nothing
    }
  3. Override the OnMove function:
    protected override void OnMove(EventArgs e)
    {
    RecreateHandle();
    }
  4. Override the CreateParams property:
    protected override CreateParams CreateParams
    {
    get
    {
    CreateParams cp = base.CreateParams;
    cp.ExStyle = 0×00000020; //WS_EX_TRANSPARENT
    return cp;
    }
    }
  5. Override the OnPaint function:
    protected override void OnPaint(PaintEventArgs e)
    {
    Graphics g = e.Graphics;

    //Do your drawing here
    .
    .
    .

    g.Dispose();
    }

4 comments » | Winforms

Special consideration for the ThreadAbort exception

November 21st, 2007 — 11:07 pm

As a rule, I never want to see an unhandled exception crashing my application with the .Net error dialog and without logging the error.
Therefor I always hook both the AppDomain.UnhandledException and the Application.ThreadException events to catch those exceptions, log them, and close the application gracefully.

Turns out I overlooked one small detail - the ThreadAbort exception, raised by a call to the Thread.Abort method. It’s not a best practice to use it (you should let the thread shut down itself), but it may be used by a 3rd party code, so it can’t be ignored.

However, since it’s not an actual exception there is no logic in shutting down the application due to this exception.

Comment » | Winforms

Acer’s localized international warranty

November 21st, 2007 — 10:46 pm

I have been looking to buy a notebook computer for some time now.
Someone told me about a friend of his who bought a new Acer notebook during a trip to the U.S. as a temporary replacement for his malfunctioning computer, and now he wants to sell this new notebook computer (as his old computer was fixed).
It seems he got it in the U.S. with an international warranty.

So I called Acer’s locale dealer (Newpan) to check this out.
Turns out the Acer management dictated that an Israeli who buy a notebook in the U.S. will not have warranty in Israel.
In other words: If you buy a computer in the U.S., you get international warranty as long as you use it inside the U.S.

Comment » | Uncategorized

Validation of a NumericUpDown control

November 18th, 2007 — 06:59 am

The NumericUpDown control has a built-in validation:

  • Values smaller than the minimum are replaced by the minimum
  • Values larger than the maximum are replaced by the maximum

This may lead to a situation in which the user entered an invalid value and pressed the form’s “OK” button, leading to saving of a value completely different than the one entered with no notification.
To prevent this, enter your own validation code into the validating event (using the “Text” property instead of “Value”), and if the validation fails set the e.Cancel argument to “true”.

2 comments » | Winforms

From the people who brought you "Catastrophic Error"

November 18th, 2007 — 02:33 am

Now comes another great error dialog:
The Operation completed successfully” error dialog.

1 comment » | Amuzing

Create the ultimate business card

November 17th, 2007 — 12:03 pm

During the David Platt’s lecture I received a business card from him.
The card’s title is “Rolling Thunder computing” (his company), and his title is: “Supreme and Exalted, Dictator-for-life
I think that’s the best job title I have ever seen on a business card, and even better - it makes people pause and remember him because it’s unusual.
Do you have special titles on your business cards?

Comment » | Jobs

« Previous Entries