How to check mouse button status without message handler?

 

We can map WM_LBUTTON or WM_RBUTTON down to know whether user has pressed the left or right button respectively on top of the window or not. But sometimes, we have to know this information while we’re processing other handlers like painting/drawing the window.

#define SHIFTED 0x8000
void GetMouseButtonState()
{
   if ((GetKeyState(VK_LBUTTON) & SHIFTED))
   {
      printf( "Left button is pressed" );
   }

   if ((GetKeyState(VK_RBUTTON) & SHIFTED))
   {
      printf( "Right button is pressed" );
   }
}

Please note that this information is a system wide information. By knowing this status doesn’t mean that the button is pressed on top of your window. For that you will have to know the current cursor position using GetCursorPosition and check if it’s within the Window Rect or not.

You can see the similar keyboard sample at MSDN website. – Using Keyboard Input

 

Importance of a Knowledge Center in an organization

 

I love to cross post some of the posts I make in my general blog (http://novembersky.tumblr.com). I recently blogged about the importance of Knowledge center in an organization. See the full post below.

One of the best thing I love about my new company is the knowledge center in the new organization. Instead of calling it simply as a library, it’s named as knowledge center. The KC is spacious and the books are beautifully arranged. Also we can enjoy pin-drop silence at the KC. Nobody really make any noise there except the phone calls received in the librarian’s extension.
The place is perfectly lighted and the seating is arranged with different type of couches, round tables, desk and chairs etc. In most of the places we can have only one kind of seating.

The collection in the library is awesome. It contains books related to technical, management, domain related etc. for an organization. Even they’ve assigned an external agency to lend fiction and other general reading titles through the same system. Almost all popular national dailees are available including Economic times. I must specially appreciate the magazine and periodicals available in the KC. Forbes, Fortune, HBR, Business Week, PC Magazine, Digit, Linux Journal, MSDN Magazine etc. Most of the magazines International and Indian versions are available.

The company is totally against the piracy and always encourage the people to make use of the resources available within the organization to ensure continuous learning. Why this make a difference? Why I am talking about obvious things. What usually a programmer lacks in a smaller or immature organization are the facilities and opportunities for continuous learning.

There are several advantages for an IT professional if they work for a small company. But there are disadvantages too. They’re more focused on customers, profits and sustainability (finding grounds). But they’re less cared about employee empowerment and continuous learning.
I even know companies that doesn’t even have a proper library. I found companies where they’re reluctant to purchase books and the library itself is too congested and looks like a garage. The librarian probably living there as he’s finding the end of this world soon.

If you invest in something, you’ve to make sure that it must be beneficial to yourself or others. I have seen libraries like hell where there are no good titles are available dn doesn’t not provide any calm atmosphere to read it. I usually used to buy the expensive books myself.

But this is quite a different story. When I do everything myself for my improvement, I had a feeling that company is not really cared about my growth, which I have to take care of myself. Without any proper support, the company is making money out of my good habits which actually has to be empowered by the organization to some extend.

I heard a anectdote from my friend. Project manager and the employee is having conversation during appraisals.
“Mr. X, you’ve to work for MFC”
“I am sorry sir  I don’t like Native programming much I can make good out of .NET technologies.
“OK then you do one thing, you work in a C# project.”
“No I wont.”
“Why a “NO” now?”
“I had put lot of effort to learn those things and I have an edge at least in this time than others but I am still paid low and you’re undervaluing or squeeze out my talents and skills without giving a penny in return”

I am not sure they discussed in the same or not. But directly or indirectly, he conveyed a great message that “There’s nothing here to learn or improve/There are lack of trainings”…

A good knowledge center or library provides an experience and making sure that people are making use of the system. Also it provides a feeling that organization need to well support for your growth in/out of the organization. I believe that this is one of “Programmer’s Bills of Rights”

 

Root cause analysis – 5 Whys

 

5 Whys is a fundamental technique to find the root causes for problems. It was originally introduced and implemented by Sakichi Toyoda at Toyota Corporation

The basic process is keep asking “Why” to find the root cause. In a typical case, it’s almost possible to find the root cause within 5 whys. But it doesn’t mean that we’ve to stop analyzing further if we can’t find the root cause within 5 whys. It all depends on the complexity of the problem we’re handling. Here’s a classic example published in business week

A few years ago National Parks managers noticed the Jefferson Memorial was crumbling at an alarming rate. When they asked why, they found out it was being washed far more often than other memorials. For most organizations, the analysis would stop here. The solution is clear, right? Adjust the cleaning schedule to match those of the other memorials.

But they did not stop there. They kept asking why for each problems.

  1. This monument is deteriorating faster than any other monuments.
  2. Why? – Found that this monument is washed more frequently than other monuments.
  3. Why? – The bird droppings are high
  4. Why? – There are large population of spiders which the birds were feeding
  5. Why? – Increasing of midges in and around the memorial
  6. Why? – Midges are mate in a unique quality light between specific timings.
  7. Why? – (not really about why midges mate) This unique quality of light created by lighting monument before the dusk.

 

They reached the real root cause of the problem and preferred the action to change the light timings a bit late. By changing this schedule they were able to reduce the bird droppings by 90%

What we’ve to infer from this example.

  • In most of the stages explained above looked like dead end and we felt like to choose trivial solutions but they’ve move forwarded further.
  • When we analyze root cause, initially less people will be involved. Participants will increase on exploring more.
  • The root cause can’t be found on single stretch. It may take any long depends on the problem, information available and the people involved in it
  • The root causes can’t solve the entire problem. It may sometimes solve the entire problem but sometimes it may help us to reduce the damage
  • The action we’re taking should be appropriate otherwise it will increase the damage.
  • It’s required to make sure that the root cause was right before investing time and money in it.

But before starting all these we’ve to ask the fundamental question, do we really need to solve this problem? To solve the problem, it required to analyze the severity, priority, cost and resources available.

Once we decide proceed, we can employ Fish Bone diagram or Ishikawa diagram to effectively map the whys. The causes are grouped in the main groups and formed through brain storming sessions. For e.g. in the manufacturing industry basically we can classify the causes under 8M’s.

  • Machine (technology)
  • Method (process)
  • Material (Includes Raw Material, Consumables and Information.)
  • Man Power (physical work)/Mind Power (brain work): Kaizens, Suggestions
    Measurement (Inspection)
  • Milieu/Mother Nature (Environment)
  • Management/Money Power
  • Maintenance

I am not explaining how to create Fishbone diagram, but it’s really powerful enough to map and find the problems root causes. So keep asking “Why” and when it make sense, stop asking “Why” and proceed to fix the problems.

 

Proudly powered by WordPress
Theme: Esquire by Matthew Buchanan.