Try studying the code snippets above and it has GetBitmap function. If you do a GetBitmap on a NULL bitmap there is a possibility that you get an exception.