Sunday, July 22, 2007

Skip 'blue' welcome screen on Windows XP

If you are using Windows Xp and want to get rid of the blue "Welcome" screen that shows up at startup (prompting you to select the correct user account and enter the password, if any), then this post can be useful :-) One reason for turning off this feature is that you can turn on your PC, and come back after some minutes and you are right on the desktop (ready for use). However, please bear in mind that although you are the sole user of the system, it is not recommended to do so as it simply means you are disabling the basic security feature that the operating system provides. So, be careful!

Pre-requisite:
You have currently logged on windows as Administrator and have admin rights.

Steps
1. Click Start and then select Run,
2. In the Run window, type control userpasswords2, and then click OK button,


A User Accounts windows pops up.

3. Clear the "Users must enter a user name and password to use this computer" check box, and then click Apply.


You will be requested for the username and password of the account you wish to automatically logon as for following reoots of your system.

4. In the Automatically Log On window, type the required information and click OK to close the window.
5. Finally click OK to close the User Accounts window.

At any later stage, you can activate this security feature by following the same steps but recheck the box, at step 3.

Friday, July 13, 2007

Setting transparent color to control's BackColor property

Using C# with .Net Framework 2.0, an attempt to assign a color from the System.Drawing.Color struct to the BackColor property of a window’s control, say a System.Windows.Forms.TextBox, will compile and run successfully.

Snippet 1:
textBox1.BackColor = Color.Cyan;

However, a problem arises when any transparent color (e.g. #00FEF2D4) is assigned to the BackColor property. Upon execution, a runtime exception will be thrown (see below).

Snippet 2:
textBox1.BackColor = ColorTranslator.FromHtml("#00FEF2D4");


On msdn, the following explanation is given:
The BackColor property does not support transparent colors unless the SupportsTransparentBackColor value of System.Windows.Forms.ControlStyles is set to true.

Using the control’s SetStyle() method, this SupportsTransparentBackColor value can be changed. The problem now is that SetStyle() is declared as a protected method and thus, only the control’s class or any child class can call this method.


A quick solution
A possible solution is to create a class inheriting from the control’s class. For example, a TransparentTextBox class can inherit from the System.Windows.Forms.TextBox. Now, the protected SetStyle() method is accessible and the SupportsTransparentBackColor value can be set to true. The ideal place to call the SetStyle() method will be in the constructor of this new class after the InitializeComponent() method calls.



It’s done. Now, as an instance of TransparentTextBox can be created and any transparent color can be set.

Snippet 3:
transparentTextBox1.BackColor = ColorTranslator.FromHtml("#00FEF2D4");

One major concern: do we really want to subclass all controls that probably will need a transparent color? Think...

Hello World

Hello World! Welcome to my new blog - ASHVIN"S TECHNICAL BLOG.

I started a personal blog Ashvin Gunga last year. Then, the idea to have another blog where I can share fwd emails popped in my mind. So, I created another one - FWDs - early this year. Weeks back I thought why not a technical blog - a blog where I can share anything I want related with technology, computing and programming. Now, it's up. I am writing my first post!

Another post that I wrote on my personal blog and talks about the start of this new blog: Ashvin's Technical Blog