Tuesday, 13 November 2007

System.Windows.Form.MessageBox control is not extensible

Windows.Form.MessageBox control is not extensible since it is provided by the operating system. It is a static a class with private constructor. However, we could do something to customise this class by digging deep into Win32 API i.e., a 'hook' could be built to listen to the window events related to creating and activating the MessageBox, etc.

References:
http://msdn.microsoft.com/msdnmag/issues/02/11/CuttingEdge/default.aspx#S9
http://www.thescripts.com/forum/thread446492.html

What are your work/life dreams? Set some goals today

When it comes to goals, bigger is not necessarily better. Understanding the difference between a goal and dream is about understanding what's achievable now — and how to break down a technicolour vision into manageable steps.

''I like thinking big. If you're going to think anything, it might as well be big.''

So said Donald Trump, the man with a nice looking property portfolio (sometimes overshadowed by his questionable-looking hair). And most people would probably assume he was right. After all, nobody ever built a 58-floor high-rise in Manhattan by thinking small.

Sometimes, though, thinking smaller is precisely what's necessary — particularly when it comes to setting goals. ''You might have the ambition to become the CEO of your company,'' says Narelle Milligan, a professional member of the Australian Association of Career Counsellors. ''But when you're the receptionist it can feel like a pipe dream. Long-term goals need to be broken down so that they're more manageable.''

Simply sitting at your switchboard burning with desire to take over the board won't get the job done. Instead, work out how you're going to get there. What steps do you need to take to get to the next level? Is there a course you can take, a mentor you can approach, a promotion you can secure?

''Goals are both short- and long-term,'' says Milligan. ''The short-term ones are the steps to get us to the bigger picture.''

In his book You Inc, real estate guru John McGrath writes of the importance of dumping the ''tomorrow fantasy''.

''Some people talk a lot of 'gonna','' he says. ''You know, they say, 'One day I'm gonna do this', or 'Next year I'm gonna do that'. The reality is, if you're not doing it now, you're probably not going to do it. So do it now — start with a small step today.''

But how?

''Goal setting is not that difficult,'' says Milligan. ''All you need is a quiet space and something to write on, or your computer.''

Now reach inside yourself and think about what you want for yourself in your life — your whole life, not just your career.

''The modern approach to career development is to try to integrate your work into your life,'' says Milligan. ''The income we get is a means to an end. I would strongly recommend setting life goals — work is just one subset of that.''

Other areas you might consider are finance, relationships, health, spirituality, study, travel … the whole shebang. How you prioritise your list is up to you.

''Dream about where you would like your life to be, translate those dreams into goals, and then work out the actions required to achieve the goals,'' says McGrath.

If your dream is to work in a different industry to the one in which you're currently stuck, your short-term goal might be to initiate contact with someone who works in that industry. Your first step to achieving that goal is to ask your network of friends if anyone knows anyone you could ring for a chat. See, you can do that!

If it were that easy, wouldn't everyone do it?

''We do need some self-insight to set attainable goals,'' says Milligan. ''While I'd never underestimate human determination and spirit, we're not all going to be world-class ballet dancers, for instance.''

One of the criteria that defines a goal is that it's achievable — otherwise you're back in dream territory again. But if your goal is to be Margot Fonteyn and your genetics say that you're more in Lauren Jackson territory height-wise, you may need to assess the reality of your aspirations. Which is not to say that you can't massage your goals as you go.

''If it's impossible to be a ballet dancer, go to dance classes, watch the ballet, or get involved in the organisational side of a ballet company,'' says Milligan.

I feel I'm getting nowhere

It doesn't always follow that if you work hard you'll reach your goals. As John Lennon said: ''Life is what happens when you're busy making other plans''. But don't let that put you off.

''Life deals us circumstances over which we have no control,'' says Milligan. ''Goals must be flexible and they need to be reviewed regularly. I'd look at them annually, and every time there's a big change in your life, like graduating uni, marriage, children, moving house, redundancy …''

Look at your skills, where you're going, whether you're on track to achieve what you want in life — because it does change. The goal you had at 21 to be chief executive at 30, might have changed by 30 to become something entirely different. Like a yoga teacher. Or a property tycoon — with fabulous hair.
By Allison Tait, October 2007
From: http://yourlifeworks.ninemsn.com.au/article.aspx?id=306383

Monday, 5 November 2007

How do I convert a string to a byte array and vica-versa in VB.NET and C#?

Convert String to Byte[]

' VB.NET to convert a string to a byte array
Public Shared Function StrToByteArray(str As String) As Byte()

Dim encoding As New System.Text.ASCIIEncoding()
Return encoding.GetBytes(str)
End Function 'StrToByteArray

// C# to convert a string to a byte array.

public static byte[] StrToByteArray(string str){
System.Text.ASCIIEncoding encoding=new System.Text.ASCIIEncoding();
return encoding.GetBytes(str);
}

Convert Byte[] to String

' VB.NET to convert a byte array to a string:
Dim dBytes As Byte() = ...Dim str As StringDim
enc As New System.Text.ASCIIEncoding()
str = enc.GetString(dBytes)

// C# to convert a byte array to a string.

byte [] dBytes = ...string str;
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
str = enc.GetString(dBytes);

Ref.: http://www.chilkatsoft.com/faq/DotNetStrToBytes.html