31 Oct

Monitor control through


While just taking part in the routine online discussions, I came across this nice article which gave a complete explaination on how to control the monitor through code. Although the article was not meant for first timers, I took some time out to reformat and present the same content here so that anyone could read and understand.

The Monitor can be controlled by the SendMessage API. This is not a .NET API, hence we must delve into P/Invoke and COM Interop.. but dont worry, I wil keep it simple.

To use the interop functionality, you must first include the reference

using System.Runtime.InteropServices;

Then comes the DllImport using which we import the library that contains the SendMessage API – user32.dll

[DllImport("user32.dll")]

Then declare the SendMessage function

static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);

The parameters represent the following data:

  • hWnd – Handle to the window whose window procedure will receive the message. Should be a valid Windows handler
  • Msg – specifies the message to be sent
  • wParam – specifies additional message-specific information
  • lParam – specifies monitor state

hWnd can be set to the current window handle if it is a Windos Forms application using

this.Handle;

But if it is a Console app of a class lib, then you would be better off setting it to -1. (Which sets the handle to the top level window in the system.)

Msg will be set to a predefined value of 0x0112. Even wParam will be set to a predefined value of 0xF170. I shall name the constants so as to avoid confusion.

const int WM_SYSCOMMAND = 0x0112;
const int SC_MONITORPOWER = 0xF170;

lParam specifies the monitor state. It has 3 states – ON, OFF and STANDBY with corresponding values -1, 2 and 1.

Hence a call to turn the monitor off would read something like this in a console application:

SendMessage((IntPtr) (-1), WM_SYSCOMMAND, (IntPtr)SC_MONITORPOWER, (IntPtr) 2);

Download the sample source code here.

31 Oct

Farewell party by RNSIT


Sreenath giving the farewell speech (trying to)

I felt so pathetic after this entire event. I was supposed to speak on my journey through this course of four years. I went on stage and forgot everything and came down by saying just thank you! Hopeless!!

And after that i didnt win any awards for my services to the college. So .. an eventful terrible day. Memorable for a few though.

But anyways it was a great evening, with dinner sponsored by the college and everyone turning up in sarees and blazers. A feast for the eyes.

Sunday May 7, 2006

31 Oct

Hands on Lab – 7th May, RNSIT

RNSIT Hands On Lab

I finally succeded in completing the long awaited and planned .NET hands on lab after cancellation at East Point college. I had to do a lot of running around with bills running up into three thousands.

I had taken entire responsibility of Getting the tickets printed, distributing the tickets, getting the stickers for the CDs printed, getting the CDs, burning stuff on the CDs (almost over 130 cds.) and then the certificates too needed to be designed and printed. And also the design for the CD stickers was also by me.

Finally the day dwaned and everything was cool and smooth with no last minute glitches. Things went compeletly normal and we even sponsored lunch to all the attendees which was previously not on the menu. Thanks to the canteen which was kept open on a sunday.

And on top of that i delivered three sessions all along the day in two different labs which were seperated by a kilometer i suppose. SO i must have done around 100 kms of running around today between labs, office and the canteen.

But what makes me happy is that it went really smooth with the amount of prepartion that we had for the sessions, with a few last minute drop outs by the speakers.

Check out some more snaps here: http://groups.msn.com/bdotnetstudent/handsonlabs.msnw

Sunday May 7, 2006

31 Oct

Rajkumar Demise


Rajkumar Demise

If you expected to see a photo of Rajkumar on this post, well what was more visible than his death actually was the wide spread arson and looting that followed after his death. There is a big political issue to debate on why riots actually happened on the natural death of a great peace loving actor.

It is rumoured that some opposition party leaders, in order to spoil the government’s image, brought in 12 trucks of hooligans from outside sources and dispersed entire cases of liquor to them and asked them to spread out and wreak havoc.

At the end of it all, it was a shame to a city like Bangalore and loss of 8 lives and about 200 Crore rupees. Thats peanuts to win an election.. some politicians would argue.

Sunday April 16, 2006

31 Oct

Imagine Cup 2006

Imagine Cup 2006

Imagine Cup 2006

It was that time of the year when every talented young student in the world waits to clash horns against his peers. It was Imagine Cup time.

Being a Student Ambassador, it was not part of my duty to participate. But if someone told you that I could win $25,000 for my software project which i will submit for my final semester, i would be a fool to let that opportunity slip.

The preparations had begun even before the 7th sem exams since the deadline to submit our abstract fell some where during exam time. But later it got extended and we had ample time to work our our project idea and to present a great picture right from the beginning.

And the results of the Round 1 were awaited with open mouths. There were around 1500 teams participating. Only the top 100 would go through. That is competition!

And we sure did as expected, cleared round 1 in flying colurs. In fact they were so impressed with our idea that they put our name first in the list for Interview for the next round. (Im obviously bluffing here).

We had cleared round 1. But we had 15 days to prepare our entry for Round 2 which required us to submit a presentation with screen shots of our project. And we would be interviewed by a conference call from Microsoft where we would have to explain the project based on the PPT we sent them. It was a tough time!

But the deadline got extended thankfully by a whole week. And i relaxed .. and relaxed big time! In goa!!

We were finally at that stage when we could no longer sleep! It was 7th March and no ground had been covered and our presentation had to be mailed to them before midnight. We knew it was impossible. And on top of that, we had no extra time as our conference call was scheduled the next day itself. We sat through the night and prepared our presentaiton and finally mailed it at 5-30AM. And we wrote a cover letter apoligizing for the delay.

The conference call was scheduled at 5 PM. I had been to GTRE in the morning to discuss our project work there. On my way back, i picked up the unused cordless phone from my grandpa’s place which had a speaker phone. I had asked all my teammates to be at my place half hour early so that we can prepare our presentation. And the phone rang at exactly 5!! Probably people at Microsoft do not follow IST!

WE made a blunder of a presentation. It was our inexperience and un-preparedness that weakened our presentation. But as a whole we covered everything and ended the call on a good note. Hopefully we may reach the top 10!

But this wasnt the only way to participate in the Imagine Cup – It had a total of 6 invitationals in which Software Design was this one. Registration for all invitationals was free and i registered for all of them, but had no intention of participating. But as time went, i got to know about a few of them and thought that i should give it a try. Most alluring was the Algorithm invitational in which we had to learn NanoBot programming and program a NanoBot to follow a specific path in a limited number of bytes. I spent nights trying to solve it and notched up 9000 points. The results for qualifying for the next round are awaited. Another invitational was the IT Invitational whose first round consisted of an Online quiz which i took and fared badly. I scored a 40 and found that the minimum qualifying mark was 70! The short film too is a good invitational and i want to participate in that too since ive cooked up a good story. Lets see how that goes.

www.imaginecup.com

Thursday March 16, 2006

31 Oct

Code4Bill

Code4Bill

Code4Bill

Maybe it was worth the hype. Launched by Gates himself on his visit to Bangalore. The promos showed off attitude.

The Round 1 of the competition was simple: complex problems with single answers and a strict timer. The results were out the next day and I was pleased to see that I was promoted to the next round. But soon i found out that almost everyone who took the test was promoted.

Then came Round 2. Lesser questions, less time, increased complexity and added competition due to the fact that most had gone thru the first round.

I thought i did well, but you always win some and you lose some. I wasnt promoted to the next level. Thus ended my travel plans to Redmond!!

Thursday March 16, 2006