Archive for November 2007
Five steps for creating a transparent user control
November 29th, 2007 — 04:30 amGuest post from Eyal Ron:
After much testing this is the correct formula for a truly transparent user control:
- Derive from Panel rather then UserControl.
- Override the OnPaintBackground function:
protected override void OnPaintBackground(PaintEventArgs pevent)
{
//do nothing
} - Override the OnMove function:
protected override void OnMove(EventArgs e)
{
RecreateHandle();
} - Override the CreateParams property:
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle = 0×00000020; //WS_EX_TRANSPARENT
return cp;
}
} - Override the OnPaint function:
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;//Do your drawing here
.
.
.g.Dispose();
}
Special consideration for the ThreadAbort exception
November 21st, 2007 — 11:07 pmAs 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.
Acer’s localized international warranty
November 21st, 2007 — 10:46 pmI 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 amThe 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”.
From the people who brought you "Catastrophic Error"
November 18th, 2007 — 02:33 amNow comes another great error dialog:
“The Operation completed successfully” error dialog.
Create the ultimate business card
November 17th, 2007 — 12:03 pmDuring 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?
