A good idea is to look online for a working example of DrawIcon, just google it, and find out whether your casting is correct. I don't quite understand the problem you are having, but I'm sure if you were to find a better DrawIcon example code you can fix this problem easily.